use of org.eclipse.jdt.debug.core.IJavaType in project xtext-eclipse by eclipse.
the class XbaseLineBreakpoint method computeJavaProject.
// old working implementation copied from 3.8
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);
if (element != null) {
sourceElement = element;
}
}
if (sourceElement instanceof IJavaElement) {
return ((IJavaElement) sourceElement).getJavaProject();
} else if (sourceElement instanceof IResource) {
IJavaProject project = JavaCore.create(((IResource) sourceElement).getProject());
if (project.exists()) {
return project;
}
}
return null;
}
Aggregations