| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 analyzer.src.generated.declaration_resolver; | 5 library analyzer.src.generated.declaration_resolver; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/ast/token.dart'; | 8 import 'package:analyzer/dart/ast/token.dart'; |
| 9 import 'package:analyzer/dart/ast/visitor.dart'; | 9 import 'package:analyzer/dart/ast/visitor.dart'; |
| 10 import 'package:analyzer/dart/element/element.dart'; | 10 import 'package:analyzer/dart/element/element.dart'; |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 /** | 487 /** |
| 488 * Updates [identifier] to point to [element], after ensuring that the | 488 * Updates [identifier] to point to [element], after ensuring that the |
| 489 * element has the expected name. | 489 * element has the expected name. |
| 490 * | 490 * |
| 491 * If no [elementName] is given, it defaults to the name of the [identifier] | 491 * If no [elementName] is given, it defaults to the name of the [identifier] |
| 492 * (or the empty string if [identifier] is `null`). | 492 * (or the empty string if [identifier] is `null`). |
| 493 * | 493 * |
| 494 * If [identifier] is `null`, nothing is updated, but the element name is | 494 * If [identifier] is `null`, nothing is updated, but the element name is |
| 495 * still checked. | 495 * still checked. |
| 496 */ | 496 */ |
| 497 Element/*=E*/ _match/*<E extends Element>*/( | 497 E _match<E extends Element>(SimpleIdentifier identifier, E element, |
| 498 SimpleIdentifier identifier, Element/*=E*/ element, | |
| 499 {String elementName, int offset}) { | 498 {String elementName, int offset}) { |
| 500 elementName ??= identifier?.name ?? ''; | 499 elementName ??= identifier?.name ?? ''; |
| 501 offset ??= identifier?.offset ?? -1; | 500 offset ??= identifier?.offset ?? -1; |
| 502 if (element.name != elementName) { | 501 if (element.name != elementName) { |
| 503 throw new StateError( | 502 throw new StateError( |
| 504 'Expected an element matching `$elementName`, got `${element.name}`'); | 503 'Expected an element matching `$elementName`, got `${element.name}`'); |
| 505 } | 504 } |
| 506 identifier?.staticElement = element; | 505 identifier?.staticElement = element; |
| 507 _matchOffset(element, offset); | 506 _matchOffset(element, offset); |
| 508 return element; | 507 return element; |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 815 class _ElementMismatchException extends AnalysisException { | 814 class _ElementMismatchException extends AnalysisException { |
| 816 /** | 815 /** |
| 817 * Creates an exception to refer to the given [compilationUnit], [element], | 816 * Creates an exception to refer to the given [compilationUnit], [element], |
| 818 * and [cause]. | 817 * and [cause]. |
| 819 */ | 818 */ |
| 820 _ElementMismatchException( | 819 _ElementMismatchException( |
| 821 CompilationUnitElement compilationUnit, Element element, | 820 CompilationUnitElement compilationUnit, Element element, |
| 822 [CaughtException cause = null]) | 821 [CaughtException cause = null]) |
| 823 : super('Element mismatch in $compilationUnit at $element', cause); | 822 : super('Element mismatch in $compilationUnit at $element', cause); |
| 824 } | 823 } |
| OLD | NEW |