Skip to content

Commit

Permalink
Improve query sync file listener
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 589240330
  • Loading branch information
Googler authored and copybara-github committed Dec 8, 2023
1 parent f486224 commit 4b1723b
Showing 1 changed file with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.AsyncFileListener;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.newvfs.events.VFileContentChangeEvent;
import com.intellij.openapi.vfs.newvfs.events.VFileCreateEvent;
import com.intellij.openapi.vfs.newvfs.events.VFileEvent;
import com.intellij.openapi.vfs.newvfs.events.VFileMoveEvent;
import com.intellij.openapi.vfs.newvfs.events.VFilePropertyChangeEvent;
import java.nio.file.Path;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
Expand Down Expand Up @@ -83,6 +83,13 @@ private ImmutableList<? extends VFileEvent> filterForProject(
}

private boolean requiresSync(VFileEvent event) {
if (event instanceof VFileCreateEvent || event instanceof VFileMoveEvent) {
return true;
} else if (event instanceof VFilePropertyChangeEvent
&& ((VFilePropertyChangeEvent) event).getPropertyName().equals("name")) {
return true;
}

VirtualFile vf = event.getFile();
if (vf == null) {
return false;
Expand All @@ -92,17 +99,6 @@ private boolean requiresSync(VFileEvent event) {
return true;
}

if (event instanceof VFileCreateEvent || event instanceof VFileMoveEvent) {
return true;
}

if (event instanceof VFileContentChangeEvent) {
// TODO: Check if file is not already part of graph
if (((VFileContentChangeEvent) event).getOldLength() == 0) {
return true;
}
}

return false;
}

Expand Down

0 comments on commit 4b1723b

Please sign in to comment.