private IJavaProject computeJavaProject(IJavaStackFrame stackFrame) {
ILaunch launch = stackFrame.getLaunch();
if (launch == null) {
return null;
}
ISourceLocator locator = launch.getSourceLocator();
if (locator == null)
return null;
Object sourceElement = null;
try {
if (locator instanceof ISourceLookupDirector
&& !stackFrame.isStatic()) {
IJavaType thisType = stackFrame.getThis().getJavaType();
if (thisType instanceof IJavaReferenceType) {
String[] sourcePaths = ((IJavaReferenceType) thisType)
.getSourcePaths(null);
if (sourcePaths != null && sourcePaths.length > 0) {
sourceElement = ((ISourceLookupDirector) locator)
.getSourceElement(sourcePaths[0]);
}
}
}
} catch (DebugException e) {
DebugPlugin.log(e);
}
if (sourceElement == null) {
sourceElement = locator.getSourceElement(stackFrame);
}
if (!(sourceElement instanceof IJavaElement)
&& sourceElement instanceof IAdaptable) {
Object element = ((IAdaptable) sourceElement)
.getAdapter(IJavaElement.class);