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

Side by Side Diff: lib/src/compiler.dart

Issue 1840203002: More analyzer updates, and handle negative_tests (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 8 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
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 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 import 'dart:math' as math; 9 import 'dart:math' as math;
10 import 'dart:io'; 10 import 'dart:io';
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 bool get failure => _failure; 79 bool get failure => _failure;
80 80
81 final _pendingLibraries = <List<CompilationUnit>>[]; 81 final _pendingLibraries = <List<CompilationUnit>>[];
82 82
83 BatchCompiler(AnalysisContext context, CompilerOptions options, 83 BatchCompiler(AnalysisContext context, CompilerOptions options,
84 {AnalysisErrorListener reporter, 84 {AnalysisErrorListener reporter,
85 FileSystem fileSystem: const FileSystem()}) 85 FileSystem fileSystem: const FileSystem()})
86 : super( 86 : super(
87 context, 87 context,
88 options, 88 options,
89 new ErrorCollector(reporter ?? AnalysisErrorListener.NULL_LISTENER), 89 new ErrorCollector(
90 context, reporter ?? AnalysisErrorListener.NULL_LISTENER),
90 fileSystem) { 91 fileSystem) {
91 _inputBaseDir = options.inputBaseDir; 92 _inputBaseDir = options.inputBaseDir;
92 if (outputDir != null) { 93 if (outputDir != null) {
93 _jsGen = new JSGenerator(this); 94 _jsGen = new JSGenerator(this);
94 _runtimeOutputDir = path.join(outputDir, 'dev_compiler', 'runtime'); 95 _runtimeOutputDir = path.join(outputDir, 'dev_compiler', 'runtime');
95 } 96 }
96 _dartCore = context.typeProvider.objectType.element.library; 97 _dartCore = context.typeProvider.objectType.element.library;
97 } 98 }
98 99
99 ErrorCollector get reporter => super.reporter; 100 ErrorCollector get reporter => super.reporter;
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 bool computeErrors(Source source) { 435 bool computeErrors(Source source) {
435 AnalysisContext errorContext = context; 436 AnalysisContext errorContext = context;
436 // TODO(jmesserly): should this be a fix somewhere in analyzer? 437 // TODO(jmesserly): should this be a fix somewhere in analyzer?
437 // otherwise we fail to find the parts. 438 // otherwise we fail to find the parts.
438 if (source.isInSystemLibrary) { 439 if (source.isInSystemLibrary) {
439 errorContext = context.sourceFactory.dartSdk.context; 440 errorContext = context.sourceFactory.dartSdk.context;
440 } 441 }
441 List<AnalysisError> errors = errorContext.computeErrors(source); 442 List<AnalysisError> errors = errorContext.computeErrors(source);
442 bool failure = false; 443 bool failure = false;
443 for (var error in errors) { 444 for (var error in errors) {
444 ErrorCode code = error.errorCode; 445 // TODO(jmesserly): this is a very expensive lookup, and it has to be
445 // Always skip TODOs. 446 // repeated every time we want to query error severity.
446 if (code.type == ErrorType.TODO) continue; 447 var severity = errorSeverity(errorContext, error);
447 448 if (severity == ErrorSeverity.ERROR) {
448 // TODO(jmesserly): for now, treat DDC errors as having a different
449 // error level from Analayzer ones.
450 if (isStrongModeError(code)) {
451 reporter.onError(error); 449 reporter.onError(error);
452 if (code.errorSeverity == ErrorSeverity.ERROR) {
453 failure = true;
454 }
455 } else if (code.errorSeverity.ordinal >= ErrorSeverity.WARNING.ordinal) {
456 // All analyzer warnings or errors are errors for DDC.
457 failure = true; 450 failure = true;
451 } else if (severity == ErrorSeverity.WARNING) {
458 reporter.onError(error); 452 reporter.onError(error);
459 } else {
460 // Skip hints for now.
461 } 453 }
462 } 454 }
463 return failure; 455 return failure;
464 } 456 }
465 } 457 }
466 458
467 // TODO(jmesserly): find a better home for these. 459 // TODO(jmesserly): find a better home for these.
468 /// Curated order to minimize lazy classes needed by dart:core and its 460 /// Curated order to minimize lazy classes needed by dart:core and its
469 /// transitive SDK imports. 461 /// transitive SDK imports.
470 final corelibOrder = [ 462 final corelibOrder = [
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 var files = [ 503 var files = [
512 'harmony_feature_check.js', 504 'harmony_feature_check.js',
513 'dart_library.js', 505 'dart_library.js',
514 'dart/_runtime.js', 506 'dart/_runtime.js',
515 ]; 507 ];
516 files.addAll(corelibOrder.map(coreToFile)); 508 files.addAll(corelibOrder.map(coreToFile));
517 return files; 509 return files;
518 }(); 510 }();
519 511
520 final _log = new Logger('dev_compiler.src.compiler'); 512 final _log = new Logger('dev_compiler.src.compiler');
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698