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

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

Issue 2008353002: Add ElementImpl.typeParameterContext getter. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: tweaks Created 4 years, 7 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 | « no previous file | pkg/analyzer/lib/src/summary/resynthesize.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 d46c864189b0b3cf1b6516337cd738da05af5e83..a3ce3817649b819b599a49bc6ad71f4346066268 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -474,6 +474,9 @@ class ClassElementImpl extends ElementImpl
}
@override
+ TypeParameterizedElementMixin get typeParameterContext => this;
+
+ @override
List<TypeParameterElement> get typeParameters {
if (_unlinkedClass != null) {
return super.typeParameters;
@@ -1268,6 +1271,7 @@ class CompilationUnitElementImpl extends UriReferencedElementImpl
@override
String get identifier => source.encoding;
+
@override
ElementKind get kind => ElementKind.COMPILATION_UNIT;
@@ -1333,6 +1337,9 @@ class CompilationUnitElementImpl extends UriReferencedElementImpl
}
@override
+ TypeParameterizedElementMixin get typeParameterContext => null;
+
+ @override
List<ClassElement> get types => _types;
/**
@@ -2345,6 +2352,15 @@ abstract class ElementImpl implements Element {
setModifier(Modifier.SYNTHETIC, isSynthetic);
}
+ /**
+ * Return the context to resolve type parameters in, or `null` if neither this
+ * element nor any of its ancestors is of a kind that can declare type
+ * parameters.
+ */
+ TypeParameterizedElementMixin get typeParameterContext {
+ return _enclosingElement?.typeParameterContext;
+ }
+
@override
CompilationUnit get unit => context.resolveCompilationUnit(source, library);
@@ -2987,6 +3003,9 @@ abstract class ExecutableElementImpl extends ElementImpl
}
@override
+ TypeParameterizedElementMixin get typeParameterContext => this;
+
+ @override
List<TypeParameterElement> get typeParameters => _typeParameters;
/**
@@ -3392,11 +3411,7 @@ class FunctionElementImpl extends ExecutableElementImpl
@override
TypeParameterizedElementMixin get enclosingTypeParameterContext {
- Element enclosingElement = this.enclosingElement;
- if (enclosingElement is TypeParameterizedElementMixin) {
- return enclosingElement;
- }
- return null;
+ return (enclosingElement as ElementImpl).typeParameterContext;
}
@override
@@ -3622,6 +3637,9 @@ class FunctionTypeAliasElementImpl extends ElementImpl
}
@override
+ TypeParameterizedElementMixin get typeParameterContext => this;
+
+ @override
List<TypeParameterElement> get typeParameters {
if (_unlinkedTypedef != null) {
return super.typeParameters;
@@ -6076,11 +6094,7 @@ class PropertyAccessorElementImpl extends ExecutableElementImpl
@override
TypeParameterizedElementMixin get enclosingTypeParameterContext {
- Element enclosingElement = this.enclosingElement;
- if (enclosingElement is TypeParameterizedElementMixin) {
- return enclosingElement;
- }
- return null;
+ return (enclosingElement as ElementImpl).typeParameterContext;
}
/**
@@ -6239,12 +6253,12 @@ abstract class ResynthesizerContext {
/**
* Build [ElementAnnotationImpl] for the given [UnlinkedConst].
*/
- ElementAnnotationImpl buildAnnotation(Element context, UnlinkedConst uc);
+ ElementAnnotationImpl buildAnnotation(ElementImpl context, UnlinkedConst uc);
/**
* Build [Expression] for the given [UnlinkedConst].
*/
- Expression buildExpression(Element context, UnlinkedConst uc);
+ Expression buildExpression(ElementImpl context, UnlinkedConst uc);
/**
* Build explicit top-level property accessors.
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/summary/resynthesize.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698