Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 


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:
  • 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

Eclipse JDT
Release 3.5

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

 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire