java.lang.Object
com.microsoft.java.debug.plugin.internal.JdtUtils

public class JdtUtils extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    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.
    static String
    Given a stack frame, get the fully qualified type name that associated with the frame.
    static org.eclipse.jdt.core.IJavaProject
    getJavaProject(String projectName)
    Given the project name, return the corresponding java project model.
    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.
    static String
    getModuleName(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.IProject
    getProject(String projectName)
    Given the project name, return the corresponding project object.
    static org.eclipse.debug.core.sourcelookup.ISourceContainer[]
    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 boolean
    isJavaProject(org.eclipse.core.resources.IProject project)
    Check if the project is a java project or not.
    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.
    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.
    static List<org.eclipse.jdt.core.IJavaProject>
    listJavaProjects(org.eclipse.core.resources.IWorkspaceRoot workspace)
    List all available Java projects of the specified workspace.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • JdtUtils

      public JdtUtils()
  • Method Details

    • getModuleName

      public static String getModuleName(org.eclipse.jdt.core.IJavaProject project)
      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

      public static org.eclipse.jdt.core.IJavaProject getJavaProject(String projectName)
      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

      public static org.eclipse.core.resources.IProject getProject(String projectName)
      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.