com.intellij.openapi.vfs.newvfs.events.VFileDeleteEvent Java Examples

The following examples show how to use com.intellij.openapi.vfs.newvfs.events.VFileDeleteEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExternalLibraryManager.java    From intellij with Apache License 2.0 6 votes vote down vote up
ExternalLibraryManager(Project project) {
  this.project = project;
  this.duringBlazeSync = false;
  this.libraries = ImmutableMap.of();
  AsyncVfsEventsPostProcessor.getInstance()
      .addListener(
          events -> {
            if (duringBlazeSync || libraries.isEmpty()) {
              return;
            }
            ImmutableList<VirtualFile> deletedFiles =
                events.stream()
                    .filter(VFileDeleteEvent.class::isInstance)
                    .map(VFileEvent::getFile)
                    .collect(toImmutableList());
            if (!deletedFiles.isEmpty()) {
              libraries.values().forEach(library -> library.removeInvalidFiles(deletedFiles));
            }
          },
          project);
}
 
Example #2
Source File: QuarkusLanguageClient.java    From intellij-quarkus with Eclipse Public License 2.0 5 votes vote down vote up
private void filter(VFileEvent event, Set<String> uris) {
  VirtualFile file = event.getFile();
  if (file != null && file.exists() && "java".equalsIgnoreCase(file.getExtension())) {
    Module module = ProjectFileIndex.getInstance(getProject()).getModuleForFile(file);
    if (module != null && (event instanceof VFileCreateEvent || event instanceof VFileContentChangeEvent || event instanceof VFileDeleteEvent)) {
      uris.add(PsiUtilsImpl.getProjectURI(module));
    }
  }
}
 
Example #3
Source File: FastBuildChangedFilesService.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
public void after(List<? extends VFileEvent> events) {
  ListenableFuture<Void> submit =
      executor.submit(
          () -> {
            synchronized (FastBuildChangedFilesService.this) {
              if (!isCollecting()) {
                return null;
              }

              ImmutableSet<File> changedFiles =
                  events.stream()
                      // We don't want to compile deleted files
                      .filter(event -> !(event instanceof VFileDeleteEvent))
                      .map(VFileEvent::getPath)
                      .filter(f -> f.endsWith(".java"))
                      .map(File::new)
                      .collect(toImmutableSet());

              if (changedFiles.isEmpty()) {
                return null;
              }
              // TODO(b/145386688): Access should be guarded by enclosing instance
              // 'com.google.idea.blaze.java.fastbuild.FastBuildChangedFilesService' of 'data',
              // which is not accessible in this scope
              labelData.values().forEach(data -> data.updateChangedSources(changedFiles));
              return null;
            }
          });
  Futures.addCallback(submit, new LogErrorCallback(), executor);
}
 
Example #4
Source File: LocalFileSystemTest.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void testFindRoot() throws IOException {
  VirtualFile root = myFS.findFileByPath("wrong_path");
  assertNull(root);

  VirtualFile root2;
  if (SystemInfo.isWindows) {
    root = myFS.findFileByPath("\\\\unit-133");
    assertNotNull(root);
    root2 = myFS.findFileByPath("//UNIT-133");
    assertNotNull(root2);
    assertEquals(String.valueOf(root2), root, root2);
    RefreshQueue.getInstance().processSingleEvent(new VFileDeleteEvent(this, root, false));

    root = myFS.findFileByIoFile(new File("\\\\unit-133"));
    assertNotNull(root);
    RefreshQueue.getInstance().processSingleEvent(new VFileDeleteEvent(this, root, false));

    if (new File("c:").exists()) {
      root = myFS.findFileByPath("c:");
      assertNotNull(root);
      assertEquals("C:/", root.getPath());

      root2 = myFS.findFileByPath("C:\\");
      assertSame(String.valueOf(root), root, root2);

      VirtualFileManager fm = VirtualFileManager.getInstance();
      root = fm.findFileByUrl("file://C:/");
      assertNotNull(root);
      root2 = fm.findFileByUrl("file:///c:/");
      assertSame(String.valueOf(root), root, root2);
    }
  }
  else if (SystemInfo.isUnix) {
    root = myFS.findFileByPath("/");
    assertNotNull(root);
    assertEquals(root.getPath(), "/");
  }

  root = myFS.findFileByPath("");
  assertNotNull(root);

  File jarFile = IoTestUtil.createTestJar();
  root = VirtualFileManager.getInstance().findFileByUrl("jar://" + jarFile.getPath() + "!/");
  assertNotNull(root);

  root2 = VirtualFileManager.getInstance().findFileByUrl("jar://" + jarFile.getPath().replace(File.separator, "//") + "!/");
  assertEquals(String.valueOf(root2), root, root2);

  if (!SystemInfo.isFileSystemCaseSensitive) {
    root2 = VirtualFileManager.getInstance().findFileByUrl("jar://" + jarFile.getPath().toUpperCase(Locale.US) + "!/");
    assertEquals(String.valueOf(root2), root, root2);
  }
}
 
Example #5
Source File: FileDocumentManagerImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
private void fileDeleted(@Nonnull VFileDeleteEvent event) {
  Document doc = getCachedDocument(event.getFile());
  if (doc != null) {
    myTrailingSpacesStripper.documentDeleted(doc);
  }
}