if (stackFrame == null) {
return null;
}
// find the project the snippets will be compiled in.
ISourceLocator locator = javaValue.getLaunch().getSourceLocator();
Object sourceElement = null;
if (locator instanceof ISourceLookupDirector) {
if (type instanceof JDIReferenceType) {
String[] sourcePaths = ((JDIReferenceType) type)
.getSourcePaths(null);
if (sourcePaths.length > 0) {
sourceElement = ((ISourceLookupDirector) locator)
.getSourceElement(sourcePaths[0]);
}
}
if (!(sourceElement instanceof IJavaElement)
&& sourceElement instanceof IAdaptable) {
sourceElement = ((IAdaptable) sourceElement)
.getAdapter(IJavaElement.class);
}
}
if (sourceElement == null) {
sourceElement = locator.getSourceElement(stackFrame);
if (!(sourceElement instanceof IJavaElement)
&& sourceElement instanceof IAdaptable) {
sourceElement = ((IAdaptable) sourceElement)
.getAdapter(IJavaElement.class);
}