| 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);
|
|
|