public static void main(String[] args) throws AnalysisException, IOException { StandaloneConfig config = new StandaloneConfig(); config.parseCommandLine(args); MemoryStatisticsCollector statistics = null; if (config.getPrintStatistics()) { statistics = new MemoryStatisticsCollector(); } List<String> compilation = config.getCompilation(); if (compilation.size() > 1) { System.err.println("Java indexer received too many arguments; got " + compilation); usage(1); } CompilationDescription desc = null; if (!Strings.isNullOrEmpty(config.getIndexPackRoot())) { // java_indexer --index_pack=archive-root unit-key desc = new Archive(config.getIndexPackRoot()).readDescription(compilation.get(0)); } else { // java_indexer kindex-file desc = IndexInfoUtils.readIndexInfoFromFile(compilation.get(0)); } if (desc == null) { throw new IllegalStateException("Unknown error reading CompilationDescription"); } if (!desc.getFileContents().iterator().hasNext()) { return; } try (OutputStream stream = Strings.isNullOrEmpty(config.getOutputPath()) ? System.out : new BufferedOutputStream(new FileOutputStream(config.getOutputPath()))) { new JavacAnalysisDriver() .analyze( new KytheJavacAnalyzer( config, new StreamFactEmitter(stream), statistics == null ? NullStatisticsCollector.getInstance() : statistics), desc.getCompilationUnit(), new FileDataCache(desc.getFileContents()), false); } if (statistics != null) { statistics.printStatistics(System.err); } }