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

Unified Diff: compiler/javatests/com/google/dart/compiler/resolver/ResolverAuditVisitor.java

Issue 9138023: More setting of symbols on identifiers (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Changes many assertEquals() to assertSame() 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
Index: compiler/javatests/com/google/dart/compiler/resolver/ResolverAuditVisitor.java
diff --git a/compiler/javatests/com/google/dart/compiler/resolver/ResolverAuditVisitor.java b/compiler/javatests/com/google/dart/compiler/resolver/ResolverAuditVisitor.java
new file mode 100644
index 0000000000000000000000000000000000000000..1311fcccb69bc9876e84d49406673fc7a23d2798
--- /dev/null
+++ b/compiler/javatests/com/google/dart/compiler/resolver/ResolverAuditVisitor.java
@@ -0,0 +1,80 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+package com.google.dart.compiler.resolver;
+
+import com.google.common.base.Joiner;
+import com.google.common.collect.Lists;
+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;
+
+import java.util.List;
+
+/**
+ * Look for DartIdentifier nodes in the tree whose symbols are null. They should all either
+ * be resolved, or marked as an unresolved element.
+ */
+public class ResolverAuditVisitor extends DartNodeTraverser<Void> {
+ 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);
+ ResolverTestCase.fail(out.toString());
+ }
+ }
+
+ private List<String> failures = Lists.newArrayList();
+
+ public List<String> getFailures() {
+ return failures;
+ }
+
+ @Override
+ public Void visitClass(DartClass node) {
+ node.getName().accept(this);
+ node.visitChildren(this);
+ return null;
+ }
+
+ @Override
+ public Void visitIdentifier(DartIdentifier node) {
+ if (node.getSymbol() == null) {
+ failures.add("Identifier: " + node.getTargetName() + " has null symbol @ ("
+ + node.getSourceLine() + ":" + node.getSourceColumn() + ")");
+ }
+ return null;
+ }
+
+ @Override
+ public Void visitParameterizedTypeNode(DartParameterizedTypeNode node) {
+ node.getExpression().accept(this);
+ visit(node.getTypeParameters());
+ return null;
+ }
+
+ @Override
+ public Void visitTypeNode(DartTypeNode node) {
+ node.getIdentifier().accept(this);
+ visit(node.getTypeArguments());
+ return null;
+ }
+
+ @Override
+ public Void visitTypeParameter(DartTypeParameter node) {
+ node.getName().accept(this);
+ if (node.getBound() != null) {
+ node.getBound().accept(this);
+ }
+ return null;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698