| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 engine.error; | 5 library engine.error; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'ast.dart' show AstNode; | 9 import 'ast.dart' show AstNode; |
| 10 import 'element.dart'; | 10 import 'element.dart'; |
| (...skipping 2456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2467 void reportError(AnalysisError error) { | 2467 void reportError(AnalysisError error) { |
| 2468 _errorListener.onError(error); | 2468 _errorListener.onError(error); |
| 2469 } | 2469 } |
| 2470 | 2470 |
| 2471 /** | 2471 /** |
| 2472 * Report an error with the given [errorCode] and [arguments]. The [element] | 2472 * Report an error with the given [errorCode] and [arguments]. The [element] |
| 2473 * is used to compute the location of the error. | 2473 * is used to compute the location of the error. |
| 2474 */ | 2474 */ |
| 2475 void reportErrorForElement( | 2475 void reportErrorForElement( |
| 2476 ErrorCode errorCode, Element element, List<Object> arguments) { | 2476 ErrorCode errorCode, Element element, List<Object> arguments) { |
| 2477 reportErrorForOffset( | 2477 String displayName = element.displayName; |
| 2478 errorCode, element.nameOffset, element.displayName.length, arguments); | 2478 int length = 0; |
| 2479 if (displayName != null) { |
| 2480 length = displayName.length; |
| 2481 } else if (element is ImportElement) { |
| 2482 length = 6; // 'import'.length |
| 2483 } else if (element is ExportElement) { |
| 2484 length = 6; // 'export'.length |
| 2485 } |
| 2486 reportErrorForOffset(errorCode, element.nameOffset, length, arguments); |
| 2479 } | 2487 } |
| 2480 | 2488 |
| 2481 /** | 2489 /** |
| 2482 * Report an error with the given [errorCode] and [arguments]. | 2490 * Report an error with the given [errorCode] and [arguments]. |
| 2483 * The [node] is used to compute the location of the error. | 2491 * The [node] is used to compute the location of the error. |
| 2484 * | 2492 * |
| 2485 * If the arguments contain the names of two or more types, the method | 2493 * If the arguments contain the names of two or more types, the method |
| 2486 * [reportTypeErrorForNode] should be used and the types | 2494 * [reportTypeErrorForNode] should be used and the types |
| 2487 * themselves (rather than their names) should be passed as arguments. | 2495 * themselves (rather than their names) should be passed as arguments. |
| 2488 */ | 2496 */ |
| (...skipping 2385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4874 * Initialize a newly created error code to have the given [name]. | 4882 * Initialize a newly created error code to have the given [name]. |
| 4875 */ | 4883 */ |
| 4876 const TodoCode(String name) : super(name, "{0}"); | 4884 const TodoCode(String name) : super(name, "{0}"); |
| 4877 | 4885 |
| 4878 @override | 4886 @override |
| 4879 ErrorSeverity get errorSeverity => ErrorSeverity.INFO; | 4887 ErrorSeverity get errorSeverity => ErrorSeverity.INFO; |
| 4880 | 4888 |
| 4881 @override | 4889 @override |
| 4882 ErrorType get type => ErrorType.TODO; | 4890 ErrorType get type => ErrorType.TODO; |
| 4883 } | 4891 } |
| OLD | NEW |