Class JdtUtil
java.lang.Object
com.ibm.wala.ide.util.JdtUtil
Convenience methods to get information from JDT
IJavaElement
model.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic org.eclipse.jdt.core.IJavaElement
createJavaElementFromJdtHandle
(String jdtHandle) Deprecated.static org.eclipse.jdt.core.IType
findJavaClassInProjects
(String fullyQualifiedName, Collection<org.eclipse.jdt.core.IJavaProject> projects) Find theIType
in the workspace corresponding to a class name.static org.eclipse.jdt.core.IType
findJavaClassInResources
(String className, Collection<org.eclipse.core.resources.IResource> resources) static org.eclipse.jdt.core.IMethod
findJavaMethodInProjects
(String klass, String selector, Collection<org.eclipse.jdt.core.IJavaProject> projects) Find the IMethod in the workspace corresponding to a method selector.static org.eclipse.jdt.core.IMethod
Deprecated.static Collection
<org.eclipse.jdt.core.IMethod> findMethods
(org.eclipse.jdt.core.IJavaElement elt) Use the search engine to find all methods in a java elementstatic org.eclipse.jdt.core.dom.ASTNode
getAST
(org.eclipse.core.resources.IFile javaSourceFile) static org.eclipse.jdt.core.IType[]
getClasses
(org.eclipse.jdt.core.ICompilationUnit cu) static String
getClassName
(org.eclipse.jdt.core.IType type) static String
getFilePath
(org.eclipse.jdt.core.IJavaElement javaElt) static String
getFullyQualifiedClassName
(org.eclipse.jdt.core.IType type) static String
getHumanReadableType
(String typeSignature) static org.eclipse.jdt.core.IJavaProject
getJavaProject
(String projectName) static org.eclipse.jdt.core.IJavaProject
getJavaProject
(org.eclipse.core.resources.IFile appJar) static String
getJdtHandleString
(org.eclipse.jdt.core.IJavaElement javaElt) Return a unique string representing the specified Java element across projects in the workspace.static org.eclipse.jdt.core.IJavaProject
getNamedProject
(String projectName) static org.eclipse.jdt.core.dom.ASTNode
static org.eclipse.jdt.core.dom.ASTNode
getOriginalNode
(org.eclipse.jdt.core.dom.ASTNode root, JdtPosition pos) static String
getPackageName
(org.eclipse.jdt.core.ICompilationUnit cu) static org.eclipse.jdt.core.IJavaProject
getProject
(org.eclipse.jdt.core.IJavaElement javaElt) static String
getProjectName
(org.eclipse.jdt.core.IJavaProject javaProject) static org.eclipse.jface.viewers.StructuredSelection
getStructuredSelectionForProjectNames
(Collection<String> projectNames) get aStructuredSelection
corresponding to the named projectsstatic Collection
<String> getTypeParameterNames
(org.eclipse.jdt.core.IType type) static Collection
<org.eclipse.jdt.core.IJavaProject> compute the java projects in the active workspacestatic String
parseForName
(String selector, org.eclipse.jdt.core.IType type) static final String[]
parseForParameterTypes
(String selector)
-
Constructor Details
-
JdtUtil
public JdtUtil()
-
-
Method Details
-
getFilePath
-
getPackageName
-
getFullyQualifiedClassName
-
getClassName
-
getJdtHandleString
Return a unique string representing the specified Java element across projects in the workspace. The returned string can be used as a handle to create JavaElement by 'JavaCore.create(String)'For example, suppose we have the method 'fooPackage.barPackage.FooClass.fooMethod(int)' which is in the 'FooProject' and source folder 'src' the handle would be '=FooProject/src<fooPackage.barPackage{FooClass.java[FooClass~fooMethod~I'
- Throws:
IllegalArgumentException
- if javaElt is null
-
createJavaElementFromJdtHandle
@Deprecated public static org.eclipse.jdt.core.IJavaElement createJavaElementFromJdtHandle(String jdtHandle) Deprecated. -
getClasses
public static org.eclipse.jdt.core.IType[] getClasses(org.eclipse.jdt.core.ICompilationUnit cu) -
getProject
public static org.eclipse.jdt.core.IJavaProject getProject(org.eclipse.jdt.core.IJavaElement javaElt) -
getProjectName
-
getHumanReadableType
- Parameters:
typeSignature
- Some of the type signatures examples are "QString;" (String) and "I" (int) The type signatures may be either unresolved (for source types) or resolved (for binary types), and either basic (for basic types) or rich (for parameterized types). SeeSignature
for details.
-
getJavaProject
public static org.eclipse.jdt.core.IJavaProject getJavaProject(org.eclipse.core.resources.IFile appJar) -
getJavaProject
-
getWorkspaceJavaProjects
compute the java projects in the active workspace -
findJavaClassInProjects
public static org.eclipse.jdt.core.IType findJavaClassInProjects(String fullyQualifiedName, Collection<org.eclipse.jdt.core.IJavaProject> projects) throws IllegalArgumentException Find theIType
in the workspace corresponding to a class name.- Returns:
- null if not found
- Throws:
IllegalArgumentException
- if projects == null
-
findJavaClassInResources
public static org.eclipse.jdt.core.IType findJavaClassInResources(String className, Collection<org.eclipse.core.resources.IResource> resources) -
findJavaMethodInProjects
public static org.eclipse.jdt.core.IMethod findJavaMethodInProjects(String klass, String selector, Collection<org.eclipse.jdt.core.IJavaProject> projects) Find the IMethod in the workspace corresponding to a method selector.TODO: this is way too slow. figure out something better.
- Returns:
- null if not found
-
getTypeParameterNames
public static Collection<String> getTypeParameterNames(org.eclipse.jdt.core.IType type) throws IllegalArgumentException, org.eclipse.jdt.core.JavaModelException - Throws:
IllegalArgumentException
org.eclipse.jdt.core.JavaModelException
-
parseForName
-
parseForParameterTypes
public static final String[] parseForParameterTypes(String selector) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
findJavaMethodInWorkspaceBrokenForInnerClasses
@Deprecated public static org.eclipse.jdt.core.IMethod findJavaMethodInWorkspaceBrokenForInnerClasses(String methodSig) Deprecated.Find the IMethod in the workspace corresponding to a method signature.This doesn't work for elements declared in inner classes. It's possible this is a 3.2 bug fixed in 3.3
- Returns:
- null if not found
-
findMethods
public static Collection<org.eclipse.jdt.core.IMethod> findMethods(org.eclipse.jdt.core.IJavaElement elt) Use the search engine to find all methods in a java element -
getStructuredSelectionForProjectNames
public static org.eclipse.jface.viewers.StructuredSelection getStructuredSelectionForProjectNames(Collection<String> projectNames) get aStructuredSelection
corresponding to the named projects -
getNamedProject
-
getAST
public static org.eclipse.jdt.core.dom.ASTNode getAST(org.eclipse.core.resources.IFile javaSourceFile) -
getOriginalNode
-
getOriginalNode
public static org.eclipse.jdt.core.dom.ASTNode getOriginalNode(org.eclipse.jdt.core.dom.ASTNode root, JdtPosition pos)
-