Example #1
0
 /**
  * Resolves and returns a type from the Java model that corresponds to the declaring type of the
  * given stack frame, or <code>null</code> if none.
  *
  * @param frame frame to resolve declaring type for
  * @return corresponding Java model type or <code>null</code>
  * @exception CoreException if an exception occurs during the resolution
  * @since 3.2
  */
 public static IType resolveDeclaringType(IJavaStackFrame frame) throws CoreException {
   IJavaElement javaElement = resolveJavaElement(frame, frame.getLaunch());
   if (javaElement != null) {
     return resolveType(frame.getDeclaringTypeName(), javaElement);
   }
   return null;
 }
 /**
  * Resolves the {@link IJavaProject} within the context of the given {@link IJavaStackFrame}
  *
  * @param frame
  * @return the {@link IJavaProject} or <code>null</code>
  * @since 3.8.0
  */
 public static IJavaProject resolveJavaProject(IJavaStackFrame frame) {
   ILaunch launch = frame.getLaunch();
   if (launch != null) {
     try {
       Object sourceElement = resolveSourceElement(frame, JAVA_STRATUM, launch);
       IJavaElement element = getJavaElement(sourceElement);
       if (element != null) {
         return element.getJavaProject();
       }
       // If Source element is not a Java element
       if (sourceElement instanceof IResource) {
         IJavaProject project = JavaCore.create(((IResource) sourceElement).getProject());
         if (project.exists()) {
           return project;
         }
       }
     } catch (CoreException ce) {
       // do nothing, return null
     }
   }
   return null;
 }