Bug 492439 - “Display” view can not execute code if your current
stack-element is inside a JSP
Change-Id: I9dc4b3b7edf48dd6beb0ff0eeaf4a9a8d2d41f19
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/EvaluateAction.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/EvaluateAction.java
index 35713c7..6da14de 100644
--- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/EvaluateAction.java
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/EvaluateAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -29,7 +29,6 @@
import org.eclipse.debug.ui.IDebugModelPresentation;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.debug.ui.IDebugView;
-import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.debug.core.IJavaDebugTarget;
import org.eclipse.jdt.debug.core.IJavaObject;
@@ -237,9 +236,8 @@
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
if (stackFrame.isSuspended()) {
- IJavaElement javaElement= getJavaElement(stackFrame);
- if (javaElement != null) {
- IJavaProject project = javaElement.getJavaProject();
+ IJavaProject project = getJavaProject(stackFrame);
+ if (project != null) {
IEvaluationEngine engine = null;
try {
Object selection= getSelectedObject();
@@ -292,19 +290,18 @@
}
}
- protected IJavaElement getJavaElement(IStackFrame stackFrame) {
+ protected IJavaProject getJavaProject(IStackFrame stackFrame) {
// Get the corresponding element.
ILaunch launch = stackFrame.getLaunch();
if (launch == null) {
return null;
}
- try {
- return JavaDebugUtils.resolveJavaElement(stackFrame, launch);
+ IJavaProject javaProject = null;
+ if (stackFrame instanceof IJavaStackFrame) {
+ javaProject = JavaDebugUtils.resolveJavaProject((IJavaStackFrame) stackFrame);
}
- catch (CoreException e) {
- return null;
- }
+ return javaProject;
}
/**
diff --git a/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/JavaDebugUtils.java b/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/JavaDebugUtils.java
index 9a6154f..0cd5809 100644
--- a/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/JavaDebugUtils.java
+++ b/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/JavaDebugUtils.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2015 IBM Corporation and others.
+ * Copyright (c) 2005, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -303,8 +303,14 @@
* @throws CoreException if an exception occurs
*/
public static IJavaElement resolveJavaElement(Object object, ILaunch launch) throws CoreException {
- Object sourceElement = resolveSourceElement(object, JAVA_STRATUM, launch);
- return getJavaElement(sourceElement);
+ Object sourceElement = resolveSourceElement(object, launch);
+ IJavaElement javaElement = getJavaElement(sourceElement);
+ if (javaElement == null) {
+ // fallback if default stratum does not provide a Java element
+ sourceElement = resolveSourceElement(object, JAVA_STRATUM, launch);
+ javaElement = getJavaElement(sourceElement);
+ }
+ return javaElement;
}
/**
@@ -403,8 +409,15 @@
ILaunch launch = frame.getLaunch();
if(launch != null) {
try {
- Object sourceElement = resolveSourceElement(frame, JAVA_STRATUM, launch);
+ Object sourceElement = resolveSourceElement(frame, launch);
IJavaElement element = getJavaElement(sourceElement);
+ if (element == null) {
+ Object sourceElement1 = resolveSourceElement(frame, JAVA_STRATUM, launch);
+ if (sourceElement1 != null){
+ sourceElement = sourceElement1;
+ element = getJavaElement(sourceElement);
+ }
+ }
if(element != null) {
return element.getJavaProject();
}