public final class JavaRefactoringUtils extends Object
Modifier and Type | Method and Description |
---|---|
static void |
cacheTreePathInfo(TreePath tp,
CompilationInfo info) |
static <T extends Element> |
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)
|
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> |
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 |
isFromLibrary(ElementHandle<? extends Element> element,
ClasspathInfo info) |
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
|
public static Collection<ExecutableElement> getOverriddenMethods(ExecutableElement method, CompilationInfo info)
method
- info
- public static Collection<ExecutableElement> getOverridingMethods(ExecutableElement method, CompilationInfo info, AtomicBoolean cancel)
method
- info
- @Deprecated public static Collection<ExecutableElement> getOverridingMethods(ExecutableElement method, CompilationInfo info)
method
- info
- public static boolean isFromLibrary(ElementHandle<? extends Element> element, ClasspathInfo info)
public static boolean isOnSourceClasspath(FileObject fo)
fo
- public static boolean isRefactorable(FileObject file)
file
- public static Collection<TypeElement> getSuperTypes(TypeElement type, CompilationInfo info, boolean sourceOnly)
type
- info
- sourceOnly
- library classes ignored if truepublic static TreePath findEnclosingClass(CompilationInfo javac, TreePath path, boolean isClass, boolean isInterface, boolean isEnum, boolean isAnnotation, boolean isAnonymous)
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.javac
- javacpath
- path to searchisClass
- stop on classisInterface
- stop on interfaceisEnum
- stop on enumisAnnotation
- stop on annotation typeisAnonymous
- check if class or interface is annonymouspublic static List<TypeMirror> elementsToTypes(List<? extends Element> typeParams)
public static ClasspathInfo getClasspathInfoFor(FileObject... files)
public static List<TreePathHandle> treesToHandles(TreePath parent, Iterable<? extends Tree> trees, CompilationInfo info)
public static List<TreePathHandle> treesToHandles(Iterable<? extends Tree> trees, CompilationInfo info)
trees
- info
- public static <T extends Element> List<T> handlesToElements(Iterable<ElementHandle<T>> handles, CompilationInfo info)
handles
- info
- public static List<TypeMirror> handlesToTypes(Iterable<? extends TypeMirrorHandle> types, CompilationInfo info)
types
- info
- public static List<TypeMirrorHandle> typesToHandles(Iterable<? extends TypeMirror> types)
types
- public static <T extends Element> List<ElementHandle<T>> elementsToHandles(Iterable<? extends T> elements)
elements
- public static Collection<TreePathHandle> getInvocationsOf(ElementHandle e, CompilationController wc) throws IOException
e
- wc
- IOException
public static Collection<TreePathHandle> getReferencesToMember(ElementHandle<TypeElement> on, ClasspathInfo info, ElementHandle toFind) throws IOException
on
- A type which presumably refers to the passed elementtoFind
- An element, presumably a field or method, of some type (not necessarily the passed one)IOException
public static void cacheTreePathInfo(TreePath tp, CompilationInfo info)