Eclipse JDT
Release 3.5

org.eclipse.jdt.core.dom
Class NodeFinder

java.lang.Object
  extended by org.eclipse.jdt.core.dom.NodeFinder

public final class NodeFinder
extends Object

For a given range, finds the covered node and the covering node. This API is still under discussion, see https://bugs.eclipse.org/53024 .

Since:
3.5

Constructor Summary
NodeFinder(ASTNode root, int start, int length)
          Instantiate a new node finder using the given root node, the given start and the given length.
 
Method Summary
 ASTNode getCoveredNode()
          Returns the covered node.
 ASTNode getCoveringNode()
          Returns the covering node.
static ASTNode perform(ASTNode root, int start, int length)
          Maps a selection to a given ASTNode, where the selection is defined using a start and a length.
static ASTNode perform(ASTNode root, int start, int length, ITypeRoot source)
          Maps a selection to a given ASTNode, where the selection is given by a start and a length.
static ASTNode perform(ASTNode root, ISourceRange range)
          Maps a selection to a given ASTNode, where the selection is defined using a source range.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NodeFinder

public NodeFinder(ASTNode root,
                  int start,
                  int length)
Instantiate a new node finder using the given root node, the given start and the given length.

Parameters:
root - the given root node
start - the given start
length - the given length
Method Detail

perform

public static ASTNode perform(ASTNode root,
                              int start,
                              int length)
Maps a selection to a given ASTNode, where the selection is defined using a start and a length. The result node is determined as follows:

Parameters:
root - the root node from which the search starts
start - the given start
length - the given length
Returns:
the found node

perform

public static ASTNode perform(ASTNode root,
                              ISourceRange range)
Maps a selection to a given ASTNode, where the selection is defined using a source range. It calls perform(root, range.getOffset(), range.getLength()).

Returns:
the result node
See Also:
perform(ASTNode, int, int)

perform

public static ASTNode perform(ASTNode root,
                              int start,
                              int length,
                              ITypeRoot source)
                       throws JavaModelException
Maps a selection to a given ASTNode, where the selection is given by a start and a length. The result node is determined as follows:

Parameters:
root - the root node from which the search starts
start - the given start
length - the given length
source - the source of the compilation unit
Returns:
the result node
Throws:
JavaModelException - if an error occurs in the Java model

getCoveredNode

public ASTNode getCoveredNode()
Returns the covered node. If more than one nodes are covered by the selection, the returned node is first covered node found in a top-down traversal of the AST.

Returns:
the covered node

getCoveringNode

public ASTNode getCoveringNode()
Returns the covering node. If more than one nodes are covering the selection, the returned node is last covering node found in a top-down traversal of the AST.

Returns:
the covering node

Eclipse JDT
Release 3.5

Copyright (c) IBM Corp. and others 2000, 2008. All Rights Reserved.