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

Unified Diff: compiler/javatests/com/google/dart/compiler/parser/DartASTValidator.java

Issue 10872048: Convert getter and catch syntax in tests; fix resulting bugs (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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/parser/DartASTValidator.java
===================================================================
--- compiler/javatests/com/google/dart/compiler/parser/DartASTValidator.java (revision 11229)
+++ compiler/javatests/com/google/dart/compiler/parser/DartASTValidator.java (working copy)
@@ -593,12 +593,12 @@
int nodeEnd = nodeStart + nodeLength;
int parentStart = parent.getSourceInfo().getOffset();
int parentEnd = parentStart + parent.getSourceInfo().getLength();
- if (parentStart > nodeStart) {
+ if (parentStart > nodeStart && !isExceptionForNesting(node)) {
errors.add("Invalid source start (" + nodeStart + ") for "
+ node.getClass().getName() + " inside "
+ parent.getClass().getName() + " (" + parentStart + ")");
}
- if (nodeEnd > parentEnd) {
+ if (nodeEnd > parentEnd && !isExceptionForNesting(node)) {
errors.add("Invalid source end (" + nodeEnd + ") for "
+ node.getClass().getName() + " inside "
+ parent.getClass().getName() + " (" + parentStart + ")");
@@ -611,6 +611,21 @@
}
}
+ /**
+ * Return {@code true} if the given node is an exception to the rule that nodes must nest lexically
+ * within their parents. The one exception currently recognized is a DartTypeNode whose parent is
+ * a DartParameter within a DartCatchBlock. This exception exists because the type has been moved
+ * outside the parameter (following the 'on' keyword) but we didn't update the AST structure to
+ * reflect this change.
+ *
+ * @param node the node being tested
+ * @return {@code true} if the given node is an exception to the rule that nodes must nest lexically
+ * within their parents
+ */
+ private boolean isExceptionForNesting(DartNode node) {
+ return (node instanceof DartTypeNode) && (node.getParent() instanceof DartParameter) && (node.getParent().getParent() instanceof DartCatchBlock);
+ }
+
@Override
public Void visitParameterizedTypeNode(DartParameterizedTypeNode node) {
validate(node);

Powered by Google App Engine
This is Rietveld 408576698