Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Unified Diff: pkg/analyzer/bin/analyzer.dart

Issue 195483004: Convert the command line dart analyzer to be async. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 2 nits Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer/bin/analyzer.dart
diff --git a/pkg/analyzer/bin/analyzer.dart b/pkg/analyzer/bin/analyzer.dart
index 3908fb582ceed2ddcf6f9686cf28dec27f59fadb..493554fe094e943bbf87ed2a2109868f4fdfb4a6 100644
--- a/pkg/analyzer/bin/analyzer.dart
+++ b/pkg/analyzer/bin/analyzer.dart
@@ -11,14 +11,12 @@ import 'dart:async';
import 'dart:convert';
import 'dart:io';
+import 'package:analyzer/src/analyzer_impl.dart';
import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/error.dart';
-import 'package:analyzer/src/generated/java_core.dart' show JavaSystem, instanceOfTimer;
+import 'package:analyzer/src/generated/java_core.dart' show JavaSystem;
import 'package:analyzer/options.dart';
-import 'package:analyzer/src/analyzer_impl.dart';
-import 'package:analyzer/src/error_formatter.dart';
-
void main(args) {
var options = CommandLineOptions.parse(args);
if (options.shouldBatch) {
@@ -27,36 +25,12 @@ void main(args) {
return _runAnalyzer(options);
});
} else {
- int startTime = JavaSystem.currentTimeMillis();
-
- ErrorSeverity result = _runAnalyzer(options);
-
- if (options.perf) {
- int totalTime = JavaSystem.currentTimeMillis() - startTime;
- int ioTime = PerformanceStatistics.io.result;
- int scanTime = PerformanceStatistics.scan.result;
- int parseTime = PerformanceStatistics.parse.result;
- int resolveTime = PerformanceStatistics.resolve.result;
- int errorsTime = PerformanceStatistics.errors.result;
- int hintsTime = PerformanceStatistics.hints.result;
- int angularTime = PerformanceStatistics.angular.result;
- print("io:$ioTime");
- print("scan:$scanTime");
- print("parse:$parseTime");
- print("resolve:$resolveTime");
- print("errors:$errorsTime");
- print("hints:$hintsTime");
- print("angular:$angularTime");
- print("other:${totalTime
- - (ioTime + scanTime + parseTime + resolveTime + errorsTime + hintsTime
- + angularTime)}");
- print("total:$totalTime");
- }
- exitCode = result.ordinal;
+ _runAnalyzer(options);
}
}
-ErrorSeverity _runAnalyzer(CommandLineOptions options) {
+void _runAnalyzer(var options) {
Brian Wilkerson 2014/03/11 18:36:53 Please provide a type annotation for the parameter
jwren 2014/03/11 21:53:04 Done.
+ int startTime = JavaSystem.currentTimeMillis();
if (!options.machineFormat) {
stdout.writeln("Analyzing ${options.sourceFiles}...");
}
@@ -66,25 +40,16 @@ ErrorSeverity _runAnalyzer(CommandLineOptions options) {
// check that file exists
if (!new File(sourcePath).existsSync()) {
print('File not found: $sourcePath');
- return ErrorSeverity.ERROR;
+ exitCode = ErrorSeverity.ERROR.ordinal;
}
// check that file is Dart file
if (!AnalysisEngine.isDartFileName(sourcePath)) {
print('$sourcePath is not a Dart file');
- return ErrorSeverity.ERROR;
+ exitCode = ErrorSeverity.ERROR.ordinal;
}
// do analyze
- ErrorFormatter formatter = new ErrorFormatter(options.machineFormat ? stderr : stdout, options);
- AnalyzerImpl analyzer = new AnalyzerImpl(options);
- analyzer.analyze(sourcePath);
- // print errors
- formatter.formatErrors(analyzer.errorInfos);
- // prepare status
- ErrorSeverity status = analyzer.maxErrorSeverity;
- if (status == ErrorSeverity.WARNING && options.warningsAreFatal) {
- status = ErrorSeverity.ERROR;
- }
- return status;
+ AnalyzerImpl analyzer = new AnalyzerImpl(sourcePath, options, startTime);
+ analyzer.analyze();
}
typedef ErrorSeverity BatchRunnerHandler(List<String> args);

Powered by Google App Engine
This is Rietveld 408576698