| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package com.google.dart.compiler.resolver; | 5 package com.google.dart.compiler.resolver; |
| 6 | 6 |
| 7 import com.google.common.base.Joiner; | 7 import com.google.common.base.Joiner; |
| 8 import com.google.common.base.Splitter; | 8 import com.google.common.base.Splitter; |
| 9 import com.google.common.collect.Lists; | 9 import com.google.common.collect.Lists; |
| 10 import com.google.dart.compiler.DartCompilationError; | 10 import com.google.dart.compiler.DartCompilationError; |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 127 |
| 128 static DartParameterizedTypeNode makeDefault(String name) { | 128 static DartParameterizedTypeNode makeDefault(String name) { |
| 129 return new DartParameterizedTypeNode(new DartIdentifier(name), null); | 129 return new DartParameterizedTypeNode(new DartIdentifier(name), null); |
| 130 } | 130 } |
| 131 | 131 |
| 132 private static DartTypeParameter makeTypeVariable(String name) { | 132 private static DartTypeParameter makeTypeVariable(String name) { |
| 133 return new DartTypeParameter(new DartIdentifier(name), null); | 133 return new DartTypeParameter(new DartIdentifier(name), null); |
| 134 } | 134 } |
| 135 | 135 |
| 136 /** | 136 /** |
| 137 * Look for DartIdentifier nodes in the tree whose symbols are null. They sh
ould all either | 137 * Look for DartIdentifier nodes in the tree whose elements are null. They s
hould all either |
| 138 * be resolved, or marked as an unresolved element. | 138 * be resolved, or marked as an unresolved element. |
| 139 */ | 139 */ |
| 140 static class ResolverAuditVisitor extends ASTVisitor<Void> { | 140 static class ResolverAuditVisitor extends ASTVisitor<Void> { |
| 141 private List<String> failures = Lists.newArrayList(); | 141 private List<String> failures = Lists.newArrayList(); |
| 142 | 142 |
| 143 @Override | 143 @Override |
| 144 public Void visitIdentifier(DartIdentifier node) { | 144 public Void visitIdentifier(DartIdentifier node) { |
| 145 | 145 |
| 146 if (node.getSymbol() == null) { | 146 if (node.getElement() == null) { |
| 147 failures.add("Identifier: " + node.getTargetName() + " has null symbol @
(" | 147 failures.add("Identifier: " + node.getName() + " has null element @ (" |
| 148 + node.getSourceLine() + ":" + node.getSourceColumn() + ")"); | 148 + node.getSourceLine() + ":" + node.getSourceColumn() + ")"); |
| 149 } | 149 } |
| 150 return null; | 150 return null; |
| 151 } | 151 } |
| 152 | 152 |
| 153 public List<String> getFailures() { | 153 public List<String> getFailures() { |
| 154 return failures; | 154 return failures; |
| 155 } | 155 } |
| 156 | 156 |
| 157 public static void exec(DartNode root) { | 157 public static void exec(DartNode root) { |
| 158 ResolverAuditVisitor visitor = new ResolverAuditVisitor(); | 158 ResolverAuditVisitor visitor = new ResolverAuditVisitor(); |
| 159 root.accept(visitor); | 159 root.accept(visitor); |
| 160 List<String> results = visitor.getFailures(); | 160 List<String> results = visitor.getFailures(); |
| 161 if (results.size() > 0) { | 161 if (results.size() > 0) { |
| 162 StringBuilder out = new StringBuilder("Missing symbols found in AST\n"); | 162 StringBuilder out = new StringBuilder("Missing elements found in AST\n")
; |
| 163 Joiner.on("\n").appendTo(out, results); | 163 Joiner.on("\n").appendTo(out, results); |
| 164 fail(out.toString()); | 164 fail(out.toString()); |
| 165 } | 165 } |
| 166 } | 166 } |
| 167 } | 167 } |
| 168 | 168 |
| 169 static class MockCoreTypeProvider implements CoreTypeProvider { | 169 static class MockCoreTypeProvider implements CoreTypeProvider { |
| 170 | 170 |
| 171 private final InterfaceType boolType; | 171 private final InterfaceType boolType; |
| 172 private final InterfaceType intType; | 172 private final InterfaceType intType; |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 public void onError(DartCompilationError event) { | 514 public void onError(DartCompilationError event) { |
| 515 resolveErrors.add(event); | 515 resolveErrors.add(event); |
| 516 } | 516 } |
| 517 }; | 517 }; |
| 518 // resolve and check errors | 518 // resolve and check errors |
| 519 resolveCompileTimeConst(unit, ctx); | 519 resolveCompileTimeConst(unit, ctx); |
| 520 ErrorExpectation.assertErrors(resolveErrors, expectedErrors); | 520 ErrorExpectation.assertErrors(resolveErrors, expectedErrors); |
| 521 return resolveErrors; | 521 return resolveErrors; |
| 522 } | 522 } |
| 523 } | 523 } |
| OLD | NEW |