Class JdtUtil
java.lang.Object
com.ibm.wala.ide.util.JdtUtil
Convenience methods to get information from JDT
IJavaElement model.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.eclipse.jdt.core.IJavaElementcreateJavaElementFromJdtHandle(String jdtHandle) Deprecated.static org.eclipse.jdt.core.ITypefindJavaClassInProjects(String fullyQualifiedName, Collection<org.eclipse.jdt.core.IJavaProject> projects) Find theITypein the workspace corresponding to a class name.static org.eclipse.jdt.core.ITypefindJavaClassInResources(String className, Collection<org.eclipse.core.resources.IResource> resources) static org.eclipse.jdt.core.IMethodfindJavaMethodInProjects(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.IMethodDeprecated.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.ASTNodegetAST(org.eclipse.core.resources.IFile javaSourceFile) static org.eclipse.jdt.core.IType[]getClasses(org.eclipse.jdt.core.ICompilationUnit cu) static StringgetClassName(org.eclipse.jdt.core.IType type) static StringgetFilePath(org.eclipse.jdt.core.IJavaElement javaElt) static StringgetFullyQualifiedClassName(org.eclipse.jdt.core.IType type) static StringgetHumanReadableType(String typeSignature) static org.eclipse.jdt.core.IJavaProjectgetJavaProject(String projectName) static org.eclipse.jdt.core.IJavaProjectgetJavaProject(org.eclipse.core.resources.IFile appJar) static StringgetJdtHandleString(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.IJavaProjectgetNamedProject(String projectName) static org.eclipse.jdt.core.dom.ASTNodestatic org.eclipse.jdt.core.dom.ASTNodegetOriginalNode(org.eclipse.jdt.core.dom.ASTNode root, JdtPosition pos) static StringgetPackageName(org.eclipse.jdt.core.ICompilationUnit cu) static org.eclipse.jdt.core.IJavaProjectgetProject(org.eclipse.jdt.core.IJavaElement javaElt) static StringgetProjectName(org.eclipse.jdt.core.IJavaProject javaProject) static org.eclipse.jface.viewers.StructuredSelectiongetStructuredSelectionForProjectNames(Collection<String> projectNames) get aStructuredSelectioncorresponding 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 StringparseForName(String selector, org.eclipse.jdt.core.IType type) static 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). SeeSignaturefor 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 theITypein 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:
IllegalArgumentExceptionorg.eclipse.jdt.core.JavaModelException
-
parseForName
-
parseForParameterTypes
- 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 aStructuredSelectioncorresponding 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)
-