Class JdtUtils
java.lang.Object
com.microsoft.java.debug.plugin.internal.JdtUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.eclipse.jdt.core.IJavaProjectfindProject(StackFrame stackFrame, org.eclipse.debug.core.sourcelookup.ISourceContainer[] containers) Given a stack frame, find the target java project that the associated source file belongs to.static ObjectfindSourceElement(String sourcePath, org.eclipse.debug.core.sourcelookup.ISourceContainer[] containers) Given a source name info, search the associated source file or class file from the source container list.static StringgetDeclaringTypeName(StackFrame frame) Given a stack frame, get the fully qualified type name that associated with the frame.static org.eclipse.jdt.core.IJavaProjectgetJavaProject(String projectName) Given the project name, return the corresponding java project model.static org.eclipse.jdt.core.IJavaProjectgetJavaProject(org.eclipse.core.resources.IProject project) If the project represents a java project, then convert it to a java project.static StringgetModuleName(org.eclipse.jdt.core.IJavaProject project) Returns the module this project represents or null if the Java project doesn't represent any named module.static org.eclipse.core.resources.IProjectgetProject(String projectName) Given the project name, return the corresponding project object.static org.eclipse.debug.core.sourcelookup.ISourceContainer[]getSourceContainers(String projectName) Compute the possible source containers that the specified project could be associated with.static org.eclipse.jdt.core.IPackageFragmentRoot[]getTestPackageFragmentRoots(org.eclipse.jdt.core.IJavaProject project) Compute the fragment roots for each test source folders.static booleanisJavaProject(org.eclipse.core.resources.IProject project) Check if the project is a java project or not.static booleanisSameFile(org.eclipse.core.resources.IResource resource1, org.eclipse.core.resources.IResource resource2) Check whether two resources point to the same physical file.static booleanisTest(org.eclipse.jdt.core.IClasspathEntry classpathEntry) There is an issue on IClasspathEntry#isTest: it will return true if the scope is runtime, so we will this method for testing whether the classpath entry is for test only.static List<org.eclipse.jdt.core.IJavaProject>listJavaProjects(org.eclipse.core.resources.IWorkspaceRoot workspace) List all available Java projects of the specified workspace.
-
Constructor Details
-
JdtUtils
public JdtUtils()
-
-
Method Details
-
getModuleName
Returns the module this project represents or null if the Java project doesn't represent any named module. -
isJavaProject
public static boolean isJavaProject(org.eclipse.core.resources.IProject project) Check if the project is a java project or not. -
getJavaProject
public static org.eclipse.jdt.core.IJavaProject getJavaProject(org.eclipse.core.resources.IProject project) If the project represents a java project, then convert it to a java project. Otherwise, return null. -
getJavaProject
Given the project name, return the corresponding java project model. If the project doesn't exist or not a java project, return null. -
listJavaProjects
public static List<org.eclipse.jdt.core.IJavaProject> listJavaProjects(org.eclipse.core.resources.IWorkspaceRoot workspace) List all available Java projects of the specified workspace. -
getProject
Given the project name, return the corresponding project object. If the project doesn't exist, return null. -
getTestPackageFragmentRoots
public static org.eclipse.jdt.core.IPackageFragmentRoot[] getTestPackageFragmentRoots(org.eclipse.jdt.core.IJavaProject project) Compute the fragment roots for each test source folders.- Parameters:
project- the java project.- Returns:
- the fragment roots for each test source folders.
-
isTest
public static boolean isTest(org.eclipse.jdt.core.IClasspathEntry classpathEntry) There is an issue on IClasspathEntry#isTest: it will return true if the scope is runtime, so we will this method for testing whether the classpath entry is for test only.- Parameters:
classpathEntry- classpath entry- Returns:
- whether this classpath entry is only used in test
-
getSourceContainers
public static org.eclipse.debug.core.sourcelookup.ISourceContainer[] getSourceContainers(String projectName) Compute the possible source containers that the specified project could be associated with.If the project name is specified, it will put the source containers parsed from the specified project's classpath entries in the front of the result, then the other projects at the same workspace.
Otherwise, just loop every projects at the current workspace and combine the parsed source containers directly.
- Parameters:
projectName- the project name.- Returns:
- the possible source container list.
-
findSourceElement
public static Object findSourceElement(String sourcePath, org.eclipse.debug.core.sourcelookup.ISourceContainer[] containers) Given a source name info, search the associated source file or class file from the source container list.- Parameters:
sourcePath- the target source name (e.g. com\microsoft\java\debug\xxx.java).containers- the source container list.- Returns:
- the associated source file or class file.
-
findProject
public static org.eclipse.jdt.core.IJavaProject findProject(StackFrame stackFrame, org.eclipse.debug.core.sourcelookup.ISourceContainer[] containers) Given a stack frame, find the target java project that the associated source file belongs to.- Parameters:
stackFrame- the stack frame.containers- the source container list.- Returns:
- the java project.
-
getDeclaringTypeName
public static String getDeclaringTypeName(StackFrame frame) throws com.microsoft.java.debug.core.DebugException Given a stack frame, get the fully qualified type name that associated with the frame.- Parameters:
frame- the stack frame- Returns:
- the fully qualified type name
- Throws:
com.microsoft.java.debug.core.DebugException- debug exception
-
isSameFile
public static boolean isSameFile(org.eclipse.core.resources.IResource resource1, org.eclipse.core.resources.IResource resource2) Check whether two resources point to the same physical file.
-