org.netbeans.modules.refactoring.java/1 1.37.0 1

org.netbeans.modules.refactoring.java.api
Class JavaRefactoringUtils

java.lang.Object
  extended by org.netbeans.modules.refactoring.java.api.JavaRefactoringUtils

public final class JavaRefactoringUtils
extends Object


Method Summary
static void cacheTreePathInfo(TreePath tp, CompilationInfo info)
           
static
<T extends Element>
List<ElementHandle<T>>
elementsToHandles(Iterable<? extends T> elements)
          Create ElementHandles from Elements
static List<TypeMirror> elementsToTypes(List<? extends Element> typeParams)
           
static TreePath findEnclosingClass(CompilationInfo javac, TreePath path, boolean isClass, boolean isInterface, boolean isEnum, boolean isAnnotation, boolean isAnonymous)
          Finds the nearest enclosing ClassTree on path that is class or interface or enum or annotation type and is or is not annonymous.
static ClasspathInfo getClasspathInfoFor(FileObject... files)
           
static Collection<TreePathHandle> getInvocationsOf(ElementHandle e, CompilationController wc)
           
static Collection<ExecutableElement> getOverriddenMethods(ExecutableElement method, CompilationInfo info)
           
static Collection<ExecutableElement> getOverridingMethods(ExecutableElement method, CompilationInfo info)
          Deprecated. use {@link #getOverridingMethods(javax.lang.model.element.ExecutableElement, org.netbeans.api.java.source.CompilationInfo, java.util.concurrent.atomic.AtomicBoolean)
static Collection<ExecutableElement> getOverridingMethods(ExecutableElement method, CompilationInfo info, AtomicBoolean cancel)
           
static Collection<TreePathHandle> getReferencesToMember(ElementHandle<TypeElement> on, ClasspathInfo info, ElementHandle toFind)
          Get all of the references to the given member element (which may be part of another type) on the passed element.
static Collection<TypeElement> getSuperTypes(TypeElement type, CompilationInfo info, boolean sourceOnly)
          Returns all supertypes of given type.
static
<T extends Element>
List<T>
handlesToElements(Iterable<ElementHandle<T>> handles, CompilationInfo info)
          Resolves ElementHandles to Elemnts
static List<TypeMirror> handlesToTypes(Iterable<? extends TypeMirrorHandle> types, CompilationInfo info)
          Resolves TypeMirrorHandles to TypeMirrors
static boolean isOnSourceClasspath(FileObject fo)
          Returns true if file is on known source path.
static boolean isRefactorable(FileObject file)
          returns true if file's mime type is text/x-java and file is on know source path
static List<TreePathHandle> treesToHandles(Iterable<? extends Tree> trees, CompilationInfo info)
          Convert Trees to TreePathHandles
static List<TreePathHandle> treesToHandles(TreePath parent, Iterable<? extends Tree> trees, CompilationInfo info)
           
static List<TypeMirrorHandle> typesToHandles(Iterable<? extends TypeMirror> types)
          Creates TypeMirrosHandles from TypeMirrors
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getOverriddenMethods

public static Collection<ExecutableElement> getOverriddenMethods(ExecutableElement method,
                                                                 CompilationInfo info)
Parameters:
method -
info -
Returns:
collection of ExecutableElements which are overidden by 'method'

getOverridingMethods

public static Collection<ExecutableElement> getOverridingMethods(ExecutableElement method,
                                                                 CompilationInfo info,
                                                                 AtomicBoolean cancel)
Parameters:
method -
info -
Returns:
collection of ExecutableElements which overrides 'method'
Since:
1.33

getOverridingMethods

@Deprecated
public static Collection<ExecutableElement> getOverridingMethods(ExecutableElement method,
                                                                            CompilationInfo info)
Deprecated. use {@link #getOverridingMethods(javax.lang.model.element.ExecutableElement, org.netbeans.api.java.source.CompilationInfo, java.util.concurrent.atomic.AtomicBoolean)

Parameters:
method -
info -
Returns:
collection of ExecutableElements which overrides 'method'

isOnSourceClasspath

public static boolean isOnSourceClasspath(FileObject fo)
Returns true if file is on known source path.

Parameters:
fo -
Returns:

isRefactorable

public static boolean isRefactorable(FileObject file)
returns true if file's mime type is text/x-java and file is on know source path

Parameters:
file -
Returns:

getSuperTypes

public static Collection<TypeElement> getSuperTypes(TypeElement type,
                                                    CompilationInfo info,
                                                    boolean sourceOnly)
Returns all supertypes of given type.

Parameters:
type -
info -
sourceOnly - library classes ignored if true
Returns:

findEnclosingClass

public static TreePath findEnclosingClass(CompilationInfo javac,
                                          TreePath path,
                                          boolean isClass,
                                          boolean isInterface,
                                          boolean isEnum,
                                          boolean isAnnotation,
                                          boolean isAnonymous)
Finds the nearest enclosing ClassTree on path that is class or interface or enum or annotation type and is or is not annonymous. In case no ClassTree is found the first top level ClassTree is returned. Especially useful for selecting proper tree to refactor.

Parameters:
javac - javac
path - path to search
isClass - stop on class
isInterface - stop on interface
isEnum - stop on enum
isAnnotation - stop on annotation type
isAnonymous - check if class or interface is annonymous
Returns:
path to the enclosing ClassTree

elementsToTypes

public static List<TypeMirror> elementsToTypes(List<? extends Element> typeParams)

getClasspathInfoFor

public static ClasspathInfo getClasspathInfoFor(FileObject... files)

treesToHandles

public static List<TreePathHandle> treesToHandles(TreePath parent,
                                                  Iterable<? extends Tree> trees,
                                                  CompilationInfo info)

treesToHandles

public static List<TreePathHandle> treesToHandles(Iterable<? extends Tree> trees,
                                                  CompilationInfo info)
Convert Trees to TreePathHandles

Parameters:
trees -
info -
Returns:

handlesToElements

public static <T extends Element> List<T> handlesToElements(Iterable<ElementHandle<T>> handles,
                                                            CompilationInfo info)
Resolves ElementHandles to Elemnts

Parameters:
handles -
info -
Returns:

handlesToTypes

public static List<TypeMirror> handlesToTypes(Iterable<? extends TypeMirrorHandle> types,
                                              CompilationInfo info)
Resolves TypeMirrorHandles to TypeMirrors

Parameters:
types -
info -
Returns:

typesToHandles

public static List<TypeMirrorHandle> typesToHandles(Iterable<? extends TypeMirror> types)
Creates TypeMirrosHandles from TypeMirrors

Parameters:
types -
Returns:

elementsToHandles

public static <T extends Element> List<ElementHandle<T>> elementsToHandles(Iterable<? extends T> elements)
Create ElementHandles from Elements

Parameters:
elements -
Returns:

getInvocationsOf

public static Collection<TreePathHandle> getInvocationsOf(ElementHandle e,
                                                          CompilationController wc)
                                                   throws IOException
Parameters:
e -
wc -
Returns:
Throws:
IOException

getReferencesToMember

public static Collection<TreePathHandle> getReferencesToMember(ElementHandle<TypeElement> on,
                                                               ClasspathInfo info,
                                                               ElementHandle toFind)
                                                        throws IOException
Get all of the references to the given member element (which may be part of another type) on the passed element.

Parameters:
on - A type which presumably refers to the passed element
toFind - An element, presumably a field or method, of some type (not necessarily the passed one)
Throws:
IOException

cacheTreePathInfo

public static void cacheTreePathInfo(TreePath tp,
                                     CompilationInfo info)

org.netbeans.modules.refactoring.java/1 1.37.0 1

Built on May 25 2012.  |  Portions Copyright 1997-2012 Oracle. All rights reserved.