Java Code Examples for com.intellij.openapi.vfs.newvfs.events.VFileEvent#getFile()

The following examples show how to use com.intellij.openapi.vfs.newvfs.events.VFileEvent#getFile() . 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: 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 2
Source File: BulkSymbolTableBuildingChangeListener.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
public void after(List<? extends VFileEvent> events) {
  if (!enabled) {
    return;
  }
  for (VFileEvent event : events) {
    VirtualFile modifiedFile = null;
    // Skip delete events.
    if (event instanceof VFileContentChangeEvent || event instanceof VFileCreateEvent) {
      modifiedFile = event.getFile();
    } else if (event instanceof VFileCopyEvent) {
      VFileCopyEvent copyEvent = (VFileCopyEvent) event;
      modifiedFile = copyEvent.getNewParent();
    } else if (event instanceof VFileMoveEvent) {
      VFileMoveEvent moveEvent = (VFileMoveEvent) event;
      modifiedFile = moveEvent.getNewParent();
    } else if (event instanceof VFilePropertyChangeEvent) {
      VFilePropertyChangeEvent propEvent = (VFilePropertyChangeEvent) event;
      // Check for file renames (sometimes we get property change events without the name
      // actually changing though)
      if (propEvent.getPropertyName().equals(VirtualFile.PROP_NAME)
          && !propEvent.getOldValue().equals(propEvent.getNewValue())) {
        modifiedFile = propEvent.getFile();
      }
    }
    if (SymbolTableProvider.isSourceFile(project, modifiedFile)) {
      queueChange(modifiedFile);
    }
  }
}
 
Example 3
Source File: LatteFileListener.java    From intellij-latte with MIT License 5 votes vote down vote up
@Override
public void after(@NotNull List<? extends VFileEvent> events) {
    for (VFileEvent event : events) {
        VirtualFile file = event.getFile();
        if (!(file instanceof XmlFile) || !file.getName().equals("latte-intellij.xml") || file.isValid()) {
            continue;
        }

        XmlDocument document = ((XmlFile) file).getDocument();
        if (document == null || document.getRootTag() == null) {
            continue;
        }

        LatteXmlFileData.VendorResult vendorResult = LatteXmlFileDataFactory.getVendor(document);
        if (vendorResult == null) {
            continue;
        }

        List<Project> projects = new ArrayList<>();
        Project project = ProjectUtil.guessProjectForContentFile(file);
        if (project != null) {
            projects.add(project);
        } else {
            Collections.addAll(projects, ProjectManager.getInstance().getOpenProjects());
        }

        LatteIndexUtil.notifyRemovedFiles(projects);
    }
}
 
Example 4
Source File: RootIndex.java    From consulo with Apache License 2.0 5 votes vote down vote up
boolean resetOnEvents(@Nonnull List<? extends VFileEvent> events) {
  for (VFileEvent event : events) {
    VirtualFile file = event.getFile();
    if (file == null || file.isDirectory()) {
      return true;
    }
  }
  return false;
}
 
Example 5
Source File: FileExperimentLoader.java    From intellij with Apache License 2.0 4 votes vote down vote up
private boolean isExperimentsFile(VFileEvent event) {
  return event.getFile() != null && event.getFile().getPath().equals(file.getPath());
}
 
Example 6
Source File: DWBulkFileListener.java    From intellij-demandware with MIT License 4 votes vote down vote up
@Override
public void after(@NotNull List<? extends VFileEvent> events) {
    Project[] projects = ProjectManager.getInstance().getOpenProjects();

    for (VFileEvent event : events) {
        VirtualFile eventFile = event.getFile();

        if (eventFile != null && !eventFile.isDirectory()) {
            for (Project project : projects) {
                Module module = ProjectRootManager.getInstance(project).getFileIndex().getModuleForFile(eventFile);

                if (module != null) {
                    ModuleType CurrentModuleType = ModuleType.get(module);

                    // Bail out if auto uploads are not enabled.
                    if (!DWSettingsProvider.getInstance(module).getAutoUploadEnabled()) {
                        return;
                    }

                    if (CurrentModuleType instanceof DWModuleType) {
                        for (VirtualFile sourceRoot : ModuleRootManager.getInstance(module).getSourceRoots()) {
                            if (eventFile.getPath().contains(sourceRoot.getPath())) {
                                ProgressManager.getInstance().run(
                                    new DWUpdateFileTask(
                                        project,
                                        module,
                                        "Syncing files to: " + DWSettingsProvider.getInstance(module).getHostname(),
                                        true,
                                        PerformInBackgroundOption.ALWAYS_BACKGROUND,
                                        sourceRoot.getPath(),
                                        eventFile.getPath()
                                    )
                                );
                            }
                        }
                    }
                }
            }
        }
    }
}