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

Unified Diff: compiler/javatests/com/google/dart/compiler/resolver/ResolverTestCase.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 | « compiler/java/com/google/dart/compiler/resolver/Resolver.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compiler/javatests/com/google/dart/compiler/resolver/ResolverTestCase.java
diff --git a/compiler/javatests/com/google/dart/compiler/resolver/ResolverTestCase.java b/compiler/javatests/com/google/dart/compiler/resolver/ResolverTestCase.java
index 3d3e65f7dbe5f17be2509842b7cd2048108de3f9..a70e254f98c1a1bd0c10f06060e9e6b08b2f2da8 100644
--- a/compiler/javatests/com/google/dart/compiler/resolver/ResolverTestCase.java
+++ b/compiler/javatests/com/google/dart/compiler/resolver/ResolverTestCase.java
@@ -13,6 +13,7 @@ import com.google.dart.compiler.ErrorCode;
import com.google.dart.compiler.ast.DartClass;
import com.google.dart.compiler.ast.DartIdentifier;
import com.google.dart.compiler.ast.DartNode;
+import com.google.dart.compiler.ast.DartNodeTraverser;
import com.google.dart.compiler.ast.DartParameterizedTypeNode;
import com.google.dart.compiler.ast.DartTypeNode;
import com.google.dart.compiler.ast.DartTypeParameter;
@@ -72,6 +73,10 @@ abstract class ResolverTestCase extends TestCase {
new MemberBuilder().exec(unit, context, scope, typeProvider);
new CompileTimeConstantResolver().exec(unit, context, typeProvider);
new Resolver(context, scope, typeProvider).exec(unit);
+ // TODO(zundel): One day, we want all AST nodes that are identifiers to point to
+ // elements if they are resolved. Uncommenting this line helps track missing elements
+ // down.
+ // ResolverAuditVisitor.exec(unit);
return scope;
}
@@ -128,6 +133,39 @@ abstract class ResolverTestCase extends TestCase {
return new DartTypeParameter(new DartIdentifier(name), null);
}
+ /**
+ * Look for DartIdentifier nodes in the tree whose symbols are null. They should all either
+ * be resolved, or marked as an unresolved element.
+ */
+ static class ResolverAuditVisitor extends DartNodeTraverser<Void> {
+ private List<String> failures = Lists.newArrayList();
+
+ @Override
+ public Void visitIdentifier(DartIdentifier node) {
+
+ if (node.getSymbol() == null) {
+ failures.add("Identifier: " + node.getTargetName() + " has null symbol @ ("
+ + node.getSourceLine() + ":" + node.getSourceColumn() + ")");
+ }
+ return null;
+ }
+
+ public List<String> getFailures() {
+ return failures;
+ }
+
+ public static void exec(DartNode root) {
+ ResolverAuditVisitor visitor = new ResolverAuditVisitor();
+ root.accept(visitor);
+ List<String> results = visitor.getFailures();
+ if (results.size() > 0) {
+ StringBuilder out = new StringBuilder("Missing symbols found in AST\n");
+ Joiner.on("\n").appendTo(out, results);
+ fail(out.toString());
+ }
+ }
+ }
+
static class MockCoreTypeProvider implements CoreTypeProvider {
private final InterfaceType boolType;
« no previous file with comments | « compiler/java/com/google/dart/compiler/resolver/Resolver.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698