|
org.eclipse.jdt.core.dom
Class NodeFinder
java.lang.Object
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. |
Methods inherited from class java.lang.
Object
|
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
|
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
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:
- first the visitor tries to find a node with the exact
start and length
- if no such node exists then the node that encloses the range defined by
start and length is returned.
- if the length is zero then also nodes are considered where the node's
start or end position matches
start .
- otherwise
null is returned.
-
-
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:
- first the visitor tries to find a node that is covered by
start and
length where either start and length exactly
matches the node or where the text covered before and after the node only consists
of white spaces or comments.
- if no such node exists then the node that encloses the range defined by
start and length is returned.
- if the length is zero then also nodes are considered where the node's
start or end position matches
start .
- otherwise
null is returned.
-
-
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
Copyright (c) IBM Corp. and others 2000, 2008. All Rights Reserved.
|
|