try {
IJavaReferenceType type = getType(javaValue);
if (type == null) {
return value;
}
IJavaStackFrame stackFrame = getStackFrame(javaValue);
if (stackFrame == null) {
return value;
}
// find the project the snippets will be compiled in.
ISourceLocator locator = javaValue.getLaunch().getSourceLocator();
Object sourceElement = null;
if (locator instanceof ISourceLookupDirector) {
String[] sourcePaths = type.getSourcePaths(null);
if (sourcePaths != null && 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);
}
}
IJavaProject project = null;
if (sourceElement instanceof IJavaElement) {
project = ((IJavaElement) sourceElement).getJavaProject();
} else if (sourceElement instanceof IResource) {
IJavaProject resourceProject = JavaCore
.create(((IResource) sourceElement).getProject());
if (resourceProject.exists()) {
project = resourceProject;
}
}
if (project == null) {
return value;
}
IAstEvaluationEngine evaluationEngine = JDIDebugPlugin.getDefault()
.getEvaluationEngine(project,
(IJavaDebugTarget) stackFrame.getDebugTarget());
EvaluationBlock evaluationBlock = new EvaluationBlock(javaValue,
type, (IJavaThread) stackFrame.getThread(),
evaluationEngine);
if (fValue == null) {
// evaluate each variable
IJavaVariable[] variables = new IJavaVariable[fVariables.length];
for (int i = 0; i < fVariables.length; i++) {