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

Unified Diff: compiler/java/com/google/dart/compiler/resolver/ResolutionContext.java

Issue 9150044: Record the elements on identifiers in the AST referring to types. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 11 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 | compiler/java/com/google/dart/compiler/resolver/Resolver.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compiler/java/com/google/dart/compiler/resolver/ResolutionContext.java
diff --git a/compiler/java/com/google/dart/compiler/resolver/ResolutionContext.java b/compiler/java/com/google/dart/compiler/resolver/ResolutionContext.java
index df8618d79df308c8e5c3553fa5eb0ceaa9d73f6e..cd1bb418768fc7699019e01801da70afd8fef00e 100644
--- a/compiler/java/com/google/dart/compiler/resolver/ResolutionContext.java
+++ b/compiler/java/com/google/dart/compiler/resolver/ResolutionContext.java
@@ -176,11 +176,31 @@ public class ResolutionContext implements ResolutionErrorListener {
if (node == null) {
return null;
} else {
- return resolveType(node, node.getIdentifier(), node.getTypeArguments(), isStatic, isFactory,
+ Type type = resolveType(node, node.getIdentifier(), node.getTypeArguments(), isStatic, isFactory,
errorCode);
+ recordTypeIdentifier(node.getIdentifier(), type.getElement());
+ return type;
}
}
+ protected <E extends Element> E recordTypeIdentifier(DartNode node, E element) {
+ node.getClass();
+ if (node instanceof DartPropertyAccess) {
+ recordTypeIdentifier(((DartPropertyAccess)node).getQualifier(),
+ element.getEnclosingElement());
+ return recordTypeIdentifier(((DartPropertyAccess)node).getName(), element);
+ } else if (node instanceof DartIdentifier) {
+ if (element == null) {
+ // TypeAnalyzer will diagnose unresolved identifiers.
+ return null;
+ }
+ node.setSymbol(element);
+ } else {
+ throw internalError(node, "Unexpected node: %s", node);
+ }
+ return element;
+ }
+
Type resolveType(DartNode diagnosticNode, DartNode identifier, List<DartTypeNode> typeArguments,
boolean isStatic, boolean isFactory, ErrorCode errorCode) {
Element element = resolveName(identifier);
@@ -247,6 +267,7 @@ public class ResolutionContext implements ResolutionErrorListener {
boolean isFactory,
ErrorCode errorCode) {
List<? extends Type> typeParameters = element.getTypeParameters();
+
Type[] typeArguments;
if (typeArgumentNodes == null || typeArgumentNodes.size() != typeParameters.size()) {
typeArguments = new Type[typeParameters.size()];
« no previous file with comments | « no previous file | compiler/java/com/google/dart/compiler/resolver/Resolver.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698