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

Side by Side Diff: lib/devc.dart

Issue 1183733004: fixes #25, most analyzer errors were not computed (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 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
« no previous file with comments | « no previous file | lib/src/info.dart » ('j') | 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 /// Command line tool to run the checker on a Dart program. 5 /// Command line tool to run the checker on a Dart program.
6 library dev_compiler.devc; 6 library dev_compiler.devc;
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:convert'; 9 import 'dart:convert';
10 import 'dart:io'; 10 import 'dart:io';
11 11
12 import 'package:analyzer/src/generated/error.dart' as analyzer; 12 import 'package:analyzer/src/generated/error.dart'
13 show AnalysisError, ErrorSeverity, ErrorType;
13 import 'package:analyzer/src/generated/engine.dart' 14 import 'package:analyzer/src/generated/engine.dart'
14 show AnalysisContext, ChangeSet; 15 show AnalysisContext, ChangeSet;
15 import 'package:analyzer/src/generated/source.dart' show Source; 16 import 'package:analyzer/src/generated/source.dart' show Source;
16 import 'package:logging/logging.dart' show Level, Logger, LogRecord; 17 import 'package:logging/logging.dart' show Level, Logger, LogRecord;
17 import 'package:path/path.dart' as path; 18 import 'package:path/path.dart' as path;
18 import 'package:shelf/shelf.dart' as shelf; 19 import 'package:shelf/shelf.dart' as shelf;
19 import 'package:shelf/shelf_io.dart' as shelf; 20 import 'package:shelf/shelf_io.dart' as shelf;
20 import 'package:shelf_static/shelf_static.dart' as shelf_static; 21 import 'package:shelf_static/shelf_static.dart' as shelf_static;
21 22
22 import 'src/analysis_context.dart'; 23 import 'src/analysis_context.dart';
23 import 'src/checker/checker.dart'; 24 import 'src/checker/checker.dart';
24 import 'src/checker/rules.dart'; 25 import 'src/checker/rules.dart';
25 import 'src/codegen/code_generator.dart' show CodeGenerator; 26 import 'src/codegen/code_generator.dart' show CodeGenerator;
26 import 'src/codegen/html_codegen.dart'; 27 import 'src/codegen/html_codegen.dart';
27 import 'src/codegen/js_codegen.dart'; 28 import 'src/codegen/js_codegen.dart';
28 import 'src/dependency_graph.dart'; 29 import 'src/dependency_graph.dart';
29 import 'src/info.dart' 30 import 'src/info.dart'
30 show AnalyzerError, CheckerResults, LibraryInfo, LibraryUnit; 31 show AnalyzerMessage, CheckerResults, LibraryInfo, LibraryUnit;
31 import 'src/options.dart'; 32 import 'src/options.dart';
32 import 'src/report.dart'; 33 import 'src/report.dart';
33 import 'src/utils.dart'; 34 import 'src/utils.dart';
34 35
35 /// Sets up the type checker logger to print a span that highlights error 36 /// Sets up the type checker logger to print a span that highlights error
36 /// messages. 37 /// messages.
37 StreamSubscription setupLogger(Level level, printFn) { 38 StreamSubscription setupLogger(Level level, printFn) {
38 Logger.root.level = level; 39 Logger.root.level = level;
39 return Logger.root.onRecord.listen((LogRecord rec) { 40 return Logger.root.onRecord.listen((LogRecord rec) {
40 printFn('${rec.level.name.toLowerCase()}: ${rec.message}'); 41 printFn('${rec.level.name.toLowerCase()}: ${rec.message}');
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 for (var cg in _generators) { 195 for (var cg in _generators) {
195 var hash = cg.generateLibrary(libraryUnit, current); 196 var hash = cg.generateLibrary(libraryUnit, current);
196 if (_hashing) node.cachingHash = hash; 197 if (_hashing) node.cachingHash = hash;
197 } 198 }
198 _reporter.leaveLibrary(); 199 _reporter.leaveLibrary();
199 } 200 }
200 201
201 /// Log any errors encountered when resolving [source] and return whether any 202 /// Log any errors encountered when resolving [source] and return whether any
202 /// errors were found. 203 /// errors were found.
203 bool logErrors(Source source) { 204 bool logErrors(Source source) {
204 List<analyzer.AnalysisError> errors = context.getErrors(source).errors; 205 context.computeErrors(source);
206 List<AnalysisError> errors = context.getErrors(source).errors;
205 bool failure = false; 207 bool failure = false;
206 if (errors.isNotEmpty) { 208 if (errors.isNotEmpty) {
207 for (var error in errors) { 209 for (var error in errors) {
208 var message = new AnalyzerError.from(error); 210 // Always skip TODOs.
211 if (error.errorCode.type == ErrorType.TODO) continue;
212
213 // Skip hints for now. In the future these could be turned on via flags.
214 if (error.errorCode.errorSeverity.ordinal <
215 ErrorSeverity.WARNING.ordinal) {
216 continue;
217 }
218
219 var message = new AnalyzerMessage.from(error);
209 if (message.level == Level.SEVERE) failure = true; 220 if (message.level == Level.SEVERE) failure = true;
210 _reporter.log(message); 221 _reporter.log(message);
211 } 222 }
212 } 223 }
213 return failure; 224 return failure;
214 } 225 }
215 226
216 CheckerResults run() { 227 CheckerResults run() {
217 var clock = new Stopwatch()..start(); 228 var clock = new Stopwatch()..start();
218 229
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 // Note: the cache-control header should be enough, but this doesn't hurt 337 // Note: the cache-control header should be enough, but this doesn't hurt
327 // and can help renew the policy after it expires. 338 // and can help renew the policy after it expires.
328 headers['ETag'] = hash; 339 headers['ETag'] = hash;
329 } 340 }
330 return response.change(headers: headers); 341 return response.change(headers: headers);
331 }; 342 };
332 } 343 }
333 344
334 final _log = new Logger('dev_compiler'); 345 final _log = new Logger('dev_compiler');
335 final _earlyErrorResult = new CheckerResults(const [], null, true); 346 final _earlyErrorResult = new CheckerResults(const [], null, true);
OLDNEW
« no previous file with comments | « no previous file | lib/src/info.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698