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

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: 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 elementsWithCompileTimeErrors.
Johnni Winther 2016/03/31 09:59:34 Maybe just: if (element == null) { // .... el
zarah 2016/04/01 07:29:52 Done.
1465 putIfAbsent(mainFunction, () => <DiagnosticMessage>[]).add(message);
1466 } else {
1467 elementsWithCompileTimeErrors.
1468 putIfAbsent(element, () => <DiagnosticMessage>[]).add(message);
1469 }
1459 } 1470 }
1460 } 1471 }
1461 1472
1462 EventSink<String> outputProvider(String name, String extension) { 1473 EventSink<String> outputProvider(String name, String extension) {
1463 if (compilationFailed) { 1474 if (compilationFailed) {
1464 if (!generateCodeWithCompileTimeErrors || testMode) { 1475 if (!generateCodeWithCompileTimeErrors || testMode) {
1465 // Disable output in test mode: The build bot currently uses the time 1476 // Disable output in test mode: The build bot currently uses the time
1466 // stamp of the generated file to determine whether the output is 1477 // stamp of the generated file to determine whether the output is
1467 // up-to-date. 1478 // up-to-date.
1468 return new NullSink('$name.$extension'); 1479 return new NullSink('$name.$extension');
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
1718 reportDiagnostic(message, infos, kind); 1729 reportDiagnostic(message, infos, kind);
1719 } 1730 }
1720 1731
1721 void reportDiagnostic(DiagnosticMessage message, 1732 void reportDiagnostic(DiagnosticMessage message,
1722 List<DiagnosticMessage> infos, 1733 List<DiagnosticMessage> infos,
1723 api.Diagnostic kind) { 1734 api.Diagnostic kind) {
1724 if (kind == api.Diagnostic.ERROR || 1735 if (kind == api.Diagnostic.ERROR ||
1725 kind == api.Diagnostic.CRASH || 1736 kind == api.Diagnostic.CRASH ||
1726 (options.fatalWarnings && 1737 (options.fatalWarnings &&
1727 kind == api.Diagnostic.WARNING)) { 1738 kind == api.Diagnostic.WARNING)) {
1728 compiler.registerCompiletimeError(currentElement, message); 1739 if (message.spannable is Element) {
1740 errorElement = message.spannable;
1741 } else {
1742 errorElement = currentElement;
1743 }
1744 compiler.registerCompiletimeError(errorElement, message);
1729 compiler.compilationFailed = true; 1745 compiler.compilationFailed = true;
1730 } 1746 }
1731 compiler.reportDiagnostic(message, infos, kind); 1747 compiler.reportDiagnostic(message, infos, kind);
1732 } 1748 }
1733 1749
1734 /** 1750 /**
1735 * Perform an operation, [f], returning the return value from [f]. If an 1751 * Perform an operation, [f], returning the return value from [f]. If an
1736 * error occurs then report it as having occurred during compilation of 1752 * error occurs then report it as having occurred during compilation of
1737 * [element]. Can be nested. 1753 * [element]. Can be nested.
1738 */ 1754 */
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
2110 if (_otherDependencies == null) { 2126 if (_otherDependencies == null) {
2111 _otherDependencies = new Setlet<Element>(); 2127 _otherDependencies = new Setlet<Element>();
2112 } 2128 }
2113 _otherDependencies.add(element.implementation); 2129 _otherDependencies.add(element.implementation);
2114 } 2130 }
2115 2131
2116 Iterable<Element> get otherDependencies { 2132 Iterable<Element> get otherDependencies {
2117 return _otherDependencies != null ? _otherDependencies : const <Element>[]; 2133 return _otherDependencies != null ? _otherDependencies : const <Element>[];
2118 } 2134 }
2119 } 2135 }
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