public static IValue getValueByExpression(String expression, IValue value) {
if (!(value instanceof IJavaObject)) {
return null;
}
IJavaObject javaValue = (IJavaObject) value;
try {
IJavaType type = javaValue.getJavaType();
if (!(type instanceof IJavaClassType)) {
return null;
}
IJavaStackFrame stackFrame = getStackFrame(javaValue);
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) {
String[] sourcePaths = ((IJavaClassType) type).getSourcePaths(null);
if (sourcePaths != null && sourcePaths.length > 0) {
sourceElement = ((ISourceLookupDirector) locator).getSourceElement(sourcePaths[0]);