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

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

Issue 1851433002: Better record compile-time errors on elements (Closed) Base URL: https://github.com/dart-lang/sdk.git@_temporary_fletch_patches
Patch Set: Address comment 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
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_backend/backend.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 dart2js.compiler_base; 5 library dart2js.compiler_base;
6 6
7 import 'dart:async' show 7 import 'dart:async' show
8 EventSink, 8 EventSink,
9 Future; 9 Future;
10 10
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 347
348 /// The [int.fromEnvironment] constructor. 348 /// The [int.fromEnvironment] constructor.
349 ConstructorElement intEnvironment; 349 ConstructorElement intEnvironment;
350 350
351 /// The [bool.fromEnvironment] constructor. 351 /// The [bool.fromEnvironment] constructor.
352 ConstructorElement boolEnvironment; 352 ConstructorElement boolEnvironment;
353 353
354 /// The [String.fromEnvironment] constructor. 354 /// The [String.fromEnvironment] constructor.
355 ConstructorElement stringEnvironment; 355 ConstructorElement stringEnvironment;
356 356
357 // TODO(zarah): Remove this map and incorporate compile-time errors
358 // in the model.
357 /// Tracks elements with compile-time errors. 359 /// Tracks elements with compile-time errors.
358 final Map<Element, DiagnosticMessage> elementsWithCompileTimeErrors = 360 final Map<Element, List<DiagnosticMessage>> elementsWithCompileTimeErrors =
359 new Map<Element, DiagnosticMessage>(); 361 new Map<Element, List<DiagnosticMessage>>();
360 362
361 fromEnvironment(String name) => null; 363 fromEnvironment(String name) => null;
362 364
363 Element get currentElement => _reporter.currentElement; 365 Element get currentElement => _reporter.currentElement;
364 366
365 List<CompilerTask> tasks; 367 List<CompilerTask> tasks;
366 ScannerTask scanner; 368 ScannerTask scanner;
367 DietParserTask dietParser; 369 DietParserTask dietParser;
368 ParserTask parser; 370 ParserTask parser;
369 PatchParserTask patchParser; 371 PatchParserTask patchParser;
(...skipping 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after
1448 1450
1449 /// Returns [true] if a compile-time error has been reported for element. 1451 /// Returns [true] if a compile-time error has been reported for element.
1450 bool elementHasCompileTimeError(Element element) { 1452 bool elementHasCompileTimeError(Element element) {
1451 return elementsWithCompileTimeErrors.containsKey(element); 1453 return elementsWithCompileTimeErrors.containsKey(element);
1452 } 1454 }
1453 1455
1454 /// Associate [element] with a compile-time error [message]. 1456 /// Associate [element] with a compile-time error [message].
1455 void registerCompiletimeError(Element element, DiagnosticMessage message) { 1457 void registerCompiletimeError(Element element, DiagnosticMessage message) {
1456 // The information is only needed if [generateCodeWithCompileTimeErrors]. 1458 // The information is only needed if [generateCodeWithCompileTimeErrors].
1457 if (generateCodeWithCompileTimeErrors) { 1459 if (generateCodeWithCompileTimeErrors) {
1458 elementsWithCompileTimeErrors[element] = message; 1460 if (element == null) {
1461 // Record as global error.
1462 // TODO(zarah): Extend element model to represent compile-time
1463 // errors instead of using a map.
1464 element = mainFunction;
1465 }
1466 elementsWithCompileTimeErrors.
1467 putIfAbsent(element, () => <DiagnosticMessage>[]).add(message);
1459 } 1468 }
1460 } 1469 }
1461 1470
1462 EventSink<String> outputProvider(String name, String extension) { 1471 EventSink<String> outputProvider(String name, String extension) {
1463 if (compilationFailed) { 1472 if (compilationFailed) {
1464 if (!generateCodeWithCompileTimeErrors || testMode) { 1473 if (!generateCodeWithCompileTimeErrors || testMode) {
1465 // Disable output in test mode: The build bot currently uses the time 1474 // Disable output in test mode: The build bot currently uses the time
1466 // stamp of the generated file to determine whether the output is 1475 // stamp of the generated file to determine whether the output is
1467 // up-to-date. 1476 // up-to-date.
1468 return new NullSink('$name.$extension'); 1477 return new NullSink('$name.$extension');
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
1718 reportDiagnostic(message, infos, kind); 1727 reportDiagnostic(message, infos, kind);
1719 } 1728 }
1720 1729
1721 void reportDiagnostic(DiagnosticMessage message, 1730 void reportDiagnostic(DiagnosticMessage message,
1722 List<DiagnosticMessage> infos, 1731 List<DiagnosticMessage> infos,
1723 api.Diagnostic kind) { 1732 api.Diagnostic kind) {
1724 if (kind == api.Diagnostic.ERROR || 1733 if (kind == api.Diagnostic.ERROR ||
1725 kind == api.Diagnostic.CRASH || 1734 kind == api.Diagnostic.CRASH ||
1726 (options.fatalWarnings && 1735 (options.fatalWarnings &&
1727 kind == api.Diagnostic.WARNING)) { 1736 kind == api.Diagnostic.WARNING)) {
1728 compiler.registerCompiletimeError(currentElement, message); 1737 if (message.spannable is Element) {
1738 errorElement = message.spannable;
1739 } else {
1740 errorElement = currentElement;
1741 }
1742 compiler.registerCompiletimeError(errorElement, message);
1729 compiler.compilationFailed = true; 1743 compiler.compilationFailed = true;
1730 } 1744 }
1731 compiler.reportDiagnostic(message, infos, kind); 1745 compiler.reportDiagnostic(message, infos, kind);
1732 } 1746 }
1733 1747
1734 /** 1748 /**
1735 * Perform an operation, [f], returning the return value from [f]. If an 1749 * Perform an operation, [f], returning the return value from [f]. If an
1736 * error occurs then report it as having occurred during compilation of 1750 * error occurs then report it as having occurred during compilation of
1737 * [element]. Can be nested. 1751 * [element]. Can be nested.
1738 */ 1752 */
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
2110 if (_otherDependencies == null) { 2124 if (_otherDependencies == null) {
2111 _otherDependencies = new Setlet<Element>(); 2125 _otherDependencies = new Setlet<Element>();
2112 } 2126 }
2113 _otherDependencies.add(element.implementation); 2127 _otherDependencies.add(element.implementation);
2114 } 2128 }
2115 2129
2116 Iterable<Element> get otherDependencies { 2130 Iterable<Element> get otherDependencies {
2117 return _otherDependencies != null ? _otherDependencies : const <Element>[]; 2131 return _otherDependencies != null ? _otherDependencies : const <Element>[];
2118 } 2132 }
2119 } 2133 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_backend/backend.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698