/** * 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; }
@Override public boolean filter(IJavaStackFrame frame, IEGLJavaDebugTarget target) { try { return frame.getDeclaringTypeName().startsWith("org.apache."); // $NON-NLS-1$ } catch (DebugException de) { return false; } }
/** * Returns the source name associated with the given object, or <code>null</code> if none. * * @param object an object with an <code>IJavaStackFrame</code> adapter, an IJavaValue or an * IJavaType * @return the source name associated with the given object, or <code>null</code> if none * @exception CoreException if unable to retrieve the source name */ public static String getSourceName(Object object) throws CoreException { if (object instanceof String) { // assume it's a file name return (String) object; } IJavaStackFrame frame = null; if (object instanceof IAdaptable) { frame = ((IAdaptable) object).getAdapter(IJavaStackFrame.class); } String typeName = null; try { if (frame != null) { if (frame.isObsolete()) { return null; } String sourceName = frame.getSourcePath(); // TODO: this may break fix to bug 21518 if (sourceName == null) { // no debug attributes, guess at source name typeName = frame.getDeclaringTypeName(); } else { return sourceName; } } else { if (object instanceof IJavaValue) { // look at its type object = ((IJavaValue) object).getJavaType(); } if (object instanceof IJavaReferenceType) { IJavaReferenceType refType = (IJavaReferenceType) object; IJavaDebugTarget target = ((IJavaDebugTarget) refType.getDebugTarget()); String[] sourcePaths = refType.getSourcePaths(target.getDefaultStratum()); if (sourcePaths != null && sourcePaths.length > 0) { return sourcePaths[0]; } } if (object instanceof IJavaType) { typeName = ((IJavaType) object).getName(); } } } catch (DebugException e) { int code = e.getStatus().getCode(); if (code == IJavaThread.ERR_THREAD_NOT_SUSPENDED || code == IJavaStackFrame.ERR_INVALID_STACK_FRAME || e.getStatus().getException() instanceof VMDisconnectedException) { return null; } throw e; } if (typeName != null) { return generateSourceName(typeName); } return null; }