### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: dom/org/eclipse/jdt/core/dom/ASTNode.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTNode.java,v retrieving revision 1.77 diff -u -r1.77 ASTNode.java --- dom/org/eclipse/jdt/core/dom/ASTNode.java 27 Jun 2008 16:03:49 -0000 1.77 +++ dom/org/eclipse/jdt/core/dom/ASTNode.java 12 Sep 2008 12:26:22 -0000 @@ -2473,9 +2473,10 @@ throw new IllegalArgumentException(); } // begin with the generic pre-visit - visitor.preVisit(this); - // dynamic dispatch to internal method for type-specific visit/endVisit - accept0(visitor); + if (visitor.preVisit2(this)) { + // dynamic dispatch to internal method for type-specific visit/endVisit + accept0(visitor); + } // end with the generic post-visit visitor.postVisit(this); } Index: dom/org/eclipse/jdt/core/dom/ASTVisitor.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTVisitor.java,v retrieving revision 1.24 diff -u -r1.24 ASTVisitor.java --- dom/org/eclipse/jdt/core/dom/ASTVisitor.java 27 Jun 2008 16:03:45 -0000 1.24 +++ dom/org/eclipse/jdt/core/dom/ASTVisitor.java 12 Sep 2008 12:26:22 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -143,12 +143,32 @@ *

* * @param node the node to visit + * + * @see #preVisit2(ASTNode) */ public void preVisit(ASTNode node) { // default implementation: do nothing } /** + * Visits the given AST node prior to the type-specific visit. (before visit). + *

+ * The default implementation calls {@link #preVisit(ASTNode)} and then + * returns true. Subclasses may reimplement. + *

+ * + * @param node the node to visit + * @return true if visit(node) should be called, + * and false if the children of this node should be skipped + * @see #preVisit(ASTNode) + * @since 3.5 + */ + public boolean preVisit2(ASTNode node) { + preVisit(node); + return true; + } + + /** * Visits the given AST node following the type-specific visit * (after endVisit). *

#P org.eclipse.jdt.ui Index: core extension/org/eclipse/jdt/internal/corext/dom/NodeFinder.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/dom/NodeFinder.java,v retrieving revision 1.17 diff -u -r1.17 NodeFinder.java --- core extension/org/eclipse/jdt/internal/corext/dom/NodeFinder.java 11 Sep 2008 11:59:38 -0000 1.17 +++ core extension/org/eclipse/jdt/internal/corext/dom/NodeFinder.java 12 Sep 2008 12:26:23 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -19,12 +19,13 @@ import org.eclipse.jdt.core.compiler.ITerminalSymbols; import org.eclipse.jdt.core.compiler.InvalidInputException; import org.eclipse.jdt.core.dom.ASTNode; +import org.eclipse.jdt.core.dom.ASTVisitor; /** * For a give range finds the node covered and the node covering. * * @since 2.1 */ -public class NodeFinder extends GenericVisitor { +public class NodeFinder extends ASTVisitor { /** * A visitor that maps a selection to a given ASTNode. The result node is @@ -127,7 +128,7 @@ fEnd= offset + length; } - protected boolean visitNode(ASTNode node) { + public boolean preVisit2(ASTNode node) { int nodeStart= node.getStartPosition(); int nodeEnd= nodeStart + node.getLength(); if (nodeEnd < fStart || fEnd < nodeStart) {