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

Side by Side Diff: pkg/analyzer/lib/src/analyzer_impl.dart

Issue 200423006: Fix batch mode to now print out errors, this gets us closer to the FYI bot passing (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/analyzer/bin/analyzer.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer_impl; 5 library analyzer_impl;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'dart:io'; 9 import 'dart:io';
10 10
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 print("Only libraries can be analyzed."); 102 print("Only libraries can be analyzed.");
103 print("$sourcePath is a part and can not be analyzed."); 103 print("$sourcePath is a part and can not be analyzed.");
104 return ErrorSeverity.ERROR; 104 return ErrorSeverity.ERROR;
105 } 105 }
106 // resolve library 106 // resolve library
107 var libraryElement = context.computeLibraryElement(librarySource); 107 var libraryElement = context.computeLibraryElement(librarySource);
108 // prepare source and errors 108 // prepare source and errors
109 prepareSources(libraryElement); 109 prepareSources(libraryElement);
110 prepareErrors(); 110 prepareErrors();
111 111
112 // print errors and performance numbers
113 _printErrorsAndPerf();
114
112 // compute max severity and set exitCode 115 // compute max severity and set exitCode
113 ErrorSeverity status = maxErrorSeverity; 116 ErrorSeverity status = maxErrorSeverity;
114 if (status == ErrorSeverity.WARNING && options.warningsAreFatal) { 117 if (status == ErrorSeverity.WARNING && options.warningsAreFatal) {
115 status = ErrorSeverity.ERROR; 118 status = ErrorSeverity.ERROR;
116 } 119 }
117 return status; 120 return status;
118 } 121 }
119 122
120 /// The async version of the analysis 123 /// The async version of the analysis
121 void _analyzeAsync() { 124 void _analyzeAsync() {
122 new Future(context.performAnalysisTask).then((AnalysisResult result) { 125 new Future(context.performAnalysisTask).then((AnalysisResult result) {
123 List<ChangeNotice> notices = result.changeNotices; 126 List<ChangeNotice> notices = result.changeNotices;
124 if (result.hasMoreWork) { 127 if (result.hasMoreWork) {
125 // There is more work, record the set of sources, and then call self 128 // There is more work, record the set of sources, and then call self
126 // again to perform next task 129 // again to perform next task
127 for (ChangeNotice notice in notices) { 130 for (ChangeNotice notice in notices) {
128 sources.add(notice.source); 131 sources.add(notice.source);
129 } 132 }
130 return _analyzeAsync(); 133 return _analyzeAsync();
131 } 134 }
132 // 135 //
133 // There are not any more tasks, set error code and print performance 136 // There are not any more tasks, set error code and print performance
134 // numbers. 137 // numbers.
135 // 138 //
136 // prepare errors 139 // prepare errors
137 prepareErrors(); 140 prepareErrors();
138 141
142 // print errors and performance numbers
143 _printErrorsAndPerf();
144
139 // compute max severity and set exitCode 145 // compute max severity and set exitCode
140 ErrorSeverity status = maxErrorSeverity; 146 ErrorSeverity status = maxErrorSeverity;
141 if (status == ErrorSeverity.WARNING && options.warningsAreFatal) { 147 if (status == ErrorSeverity.WARNING && options.warningsAreFatal) {
142 status = ErrorSeverity.ERROR; 148 status = ErrorSeverity.ERROR;
143 } 149 }
144 exitCode = status.ordinal; 150 exitCode = status.ordinal;
145
146 // print errors
147 ErrorFormatter formatter = new ErrorFormatter(stdout, options);
148 formatter.formatErrors(errorInfos);
149
150 // print performance numbers
151 if (options.perf) {
152 int totalTime = JavaSystem.currentTimeMillis() - startTime;
153 int ioTime = PerformanceStatistics.io.result;
154 int scanTime = PerformanceStatistics.scan.result;
155 int parseTime = PerformanceStatistics.parse.result;
156 int resolveTime = PerformanceStatistics.resolve.result;
157 int errorsTime = PerformanceStatistics.errors.result;
158 int hintsTime = PerformanceStatistics.hints.result;
159 int angularTime = PerformanceStatistics.angular.result;
160 stdout.writeln("io:$ioTime");
161 stdout.writeln("scan:$scanTime");
162 stdout.writeln("parse:$parseTime");
163 stdout.writeln("resolve:$resolveTime");
164 stdout.writeln("errors:$errorsTime");
165 stdout.writeln("hints:$hintsTime");
166 stdout.writeln("angular:$angularTime");
167 stdout.writeln("other:${totalTime
168 - (ioTime + scanTime + parseTime + resolveTime + errorsTime + hints Time
169 + angularTime)}");
170 stdout.writeln("total:$totalTime");
171 }
172 }).catchError((ex, st) { 151 }).catchError((ex, st) {
173 AnalysisEngine.instance.logger.logError("${ex}\n${st}"); 152 AnalysisEngine.instance.logger.logError("${ex}\n${st}");
174 }); 153 });
175 } 154 }
176 155
156 _printErrorsAndPerf() {
157 // The following is a hack. We currently print out to stderr to ensure that
158 // when in batch mode we print to stderr, this is because the prints from
159 // batch are made to stderr. The reason that options.shouldBatch isn't used
160 // is because when the argument flags are constructed in BatchRunner and
161 // passed in from batch mode which removes the batch flag to prevent the
162 // "cannot have the batch flag and source file" error message.
163 IOSink sink = options.machineFormat ? stderr : stdout;
164
165 // print errors
166 ErrorFormatter formatter = new ErrorFormatter(sink, options);
167 formatter.formatErrors(errorInfos);
168
169 // print performance numbers
170 if (options.perf) {
171 int totalTime = JavaSystem.currentTimeMillis() - startTime;
172 int ioTime = PerformanceStatistics.io.result;
173 int scanTime = PerformanceStatistics.scan.result;
174 int parseTime = PerformanceStatistics.parse.result;
175 int resolveTime = PerformanceStatistics.resolve.result;
176 int errorsTime = PerformanceStatistics.errors.result;
177 int hintsTime = PerformanceStatistics.hints.result;
178 int angularTime = PerformanceStatistics.angular.result;
179 stdout.writeln("io:$ioTime");
180 stdout.writeln("scan:$scanTime");
181 stdout.writeln("parse:$parseTime");
182 stdout.writeln("resolve:$resolveTime");
183 stdout.writeln("errors:$errorsTime");
184 stdout.writeln("hints:$hintsTime");
185 stdout.writeln("angular:$angularTime");
186 stdout.writeln("other:${totalTime
187 - (ioTime + scanTime + parseTime + resolveTime + errorsTime + hintsTim e
188 + angularTime)}");
189 stdout.writeln("total:$totalTime");
190 }
191 }
192
177 /// Returns the maximal [ErrorSeverity] of the recorded errors. 193 /// Returns the maximal [ErrorSeverity] of the recorded errors.
178 ErrorSeverity get maxErrorSeverity { 194 ErrorSeverity get maxErrorSeverity {
179 var status = ErrorSeverity.NONE; 195 var status = ErrorSeverity.NONE;
180 for (AnalysisErrorInfo errorInfo in errorInfos) { 196 for (AnalysisErrorInfo errorInfo in errorInfos) {
181 for (AnalysisError error in errorInfo.errors) { 197 for (AnalysisError error in errorInfo.errors) {
182 var severity = error.errorCode.errorSeverity; 198 var severity = error.errorCode.errorSeverity;
183 status = status.max(severity); 199 status = status.max(severity);
184 } 200 }
185 } 201 }
186 return status; 202 return status;
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 } 356 }
341 } 357 }
342 358
343 @override 359 @override
344 void logInformation2(String message, Exception exception) { 360 void logInformation2(String message, Exception exception) {
345 if (log) { 361 if (log) {
346 stdout.writeln(message); 362 stdout.writeln(message);
347 } 363 }
348 } 364 }
349 } 365 }
OLDNEW
« no previous file with comments | « pkg/analyzer/bin/analyzer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698