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

Unified Diff: pkg/analyzer/lib/src/dart/element/element.dart

Issue 1768713002: Fixes to associating existing elements with an AST (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Address comments Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/dart/element/builder.dart ('k') | pkg/analyzer/lib/src/generated/resolver.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/dart/element/element.dart
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index e3f4dfeeab2c9f4feb4b3fb7b5647c04d8e0d28a..584f797d755272a2b1e32f74654d3cb8030a1b83 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -928,6 +928,13 @@ class CompilationUnitElementImpl extends UriReferencedElementImpl
Source librarySource;
/**
+ * A table mapping the offset of a directive to the annotations associated
+ * with that directive, or `null` if none of the annotations in the
+ * compilation unit have annotations.
+ */
+ Map<int, List<ElementAnnotation>> annotationMap = null;
+
+ /**
* A list containing all of the top-level accessors (getters and setters)
* contained in this compilation unit.
*/
@@ -1103,6 +1110,18 @@ class CompilationUnitElementImpl extends UriReferencedElementImpl
@override
CompilationUnit computeNode() => unit;
+ /**
+ * Return the annotations associated with the directive at the given [offset],
+ * or an empty list if the directive has no annotations or if there is no
+ * directive at the given offset.
+ */
+ List<ElementAnnotation> getAnnotations(int offset) {
+ if (annotationMap == null) {
+ return ElementAnnotation.EMPTY_LIST;
+ }
+ return annotationMap[offset] ?? ElementAnnotation.EMPTY_LIST;
+ }
+
@override
ElementImpl getChild(String identifier) {
//
@@ -1181,6 +1200,15 @@ class CompilationUnitElementImpl extends UriReferencedElementImpl
_variables[index] = to;
}
+ /**
+ * Set the annotations associated with the directive at the given [offset] to
+ * the given list of [annotations].
+ */
+ void setAnnotations(int offset, List<ElementAnnotation> annotations) {
+ annotationMap ??= new HashMap<int, List<ElementAnnotation>>();
+ annotationMap[offset] = annotations;
+ }
+
@override
void visitChildren(ElementVisitor visitor) {
super.visitChildren(visitor);
« no previous file with comments | « pkg/analyzer/lib/src/dart/element/builder.dart ('k') | pkg/analyzer/lib/src/generated/resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698