|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.cmu.cs.crystal.internal.WorkspaceUtilities
public class WorkspaceUtilities
A collection of methods used to extract useful data from the workspace. These methods are used by the framework and should not be used by users of the framework. You can access must of the data collected from these methods via the Crystal class.
Constructor Summary | |
---|---|
WorkspaceUtilities()
|
Method Summary | |
---|---|
static List<ICompilationUnit> |
collectCompilationUnits(IJavaElement javaElement)
A recursive traversal of the IJavaModel starting from the given element to collect all ICompilationUnits. |
static List<ITypeRoot> |
collectCompilationUnits(IJavaElement javaElement,
boolean includeArchives)
A recursive traversal of the IJavaModel starting from the given element to collect all ITypeRoots, optionally including .class files available in libraries. |
static List<ICompilationUnit> |
findCompilationUnits(List<String> files)
Returns the list of compilation units for a given list of file names. |
static ASTNode |
getASTNodeFromCompilationUnit(ITypeRoot compUnit)
Gets the root ASTNode for a compilation unit, with bindings on. |
static Option<TypeDeclaration> |
getDeclNodeFromType(IType type)
Given an IType from the model, this method will return the ast node associated with that type, or null if it doesn't exist. |
static Option<MethodDeclaration> |
getMethodDeclFromModel(IMethod method)
Returns the AST node associated with the given model element, which in this case is a method. |
static String |
getWorkspaceRelativeName(IJavaElement element)
Walks up the Java model hierarchy and separates the names of encountered elements by forward slashes |
static Map<ICompilationUnit,ASTNode> |
parseCompilationUnits(List<ICompilationUnit> compilationUnits)
Goes through a list of compilation units and parses them. |
static Map<String,ASTNode> |
scanForBindings(ICompilationUnit compUnit,
ASTNode node)
|
static Map<String,ASTNode> |
scanForBindings(Map<ICompilationUnit,ASTNode> compilationUnitToASTNode)
|
static List<ICompilationUnit> |
scanForCompilationUnits()
Traverses the workspace for CompilationUnits. |
static List<ITypeRoot> |
scanForCompilationUnits(boolean includeClassfiles)
Traverses the workspace for CompilationUnits and (optionally) class files. |
static List<MethodDeclaration> |
scanForMethodDeclarations(Map<ICompilationUnit,ASTNode> compilationUnitToASTNode)
Collects all top level methods from CompilationUnits. |
static List<MethodDeclaration> |
scanForMethodDeclarationsFromAST(ASTNode node)
Collects all top level methods from an AST including embedded methods. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public WorkspaceUtilities()
Method Detail |
---|
public static List<ICompilationUnit> scanForCompilationUnits()
null
if no comp units were found.public static List<ICompilationUnit> collectCompilationUnits(IJavaElement javaElement)
javaElement
- a node in the IJavaModel that will be traversed
null
if no comp units are foundpublic static List<ITypeRoot> scanForCompilationUnits(boolean includeClassfiles)
includeClassfiles
- include compilation units availabile as .class files
null
if no comp units were found.public static List<ITypeRoot> collectCompilationUnits(IJavaElement javaElement, boolean includeArchives)
javaElement
- a node in the IJavaModel that will be traversedincludeArchives
- whether to descend into binary libraries of .class files
null
if no comp units are foundpublic static Map<ICompilationUnit,ASTNode> parseCompilationUnits(List<ICompilationUnit> compilationUnits)
compilationUnits
- the list of compilation units to parse
public static List<MethodDeclaration> scanForMethodDeclarations(Map<ICompilationUnit,ASTNode> compilationUnitToASTNode)
compilationUnitToASTNode
- the mapping of CompilationUnits to preparsed ASTNodes
public static List<MethodDeclaration> scanForMethodDeclarationsFromAST(ASTNode node)
node
- the root of an AST
public static Map<String,ASTNode> scanForBindings(Map<ICompilationUnit,ASTNode> compilationUnitToASTNode)
public static Map<String,ASTNode> scanForBindings(ICompilationUnit compUnit, ASTNode node)
public static List<ICompilationUnit> findCompilationUnits(List<String> files)
files
- List of file names to search for. They will be compared to
the result of getWorkspaceRelativeName(IJavaElement)
.
public static String getWorkspaceRelativeName(IJavaElement element)
element
-
public static ASTNode getASTNodeFromCompilationUnit(ITypeRoot compUnit)
compUnit
- never null
IllegalStateException
- if compUnit
doesn't have a
source attachment
ASTParser.createAST(org.eclipse.core.runtime.IProgressMonitor)
public static Option<TypeDeclaration> getDeclNodeFromType(IType type)
public static Option<MethodDeclaration> getMethodDeclFromModel(IMethod method)
method
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |