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

Unified Diff: pkg/analyzer2dart/lib/src/identifier_semantics.dart

Issue 710163002: Add support for type references to AccessSemantics. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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/analyzer2dart/lib/src/semantic_visitor.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer2dart/lib/src/identifier_semantics.dart
diff --git a/pkg/analyzer2dart/lib/src/identifier_semantics.dart b/pkg/analyzer2dart/lib/src/identifier_semantics.dart
index 026e00aef7a9dab3d5ec4b424bb560ebe473c256..70747cf7852d851eae3f38d32812c2606ad32097 100644
--- a/pkg/analyzer2dart/lib/src/identifier_semantics.dart
+++ b/pkg/analyzer2dart/lib/src/identifier_semantics.dart
@@ -58,6 +58,18 @@ class AccessKind {
static const AccessKind STATIC_PROPERTY =
const AccessKind._('STATIC_PROPERTY');
+ /**
+ * The destination of the access is a toplevel class.
+ */
+ static const AccessKind TOPLEVEL_CLASS =
+ const AccessKind._('TOPLEVEL_CLASS');
+
+ /**
+ * The destination of the access is a type parameter of the enclosing class.
+ */
+ static const AccessKind TYPE_PARAMETER =
+ const AccessKind._('TYPE_PARAMETER');
+
final String name;
String toString() => name;
@@ -91,8 +103,9 @@ class AccessSemantics {
/**
* The class containing the element being accessed, if this is a static
* reference to an element in a class. This will be null if [kind] is
- * DYNAMIC, LOCAL_FUNCTION, LOCAL_VARIABLE, or PARAMETER, or if the element
- * being accessed is defined at toplevel within a library.
+ * DYNAMIC, LOCAL_FUNCTION, LOCAL_VARIABLE, PARAMETER, TOPLEVEL_CLASS, or
+ * TYPE_PARAMETER, or if the element being accessed is defined at toplevel
+ * within a library.
*
* Note: it is possible for [classElement] to be non-null and for [element]
* to be null; for example this occurs if the element being accessed is a
@@ -154,6 +167,18 @@ class AccessSemantics {
: kind = AccessKind.STATIC_PROPERTY,
target = null;
+ AccessSemantics.toplevelClass(this.identifier, this.element)
+ : kind = AccessKind.TOPLEVEL_CLASS,
+ classElement = null,
+ isInvoke = false,
+ target = null;
+
+ AccessSemantics.typeParameter(this.identifier, this.element)
+ : kind = AccessKind.TYPE_PARAMETER,
+ classElement = null,
+ isInvoke = false,
+ target = null;
+
/**
* True if this is a read access to a property, or a method tear-off. Note
* that both [isRead] and [isWrite] will be true in the case of a
@@ -354,6 +379,8 @@ class AccessSemanticsVisitor extends RecursiveAstVisitor<AccessSemantics> {
}
} else if (rhsElement is FunctionElement) {
return new AccessSemantics.staticMethod(rhs, rhsElement, null);
+ } else if (rhsElement is ClassElement) {
+ return new AccessSemantics.toplevelClass(rhs, rhsElement);
} else {
return new AccessSemantics.dynamic(rhs, null);
}
@@ -402,13 +429,7 @@ class AccessSemanticsVisitor extends RecursiveAstVisitor<AccessSemantics> {
return null;
}
if (parent is TypeName) {
- // TODO(paulberry): handle this case. Or, perhaps it would be better to
- // require clients not to visit the children of a TypeName when visiting
- // the AST structure.
- //
- // TODO(paulberry): be sure to consider type literals, e.g.:
- // class A {}
- // var a = A;
+ // TODO(paulberry): do we need to handle this case?
return null;
}
if ((parent is PropertyAccess && parent.propertyName == node) ||
@@ -457,6 +478,10 @@ class AccessSemanticsVisitor extends RecursiveAstVisitor<AccessSemantics> {
node,
staticElement,
staticElement.enclosingElement);
+ } else if (staticElement is TypeParameterElement) {
+ return new AccessSemantics.typeParameter(node, staticElement);
+ } else if (staticElement is ClassElement) {
+ return new AccessSemantics.toplevelClass(node, staticElement);
Johnni Winther 2014/11/11 12:49:45 How do you handle 'dynamic' as a type literal?
Paul Berry 2014/11/11 13:22:34 Whoops, I forgot to handle this case. I also forg
}
return new AccessSemantics.dynamic(node, null);
}
« no previous file with comments | « no previous file | pkg/analyzer2dart/lib/src/semantic_visitor.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698