private void accept(@NotNull final PsiElementVisitor visitor, final boolean clearResolveCache) { final boolean needReadAction = !ApplicationManager.getApplication().isReadAccessAllowed(); final PsiManager psiManager = PsiManager.getInstance(myProject); final FileIndex fileIndex = getFileIndex(); accept(new Processor<VirtualFile>() { @Override public boolean process(VirtualFile file) { if (file.isDirectory()) return true; if (ProjectCoreUtil.isProjectOrWorkspaceFile(file)) return true; if (fileIndex.isInContent(file) && (myIncludeTestSource || !fileIndex.isInTestSourceContent(file)) && !isInGeneratedSources(file, myProject)) { return processFile(file, visitor, psiManager, needReadAction, clearResolveCache); } return true; } }); }
@Nullable public static Runnable prepareToReportChangedProjectFiles(@NotNull final Project project, @NotNull Collection<VirtualFile> files) { final Set<VirtualFile> vfs = new THashSet<VirtualFile>(); for (VirtualFile file : files) { if (file != null && !file.isDirectory()) { if (ProjectCoreUtil.isProjectOrWorkspaceFile(file) || isProjectFile(file)) { vfs.add(file); } } } return vfs.isEmpty() ? null : new Runnable() { @Override public void run() { ProjectManagerEx ex = ProjectManagerEx.getInstanceEx(); for (VirtualFile vf : vfs) { ex.saveChangedProjectFile(vf, project); } } }; }
public PsiManagerEx getManager() { Project project = ProjectCoreUtil.theOnlyOpenProject(); if (project != null) { return (PsiManagerEx)PsiManager.getInstance(project); } TreeElement element; for (element = this; element.getTreeParent() != null; element = element.getTreeParent()) { } if (element instanceof FileElement) { //TODO!! return element.getManager(); } else { if (getTreeParent() != null) { return getTreeParent().getManager(); } return null; } }
@Override public boolean shouldInspect(@NotNull PsiElement psiRoot) { if (ApplicationManager.getApplication().isUnitTestMode()) return true; final FileHighlightingSetting settingForRoot = getHighlightingSettingForRoot(psiRoot); if (settingForRoot == FileHighlightingSetting.SKIP_HIGHLIGHTING || settingForRoot == FileHighlightingSetting.SKIP_INSPECTION) { return false; } final Project project = psiRoot.getProject(); final VirtualFile virtualFile = psiRoot.getContainingFile().getVirtualFile(); if (virtualFile == null || !virtualFile.isValid()) return false; if (ProjectCoreUtil.isProjectOrWorkspaceFile(virtualFile)) return false; final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex(); if (ProjectScope.getLibrariesScope(project).contains(virtualFile) && !fileIndex.isInContent(virtualFile)) return false; return !SingleRootFileViewProvider.isTooLargeForIntelligence(virtualFile); }
public static boolean shouldInspect(@NotNull PsiElement psiRoot) { if (ApplicationManager.getApplication().isUnitTestMode()) return true; if (!shouldHighlight(psiRoot)) return false; final Project project = psiRoot.getProject(); final VirtualFile virtualFile = psiRoot.getContainingFile().getVirtualFile(); if (virtualFile == null || !virtualFile.isValid()) return false; if (ProjectCoreUtil.isProjectOrWorkspaceFile(virtualFile)) return false; final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex(); if (ProjectScope.getLibrariesScope(project).contains(virtualFile) && !fileIndex.isInContent(virtualFile)) return false; if (SingleRootFileViewProvider.isTooLargeForIntelligence(virtualFile)) return false; final HighlightingSettingsPerFile component = HighlightingSettingsPerFile.getInstance(project); if (component == null) return true; final FileHighlightingSetting settingForRoot = component.getHighlightingSettingForRoot(psiRoot); return settingForRoot != FileHighlightingSetting.SKIP_INSPECTION; }
private void accept(@Nonnull final PsiElementVisitor visitor, final boolean clearResolveCache) { final boolean needReadAction = !ApplicationManager.getApplication().isReadAccessAllowed(); final PsiManager psiManager = PsiManager.getInstance(myProject); final FileIndex fileIndex = getFileIndex(); accept(new Processor<VirtualFile>() { @Override public boolean process(VirtualFile file) { if (file.isDirectory()) return true; if (ProjectCoreUtil.isProjectOrWorkspaceFile(file)) return true; if (fileIndex.isInContent(file) && (myIncludeTestSource || !fileIndex.isInTestSourceContent(file)) && !isInGeneratedSources(file, myProject)) { return processFile(file, visitor, psiManager, needReadAction, clearResolveCache); } return true; } }); }
@Override public PsiManagerEx getManager() { Project project = ProjectCoreUtil.theOnlyOpenProject(); if (project != null) { return PsiManagerEx.getInstanceEx(project); } PsiElement parent = this; while (parent instanceof ASTDelegatePsiElement) { parent = parent.getParent(); } if (parent == null) { throw new PsiInvalidElementAccessException(this); } return (PsiManagerEx)parent.getManager(); }
public PsiManagerEx getManager() { Project project = ProjectCoreUtil.theOnlyOpenProject(); if (project != null) { return PsiManagerEx.getInstanceEx(project); } TreeElement element; for (element = this; element.getTreeParent() != null; element = element.getTreeParent()) { } if (element instanceof FileElement) { //TODO!! return element.getManager(); } else { if (getTreeParent() != null) { return getTreeParent().getManager(); } return null; } }
@Override public boolean shouldInspect(@Nonnull PsiElement psiRoot) { if (ApplicationManager.getApplication().isUnitTestMode()) return true; if (!shouldHighlight(psiRoot)) return false; final Project project = psiRoot.getProject(); final VirtualFile virtualFile = psiRoot.getContainingFile().getVirtualFile(); if (virtualFile == null || !virtualFile.isValid()) return false; if (ProjectCoreUtil.isProjectOrWorkspaceFile(virtualFile)) return false; final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex(); if (ProjectScope.getLibrariesScope(project).contains(virtualFile) && !fileIndex.isInContent(virtualFile)) return false; if (SingleRootFileViewProvider.isTooLargeForIntelligence(virtualFile)) return false; final FileHighlightingSetting settingForRoot = getHighlightingSettingForRoot(psiRoot); return settingForRoot != FileHighlightingSetting.SKIP_INSPECTION; }
public static boolean shouldInspect(@Nonnull PsiElement psiRoot) { if (ApplicationManager.getApplication().isUnitTestMode()) return true; if (!shouldHighlight(psiRoot)) return false; final Project project = psiRoot.getProject(); final VirtualFile virtualFile = psiRoot.getContainingFile().getVirtualFile(); if (virtualFile == null || !virtualFile.isValid()) return false; if (ProjectCoreUtil.isProjectOrWorkspaceFile(virtualFile)) return false; final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex(); if (ProjectScope.getLibrariesScope(project).contains(virtualFile) && !fileIndex.isInContent(virtualFile)) return false; if (SingleRootFileViewProvider.isTooLargeForIntelligence(virtualFile)) return false; final HighlightingSettingsPerFile component = HighlightingSettingsPerFile.getInstance(project); if (component == null) return true; final FileHighlightingSetting settingForRoot = component.getHighlightingSettingForRoot(psiRoot); return settingForRoot != FileHighlightingSetting.SKIP_INSPECTION; }
@Override public void documentChanged(DocumentEvent event) { if (myDocumentSavingInProgress) { /** When {@link FileDocumentManager#saveAllDocuments} is called, * {@link com.intellij.openapi.editor.impl.TrailingSpacesStripper} can change a document. * These needless 'documentChanged' events should be filtered out. */ return; } final Document document = event.getDocument(); final VirtualFile file = FileDocumentManager.getInstance().getFile(document); if (file == null) { return; } if (!myChangedFiles.contains(file)) { if (ProjectCoreUtil.isProjectOrWorkspaceFile(file)) { return; } if (myChangedFileFilter != null && !myChangedFileFilter.value(file)) { return; } myChangedFiles.add(file); } myAlarm.cancelRequest(myAlarmRunnable); myAlarm.addRequest(myAlarmRunnable, myDelayMillis); myModificationStamp++; }
@Override @NotNull public Project getProject() { Project project = ProjectCoreUtil.theOnlyOpenProject(); if (project != null) { return project; } final PsiManager manager = getManager(); if (manager == null) throw new PsiInvalidElementAccessException(this); return manager.getProject(); }
@Override @NotNull public Project getProject() { Project project = ProjectCoreUtil.theOnlyOpenProject(); if (project != null) { return project; } final PsiManager manager = getManager(); if (manager == null) invalid(); return manager.getProject(); }
public boolean isSupportedFile(VirtualFile file) { if (file == null || file.isDirectory()) { return false; } if (ProjectCoreUtil.isProjectOrWorkspaceFile(file)) return false; FileType type = file.getFileType(); return getMap().get(type.getName()) != null; }
public static boolean isSupportedFile(PsiFile file) { if (file == null || file instanceof PsiDirectory || file instanceof PsiCodeFragment) { return false; } final VirtualFile virtualFile = file.getVirtualFile(); if (virtualFile == null) return false; if (ProjectCoreUtil.isProjectOrWorkspaceFile(virtualFile)) return false; return isSupportedType(virtualFile.getFileType()); }
@SuppressWarnings({"SimplifiableIfStatement"}) private boolean processFile(@NotNull final VirtualFile fileOrDir, @NotNull final PsiElementVisitor visitor, @NotNull final FileIndex projectFileIndex, @NotNull final PsiManager psiManager, final boolean needReadAction) { if (fileOrDir.isDirectory()) return true; if (ProjectCoreUtil.isProjectOrWorkspaceFile(fileOrDir)) return true; if (projectFileIndex.isInContent(fileOrDir) && (myIncludeTestSource || !projectFileIndex.isInTestSourceContent(fileOrDir))) { return processFile(fileOrDir, visitor, psiManager, needReadAction); } return true; }
public static void reportProjectFileChangeIfNeeded(Project project, VirtualFile file) { if (file != null && ! file.isDirectory()) { if (ProjectCoreUtil.isProjectOrWorkspaceFile(file) || isProjectFile(file)) { ProjectManagerEx.getInstanceEx().saveChangedProjectFile(file, project); } } }
public static boolean isSupportedFile(PsiFile file) { if (file == null || file instanceof PsiDirectory) { return false; } final VirtualFile virtualFile = file.getVirtualFile(); if (virtualFile == null) return false; if (ProjectCoreUtil.isProjectOrWorkspaceFile(virtualFile)) return false; return isSupportedType(virtualFile.getFileType()); }
@Override public void documentChanged(DocumentEvent event) { if (myDocumentSavingInProgress) { /* When {@link FileDocumentManager#saveAllDocuments} is called, {@link com.intellij.openapi.editor.impl.TrailingSpacesStripper} can change a document. These needless 'documentChanged' events should be filtered out. */ return; } final Document document = event.getDocument(); final VirtualFile file = FileDocumentManager.getInstance().getFile(document); if (file == null) { return; } if (!myChangedFiles.contains(file)) { if (ProjectCoreUtil.isProjectOrWorkspaceFile(file)) { return; } if (myChangedFileFilter != null && !myChangedFileFilter.value(file)) { return; } myChangedFiles.add(file); } myAlarm.cancelRequest(myAlarmRunnable); myAlarm.addRequest(myAlarmRunnable, myDelayMillis); myModificationStamp++; }
@Override public PsiManagerEx getManager() { Project project = ProjectCoreUtil.theOnlyOpenProject(); if (project != null) { return PsiManagerEx.getInstanceEx(project); } return (PsiManagerEx)getContainingFile().getManager(); }
@Override @Nonnull public Project getProject() { Project project = ProjectCoreUtil.theOnlyOpenProject(); if (project != null) { return project; } return getContainingFile().getProject(); }
@Override @Nonnull public Project getProject() { Project project = ProjectCoreUtil.theOnlyOpenProject(); if (project != null) { return project; } final PsiManager manager = getManager(); if (manager == null) throw new PsiInvalidElementAccessException(this); return manager.getProject(); }
@Override @Nonnull public Project getProject() { Project project = ProjectCoreUtil.theOnlyOpenProject(); if (project != null) { return project; } final PsiManager manager = getManager(); if (manager == null) invalid(); return manager.getProject(); }
public static String getCurrentSeparator() { return getCurrentSeparator(ProjectCoreUtil.theOnlyOpenProject()); }
public static void reportProjectFileChangeIfNeeded(@Nullable Project project, @Nullable VirtualFile file) { if (project != null && file != null && !file.isDirectory() && (ProjectCoreUtil.isProjectOrWorkspaceFile(file) || isProjectFile(file))) { ProjectManagerEx.getInstanceEx().saveChangedProjectFile(file, project); } }
private boolean shouldBeIgnored(@NotNull VirtualFile virtualFile) { return ProjectCoreUtil.isProjectOrWorkspaceFile(virtualFile) || ProjectRootManager.getInstance(myProject).getFileIndex().isExcluded(virtualFile); }
private boolean shouldBeIgnored(@Nonnull VirtualFile virtualFile) { return ProjectCoreUtil.isProjectOrWorkspaceFile(virtualFile) || ProjectRootManager.getInstance(myProject).getFileIndex().isExcluded(virtualFile); }