File tree Expand file tree Collapse file tree 3 files changed +20
-5
lines changed Expand file tree Collapse file tree 3 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -897,6 +897,16 @@ abstract class ElementAnnotation implements ConstantEvaluationTarget {
897897 /// other element.
898898 Element ? get element;
899899
900+ /// Returns the element referenced by this annotation.
901+ ///
902+ /// In valid code this element can be a [GetterElement] of a constant
903+ /// top-level variable, or a constant static field of a class; or a
904+ /// constant [ConstructorElement] .
905+ ///
906+ /// In invalid code this element can be `null` , or a reference to any
907+ /// other element.
908+ Element2 ? get element2;
909+
900910 /// Whether the annotation marks the associated function as always throwing.
901911 bool get isAlwaysThrows;
902912
Original file line number Diff line number Diff line change @@ -2078,6 +2078,11 @@ class ElementAnnotationImpl implements ElementAnnotation {
20782078 @override
20792079 AnalysisContext get context => compilationUnit.library.context;
20802080
2081+ @override
2082+ Element2 ? get element2 {
2083+ return element? .asElement2;
2084+ }
2085+
20812086 @override
20822087 bool get isAlwaysThrows => _isPackageMetaGetter (_alwaysThrowsVariableName);
20832088
Original file line number Diff line number Diff line change 44
55import 'package:analyzer/dart/ast/ast.dart' ;
66import 'package:analyzer/dart/ast/visitor.dart' ;
7- import 'package:analyzer/dart/element/element .dart' ;
7+ import 'package:analyzer/dart/element/element2 .dart' ;
88// ignore: implementation_imports
99import 'package:analyzer/src/dart/element/extensions.dart' ;
1010import 'package:meta/meta_meta.dart' ;
@@ -89,9 +89,9 @@ extension on ElementAnnotation {
8989 required String libraryName,
9090 required String className,
9191 }) {
92- var element = this .element ;
93- return element is ConstructorElement &&
94- element.enclosingElement3 .name == className &&
95- element.library .name == libraryName;
92+ var element = element2 ;
93+ return element is ConstructorElement2 &&
94+ element.enclosingElement2 .name == className &&
95+ element.library2 ? .name == libraryName;
9696 }
9797}
You can’t perform that action at this time.
0 commit comments