private static void logStats(Collection<PsiFile> otherFiles, long start) { long time = System.currentTimeMillis() - start; final Multiset<String> stats = HashMultiset.create(); for (PsiFile file : otherFiles) { stats.add( StringUtil.notNullize(file.getViewProvider().getVirtualFile().getExtension()) .toLowerCase()); } List<String> extensions = ContainerUtil.newArrayList(stats.elementSet()); Collections.sort( extensions, new Comparator<String>() { @Override public int compare(String o1, String o2) { return stats.count(o2) - stats.count(o1); } }); String message = "Search in " + otherFiles.size() + " files with unknown types took " + time + "ms.\n" + "Mapping their extensions to an existing file type (e.g. Plain Text) might speed up the search.\n" + "Most frequent non-indexed file extensions: "; for (int i = 0; i < Math.min(10, extensions.size()); i++) { String extension = extensions.get(i); message += extension + "(" + stats.count(extension) + ") "; } LOG.info(message); }
public void findUsages( @NotNull final Processor<UsageInfo> consumer, @NotNull FindUsagesProcessPresentation processPresentation) { try { myProgress.setIndeterminate(true); myProgress.setText("Scanning indexed files..."); final Set<PsiFile> filesForFastWordSearch = ApplicationManager.getApplication() .runReadAction( new Computable<Set<PsiFile>>() { @Override public Set<PsiFile> compute() { return getFilesForFastWordSearch(); } }); myProgress.setIndeterminate(false); searchInFiles(filesForFastWordSearch, processPresentation, consumer); myProgress.setIndeterminate(true); myProgress.setText("Scanning non-indexed files..."); boolean skipIndexed = canRelyOnIndices(); final Collection<PsiFile> otherFiles = collectFilesInScope(filesForFastWordSearch, skipIndexed); myProgress.setIndeterminate(false); long start = System.currentTimeMillis(); searchInFiles(otherFiles, processPresentation, consumer); if (skipIndexed && otherFiles.size() > 1000) { logStats(otherFiles, start); } } catch (ProcessCanceledException e) { // fine } if (!myLargeFiles.isEmpty()) { processPresentation.setLargeFilesWereNotScanned(myLargeFiles); } if (!myProgress.isCanceled()) { myProgress.setText(FindBundle.message("find.progress.search.completed")); } }
private void doCompile(@NotNull final ModuleChunk chunk, @NotNull String outputDir) throws IOException { myCompileContext.getProgressIndicator().checkCanceled(); if (ApplicationManager.getApplication() .runReadAction( new Computable<Boolean>() { public Boolean compute() { return chunk.getFilesToCompile().isEmpty() ? Boolean.TRUE : Boolean.FALSE; } }) .booleanValue()) { return; // should not invoke javac with empty sources list } int exitValue = 0; try { final Process process = myCompiler.launchProcess(chunk, outputDir, myCompileContext); final long compilationStart = System.currentTimeMillis(); final ClassParsingThread classParsingThread = new ClassParsingThread(isJdk6(JavaSdkUtil.getSdkForCompilation(chunk)), outputDir); final Future<?> classParsingThreadFuture = ApplicationManager.getApplication().executeOnPooledThread(classParsingThread); OutputParser errorParser = myCompiler.createErrorParser(outputDir, process); CompilerParsingThread errorParsingThread = errorParser == null ? null : new SynchedCompilerParsing( process, myCompileContext, errorParser, classParsingThread, true, errorParser.isTrimLines()); Future<?> errorParsingThreadFuture = null; if (errorParsingThread != null) { errorParsingThreadFuture = ApplicationManager.getApplication().executeOnPooledThread(errorParsingThread); } OutputParser outputParser = myCompiler.createOutputParser(outputDir); CompilerParsingThread outputParsingThread = outputParser == null ? null : new SynchedCompilerParsing( process, myCompileContext, outputParser, classParsingThread, false, outputParser.isTrimLines()); Future<?> outputParsingThreadFuture = null; if (outputParsingThread != null) { outputParsingThreadFuture = ApplicationManager.getApplication().executeOnPooledThread(outputParsingThread); } try { exitValue = process.waitFor(); } catch (InterruptedException e) { process.destroy(); exitValue = process.exitValue(); } catch (Error e) { process.destroy(); exitValue = process.exitValue(); throw e; } finally { if (CompileDriver.ourDebugMode) { System.out.println("Compiler exit code is " + exitValue); } if (errorParsingThread != null) { errorParsingThread.setProcessTerminated(true); } if (outputParsingThread != null) { outputParsingThread.setProcessTerminated(true); } joinThread(errorParsingThreadFuture); joinThread(outputParsingThreadFuture); classParsingThread.stopParsing(); joinThread(classParsingThreadFuture); registerParsingException(outputParsingThread); registerParsingException(errorParsingThread); assert outputParsingThread == null || !outputParsingThread.processing; assert errorParsingThread == null || !errorParsingThread.processing; assert classParsingThread == null || !classParsingThread.processing; } } finally { compileFinished(exitValue, chunk, outputDir); myModuleName = null; } }