/** * Invoke the compiler to build all of the files passed on the command line * * @param analyzerOptions parsed command line arguments * @return {@code true} on success, {@code false} on failure. */ protected static ErrorSeverity runAnalyzer(AnalyzerOptions options) throws IOException, AnalysisException { File sourceFile = new File(options.getSourceFile()); if (!sourceFile.exists()) { System.out.println("File not found: " + sourceFile); System.out.println(); showUsage(System.out); return ErrorSeverity.ERROR; } // TODO: also support analyzing html files (via AnalysisEngine.isHtmlFileName()) if (!AnalysisEngine.isDartFileName(sourceFile.getName())) { System.out.println(sourceFile + " is not a Dart file"); System.out.println(); showUsage(System.out); return ErrorSeverity.ERROR; } ErrorFormatter formatter = new ErrorFormatter(options.getMachineFormat() ? System.err : System.out, options); List<AnalysisError> errors = new ArrayList<AnalysisError>(); formatter.startAnalysis(); long startTime = System.currentTimeMillis(); AnalyzerImpl analyzer = new AnalyzerImpl(options); ErrorSeverity status = analyzer.analyze(sourceFile, errors); formatter.formatErrors(errors); if (status.equals(ErrorSeverity.WARNING) && options.getWarningsAreFatal()) { status = ErrorSeverity.ERROR; } if (options.getPerf()) { long totalTime = System.currentTimeMillis() - startTime; System.out.println("scan:" + PerformanceStatistics.scan.getResult()); System.out.println("parse:" + PerformanceStatistics.parse.getResult()); System.out.println("resolve:" + PerformanceStatistics.resolve.getResult()); System.out.println("errors:" + PerformanceStatistics.errors.getResult()); System.out.println("hints:" + PerformanceStatistics.hints.getResult()); System.out.println("total:" + totalTime); } return status; }