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

Side by Side Diff: pkg/analyzer_experimental/bin/analyzer.dart

Issue 15675016: More fixes for java2dart and status files. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env dart 1 #!/usr/bin/env dart
2 2
3 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 3 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
4 // for details. All rights reserved. Use of this source code is governed by a 4 // for details. All rights reserved. Use of this source code is governed by a
5 // BSD-style license that can be found in the LICENSE file. 5 // BSD-style license that can be found in the LICENSE file.
6 6
7 /** The entry point for the analyzer. */ 7 /** The entry point for the analyzer. */
8 library analyzer; 8 library analyzer;
9 9
10 import 'dart:async'; 10 import 'dart:async';
(...skipping 24 matching lines...) Expand all
35 ErrorSeverity result = _runAnalyzer(options); 35 ErrorSeverity result = _runAnalyzer(options);
36 exit(result.ordinal); 36 exit(result.ordinal);
37 } 37 }
38 } 38 }
39 39
40 ErrorSeverity _runAnalyzer(CommandLineOptions options) { 40 ErrorSeverity _runAnalyzer(CommandLineOptions options) {
41 if (!options.machineFormat) { 41 if (!options.machineFormat) {
42 stdout.writeln("Analyzing ${options.sourceFiles}..."); 42 stdout.writeln("Analyzing ${options.sourceFiles}...");
43 } 43 }
44 ErrorSeverity allResult = ErrorSeverity.NONE; 44 ErrorSeverity allResult = ErrorSeverity.NONE;
45 for (String sourcePath in options.sourceFiles) { 45 String sourcePath = options.sourceFiles[0];
46 sourcePath = sourcePath.trim(); 46 sourcePath = sourcePath.trim();
47 // check that file exists 47 // check that file exists
48 if (!new File(sourcePath).existsSync()) { 48 if (!new File(sourcePath).existsSync()) {
49 print('File not found: $sourcePath'); 49 print('File not found: $sourcePath');
50 return ErrorSeverity.ERROR; 50 return ErrorSeverity.ERROR;
51 }
52 // check that file is Dart file
53 if (!AnalysisEngine.isDartFileName(sourcePath)) {
54 print('$sourcePath is not a Dart file');
55 return ErrorSeverity.ERROR;
56 }
57 // do analyze
58 ErrorFormatter formatter = new ErrorFormatter(options.machineFormat ? stderr : stdout, options);
59 AnalyzerImpl analyzer = new AnalyzerImpl(options);
60 analyzer.analyze(sourcePath);
61 // pring errors
62 formatter.formatErrors(analyzer.errorInfos);
63 // prepare status
64 ErrorSeverity status = analyzer.maxErrorSeverity;
65 if (status == ErrorSeverity.WARNING && options.warningsAreFatal) {
66 status = ErrorSeverity.ERROR;
67 }
68 allResult = allResult.max(status);
69 } 51 }
70 return allResult; 52 // check that file is Dart file
53 if (!AnalysisEngine.isDartFileName(sourcePath)) {
54 print('$sourcePath is not a Dart file');
55 return ErrorSeverity.ERROR;
56 }
57 // do analyze
58 ErrorFormatter formatter = new ErrorFormatter(options.machineFormat ? stderr : stdout, options);
59 AnalyzerImpl analyzer = new AnalyzerImpl(options);
60 analyzer.analyze(sourcePath);
61 // pring errors
Brian Wilkerson 2013/06/06 16:53:18 "pring" --> "print"
62 formatter.formatErrors(analyzer.errorInfos);
Brian Wilkerson 2013/06/06 16:53:18 It might already be getting done, but somewhere we
63 // prepare status
64 ErrorSeverity status = analyzer.maxErrorSeverity;
65 if (status == ErrorSeverity.WARNING && options.warningsAreFatal) {
66 status = ErrorSeverity.ERROR;
67 }
68 return status;
71 } 69 }
72 70
73 typedef ErrorSeverity BatchRunnerHandler(List<String> args); 71 typedef ErrorSeverity BatchRunnerHandler(List<String> args);
74 72
75 /// Provides a framework to read command line options from stdin and feed them t o a callback. 73 /// Provides a framework to read command line options from stdin and feed them t o a callback.
76 class BatchRunner { 74 class BatchRunner {
77 /** 75 /**
78 * Run the tool in 'batch' mode, receiving command lines through stdin and ret urning pass/fail 76 * Run the tool in 'batch' mode, receiving command lines through stdin and ret urning pass/fail
79 * status through stdout. This feature is intended for use in unit testing. 77 * status through stdout. This feature is intended for use in unit testing.
80 */ 78 */
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 stdout.writeln('>>> TEST $resultPassString ${stopwatch.elapsedMillisecon ds}ms'); 120 stdout.writeln('>>> TEST $resultPassString ${stopwatch.elapsedMillisecon ds}ms');
123 } catch (e, stackTrace) { 121 } catch (e, stackTrace) {
124 stderr.writeln(e); 122 stderr.writeln(e);
125 stderr.writeln(stackTrace); 123 stderr.writeln(stackTrace);
126 stderr.writeln('>>> EOF STDERR'); 124 stderr.writeln('>>> EOF STDERR');
127 stdout.writeln('>>> TEST CRASH'); 125 stdout.writeln('>>> TEST CRASH');
128 } 126 }
129 }); 127 });
130 } 128 }
131 } 129 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698