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

Side by Side Diff: pkg/analyzer/lib/src/generated/error.dart

Issue 1372673003: Use Element.nameLength where possible. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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) 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 2551 matching lines...) Expand 10 before | Expand all | Expand 10 after
2562 * Report the given [error]. 2562 * Report the given [error].
2563 */ 2563 */
2564 void reportError(AnalysisError error) { 2564 void reportError(AnalysisError error) {
2565 _errorListener.onError(error); 2565 _errorListener.onError(error);
2566 } 2566 }
2567 2567
2568 /** 2568 /**
2569 * Report an error with the given [errorCode] and [arguments]. The [element] 2569 * Report an error with the given [errorCode] and [arguments]. The [element]
2570 * is used to compute the location of the error. 2570 * is used to compute the location of the error.
2571 */ 2571 */
2572 void reportErrorForElement( 2572 void reportErrorForElement(ErrorCode errorCode, Element element,
2573 ErrorCode errorCode, Element element, List<Object> arguments) { 2573 [List<Object> arguments]) {
2574 String displayName = element.displayName;
2575 int length = 0; 2574 int length = 0;
2576 if (displayName != null) { 2575 if (element is ImportElement) {
2577 length = displayName.length;
2578 } else if (element is ImportElement) {
2579 length = 6; // 'import'.length 2576 length = 6; // 'import'.length
2580 } else if (element is ExportElement) { 2577 } else if (element is ExportElement) {
2581 length = 6; // 'export'.length 2578 length = 6; // 'export'.length
2579 } else {
2580 length = element.nameLength;
2582 } 2581 }
2583 reportErrorForOffset(errorCode, element.nameOffset, length, arguments); 2582 reportErrorForOffset(errorCode, element.nameOffset, length, arguments);
2584 } 2583 }
2585 2584
2586 /** 2585 /**
2587 * Report an error with the given [errorCode] and [arguments]. 2586 * Report an error with the given [errorCode] and [arguments].
2588 * The [node] is used to compute the location of the error. 2587 * The [node] is used to compute the location of the error.
2589 * 2588 *
2590 * If the arguments contain the names of two or more types, the method 2589 * If the arguments contain the names of two or more types, the method
2591 * [reportTypeErrorForNode] should be used and the types 2590 * [reportTypeErrorForNode] should be used and the types
(...skipping 2407 matching lines...) Expand 10 before | Expand all | Expand 10 after
4999 * Initialize a newly created error code to have the given [name]. 4998 * Initialize a newly created error code to have the given [name].
5000 */ 4999 */
5001 const TodoCode(String name) : super(name, "{0}"); 5000 const TodoCode(String name) : super(name, "{0}");
5002 5001
5003 @override 5002 @override
5004 ErrorSeverity get errorSeverity => ErrorSeverity.INFO; 5003 ErrorSeverity get errorSeverity => ErrorSeverity.INFO;
5005 5004
5006 @override 5005 @override
5007 ErrorType get type => ErrorType.TODO; 5006 ErrorType get type => ErrorType.TODO;
5008 } 5007 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/element.dart ('k') | pkg/analyzer/lib/src/generated/error_verifier.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698