站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc (Current Development Version)

TreePathHandle (Java Source) - NetBeans API Javadoc (Current Development Version)

org.netbeans.modules.java.source 0.13.0 1

org.netbeans.api.java.source
Class TreePathHandle

java.lang.Object
  extended by org.netbeans.api.java.source.TreePathHandle

public final class TreePathHandle
extends Object

Represents a handle for TreePath which can be kept and later resolved by another javac. The Javac Elements are valid only in the single CompilationTask or single run of the CancellableTask. If the client needs to keep a reference to the TreePath and use it in the other CancellableTask he has to serialize it into the TreePathHandle.

Typical usage of TreePathHandle enclElIsCorrespondingEl:

                                                                                                                                                                                                                       
 final TreePathHandle[] tpHandle = new TreePathHandle[1];                                                                                                                                                                    
 javaSource.runCompileControlTask(new CancellableTask() {                                                                                                                                             
     public void run(CompilationController compilationController) {                                                                                                                                                          
         parameter.toPhase(Phase.RESOLVED);                                                                                                                                                                                  
         CompilationUnitTree cu = compilationController.getTree ();                                                                                                                                                          
         TreePath treePath = getInterestingTreePath (cu);                                                                                                                                                                    
         treePathHandle[0] = TreePathHandle.create (element, compilationController);                                                                                                                                         
    }                                                                                                                                                                                                                        
 },priority);                                                                                                                                                                                                                
                                                                                                                                                                                                                             
 otherJavaSource.runCompileControlTask(new CancellableTask() {                                                                                                                                        
     public void run(CompilationController compilationController) {                                                                                                                                                          
         parameter.toPhase(Phase.RESOLVED);                                                                                                                                                                                  
         TreePath treePath = treePathHanlde[0].resolve (compilationController);                                                                                                                                              
         ....                                                                                                                                                                                                                
    }                                                                                                                                                                                                                        
 },priority);                                                                                                                                                                                                                
 


Method Summary
static TreePathHandle create(Element element, CompilationInfo info)
          Factory method for creating TreePathHandle.
static TreePathHandle create(TreePath treePath, CompilationInfo info)
          Factory method for creating TreePathHandle.
 FileObject getFileObject()
          getter for FileObject from give TreePathHandle
 Tree.Kind getKind()
          Returns the Tree.Kind of this TreePathHandle, it returns the kind of the Tree from which the handle was created.
 TreePath resolve(CompilationInfo compilationInfo)
          Resolves an TreePath from the TreePathHandle.
 Element resolveElement(CompilationInfo info)
          Resolves an Element from the TreePathHandle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getFileObject

public FileObject getFileObject()
getter for FileObject from give TreePathHandle

Returns:
FileObject for which was this handle created

resolve

public TreePath resolve(CompilationInfo compilationInfo)
                 throws IllegalArgumentException
Resolves an TreePath from the TreePathHandle.

Parameters:
compilationInfo - representing the CompilationTask
Returns:
resolved subclass of Element or null if the elment does not exist on the classpath/sourcepath of CompilationTask.
Throws:
{@link - IllegalArgumentException} when this TreePathHandle is not created for a source represented by the compilationInfo.
IllegalArgumentException

resolveElement

public Element resolveElement(CompilationInfo info)
Resolves an Element from the TreePathHandle.

Parameters:
compilationInfo - representing the CompilationTask
Returns:
resolved subclass of Element or null if the elment does not exist on the classpath/sourcepath of CompilationTask.

getKind

public Tree.Kind getKind()
Returns the Tree.Kind of this TreePathHandle, it returns the kind of the Tree from which the handle was created.

Returns:
Tree.Kind

create

public static TreePathHandle create(TreePath treePath,
                                    CompilationInfo info)
                             throws IllegalArgumentException
Factory method for creating TreePathHandle.

Parameters:
treePath - for which the TrePathHandle should be created.
info -
Returns:
a new TreePathHandle
Throws:
IllegalArgumentException - if arguments are not supported

create

public static TreePathHandle create(Element element,
                                    CompilationInfo info)
                             throws IllegalArgumentException
Factory method for creating TreePathHandle.

Parameters:
element - for which the TrePathHandle should be created.
info -
Returns:
a new TreePathHandle
Throws:
IllegalArgumentException - if arguments are not supported

org.netbeans.modules.java.source 0.13.0 1

Built on May 28 2007.  |  Portions Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.