public static boolean isSupportedFileType(@NotNull VirtualFile virtualFile) { if (virtualFile.isDirectory()) return true; if (virtualFile.getFileType() == StdFileTypes.JAVA) return true; if (virtualFile.getFileType() == StdFileTypes.XML && !ProjectCoreUtil.isProjectOrWorkspaceFile(virtualFile)) return true; if ("groovy".equals(virtualFile.getExtension())) return true; return false; }
private static boolean canBeFormatted(PsiFile file) { if (LanguageFormatting.INSTANCE.forContext(file) == null) { return false; } VirtualFile virtualFile = file.getVirtualFile(); if (virtualFile == null) return true; if (ProjectCoreUtil.isProjectOrWorkspaceFile(virtualFile)) return false; return !GeneratedSourcesFilter.isGeneratedSourceByAnyFilter(virtualFile, file.getProject()); }
@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); }
private boolean shouldBeIgnored(@NotNull VirtualFile virtualFile) { return ProjectCoreUtil.isProjectOrWorkspaceFile(virtualFile) || ProjectRootManager.getInstance(myProject).getFileIndex().isExcluded(virtualFile); }
private void searchInFiles( @NotNull Collection<PsiFile> psiFiles, @NotNull FindUsagesProcessPresentation processPresentation, @NotNull final Processor<UsageInfo> consumer) { int i = 0; long totalFilesSize = 0; int count = 0; for (final PsiFile psiFile : psiFiles) { final VirtualFile virtualFile = psiFile.getVirtualFile(); final int index = i++; if (virtualFile == null) continue; long fileLength = UsageViewManagerImpl.getFileLength(virtualFile); if (fileLength == -1) continue; // Binary or invalid final boolean skipProjectFile = ProjectCoreUtil.isProjectOrWorkspaceFile(virtualFile) && !myFindModel.isSearchInProjectFiles(); if (skipProjectFile && !Registry.is("find.search.in.project.files")) continue; if (fileLength > SINGLE_FILE_SIZE_LIMIT) { myLargeFiles.add(psiFile); continue; } myProgress.checkCanceled(); myProgress.setFraction((double) index / psiFiles.size()); String text = FindBundle.message( "find.searching.for.string.in.file.progress", myFindModel.getStringToFind(), virtualFile.getPresentableUrl()); myProgress.setText(text); myProgress.setText2( FindBundle.message("find.searching.for.string.in.file.occurrences.progress", count)); int countInFile = FindInProjectUtil.processUsagesInFile( psiFile, myFindModel, new Processor<UsageInfo>() { @Override public boolean process(UsageInfo info) { return skipProjectFile || consumer.process(info); } }); if (countInFile > 0 && skipProjectFile) { processPresentation.projectFileUsagesFound( new Runnable() { @Override public void run() { FindModel model = myFindModel.clone(); model.setSearchInProjectFiles(true); FindInProjectManager.getInstance(myProject).startFindInProject(model); } }); continue; } count += countInFile; if (countInFile > 0) { totalFilesSize += fileLength; if (totalFilesSize > FILES_SIZE_LIMIT && !myWarningShown) { myWarningShown = true; String message = FindBundle.message( "find.excessive.total.size.prompt", UsageViewManagerImpl.presentableSize(totalFilesSize), ApplicationNamesInfo.getInstance().getProductName()); UsageLimitUtil.showAndCancelIfAborted( myProject, message, processPresentation.getUsageViewPresentation()); } } } }