Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Rennie2011-03-22 16:55:23 +0000
committerMichael Rennie2011-03-22 16:55:23 +0000
commit8953d55db8500c9ae298a2993f6191fa537f5e23 (patch)
treef712ecdf15e2635cee425981c7ca56e627bb75b7
parent34d10e604d1e4486e2f677fc3827134ccf9fdfa3 (diff)
downloadeclipse.platform.debug-8953d55db8500c9ae298a2993f6191fa537f5e23.tar.gz
eclipse.platform.debug-8953d55db8500c9ae298a2993f6191fa537f5e23.tar.xz
eclipse.platform.debug-8953d55db8500c9ae298a2993f6191fa537f5e23.zip
Bug 338576 - Add the platform IEvaluationContext as a parent for debug UI IEvaluationContexts
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java23
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/LaunchShortcutAction.java6
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ToggleBreakpointsTargetManager.java22
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/LaunchingResourceManager.java5
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationManager.java7
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/RenderingBindings.java5
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/DetailPaneManager.java7
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ContextualLaunchAction.java5
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchShortcutsAction.java5
9 files changed, 46 insertions, 39 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java
index ca449656f..f917bb3de 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 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
@@ -23,6 +23,8 @@ import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
+import org.eclipse.core.expressions.EvaluationContext;
+import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.core.resources.ISaveContext;
import org.eclipse.core.resources.ISaveParticipant;
import org.eclipse.core.resources.IncrementalProjectBuilder;
@@ -96,6 +98,7 @@ import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.ui.progress.IProgressConstants2;
import org.eclipse.ui.progress.IProgressService;
+import org.eclipse.ui.services.IEvaluationService;
import org.eclipse.ui.themes.IThemeManager;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -1301,5 +1304,23 @@ public class DebugUIPlugin extends AbstractUIPlugin implements ILaunchListener {
}
return ret;
}
+
+ /**
+ * Creates a new {@link IEvaluationContext} initialized with the current platform state if the
+ * {@link IEvaluationService} can be acquired, otherwise the new context is created with no
+ * parent context
+ *
+ * @param defaultvar the default variable for the new context
+ * @return a new {@link IEvaluationContext}
+ * @since 3.7
+ */
+ public static IEvaluationContext createEvaluationContext(Object defaultvar) {
+ IEvaluationContext parent = null;
+ IEvaluationService esrvc = (IEvaluationService)PlatformUI.getWorkbench().getService(IEvaluationService.class);
+ if (esrvc != null) {
+ parent = esrvc.getCurrentState();
+ }
+ return new EvaluationContext(parent, defaultvar);
+ }
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/LaunchShortcutAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/LaunchShortcutAction.java
index 77946cf41..5affdaa8a 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/LaunchShortcutAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/LaunchShortcutAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 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
@@ -15,7 +15,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Set;
-import org.eclipse.core.expressions.EvaluationContext;
import org.eclipse.core.expressions.Expression;
import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.core.resources.IResource;
@@ -31,6 +30,7 @@ import org.eclipse.debug.internal.ui.stringsubstitution.SelectedResourceManager;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.ILaunchGroup;
import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.SWT;
@@ -141,7 +141,7 @@ public class LaunchShortcutAction extends Action {
enabled = !ss.isEmpty();
} else {
List list = ss.toList();
- IEvaluationContext context = new EvaluationContext(null, list);
+ IEvaluationContext context = DebugUIPlugin.createEvaluationContext(list);
context.addVariable("selection", list); //$NON-NLS-1$
enabled = fShortcut.evalEnablementExpression(context, expression);
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ToggleBreakpointsTargetManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ToggleBreakpointsTargetManager.java
index 8bd624fb1..94a7ec940 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ToggleBreakpointsTargetManager.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ToggleBreakpointsTargetManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 Wind River Systems and others.
+ * Copyright (c) 2008, 2011 Wind River Systems 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
@@ -20,11 +20,10 @@ import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import java.util.StringTokenizer;
-import java.util.Map.Entry;
-import org.eclipse.core.expressions.EvaluationContext;
import org.eclipse.core.expressions.EvaluationResult;
import org.eclipse.core.expressions.Expression;
import org.eclipse.core.expressions.ExpressionConverter;
@@ -44,14 +43,13 @@ import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
+import org.eclipse.debug.ui.actions.IToggleBreakpointsTargetExtension;
import org.eclipse.debug.ui.actions.IToggleBreakpointsTargetFactory;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.services.IEvaluationService;
/**
* Organizes the toggle breakpoints target factories contributed through the
@@ -150,20 +148,14 @@ public class ToggleBreakpointsTargetManager {
* Evaluate the given expression within the given context and return
* the result. Returns <code>true</code> iff result is either TRUE.
*
- * @param exp the enablement expression to evaluate or <code>null</code>
- * @param context the context of the evaluation. Usually, the
- * user's selection.
+ * @param part the {@link IWorkbenchPart} context
+ * @param selection the current selection in the part
+ * @param exp the current expression
* @return the result of evaluating the expression
*/
private boolean evalEnablementExpression(IWorkbenchPart part, ISelection selection, Expression exp) {
if (exp != null){
- IEvaluationContext parentContext = null;
- IEvaluationService evaluationService = (IEvaluationService)PlatformUI.getWorkbench().getService(IEvaluationService.class);
- if (evaluationService != null) {
- parentContext = evaluationService.getCurrentState();
- }
- IEvaluationContext context = new EvaluationContext(parentContext, part);
-
+ IEvaluationContext context = DebugUIPlugin.createEvaluationContext(part);
List debugContextList = getDebugContext(part).toList();
context.addVariable(IConfigurationElementConstants.DEBUG_CONTEXT, debugContextList);
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/LaunchingResourceManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/LaunchingResourceManager.java
index 616666342..4c784fcae 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/LaunchingResourceManager.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/LaunchingResourceManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 IBM Corporation and others.
+ * Copyright (c) 2007, 2011 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
@@ -19,7 +19,6 @@ import java.util.List;
import java.util.ListIterator;
import java.util.Set;
-import org.eclipse.core.expressions.EvaluationContext;
import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@@ -443,7 +442,7 @@ public class LaunchingResourceManager implements IPropertyChangeListener, IWindo
if(o instanceof IEditorPart) {
ctxt.set(0, ((IEditorPart)o).getEditorInput());
}
- IEvaluationContext context = new EvaluationContext(null, ctxt);
+ IEvaluationContext context = DebugUIPlugin.createEvaluationContext(ctxt);
context.addVariable("selection", ctxt); //$NON-NLS-1$
LaunchShortcutExtension ext = null;
for(Iterator iter = sc.iterator(); iter.hasNext();) {
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationManager.java
index 6e8b888a9..f00f0e32f 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationManager.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 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
@@ -32,7 +32,6 @@ import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
-import org.eclipse.core.expressions.EvaluationContext;
import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
@@ -702,7 +701,7 @@ public class LaunchConfigurationManager implements ILaunchListener, ISavePartici
if(resource != null) {
ctxt.add(resource);
}
- IEvaluationContext context = new EvaluationContext(null, ctxt);
+ IEvaluationContext context = DebugUIPlugin.createEvaluationContext(ctxt);
context.addVariable("selection", ctxt); //$NON-NLS-1$
LaunchShortcutExtension ext = null;
for(Iterator iter = sc.iterator(); iter.hasNext();) {
@@ -734,7 +733,7 @@ public class LaunchConfigurationManager implements ILaunchListener, ISavePartici
LaunchShortcutExtension ext = null;
List list = new ArrayList();
list.add(resource);
- IEvaluationContext context = new EvaluationContext(null, list);
+ IEvaluationContext context = DebugUIPlugin.createEvaluationContext(list);
context.setAllowPluginActivation(true);
context.addVariable("selection", list); //$NON-NLS-1$
HashSet set = new HashSet();
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/RenderingBindings.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/RenderingBindings.java
index 3a4f15b9f..9a0f2b514 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/RenderingBindings.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/RenderingBindings.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2011 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
@@ -13,7 +13,6 @@ package org.eclipse.debug.internal.ui.memory;
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.core.expressions.EvaluationContext;
import org.eclipse.core.expressions.EvaluationResult;
import org.eclipse.core.expressions.Expression;
import org.eclipse.core.expressions.ExpressionConverter;
@@ -184,7 +183,7 @@ class RenderingBindings extends AbstractMemoryRenderingBindingsProvider implemen
private boolean isBound(IMemoryBlock block) {
Expression expression = getExpression();
if (expression != null) {
- IEvaluationContext context = new EvaluationContext(null, block);
+ IEvaluationContext context = DebugUIPlugin.createEvaluationContext(block);
try {
return expression.evaluate(context) == EvaluationResult.TRUE;
} catch (CoreException e) {
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/DetailPaneManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/DetailPaneManager.java
index 2ea40e9d8..324c299b1 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/DetailPaneManager.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/DetailPaneManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2010 IBM Corporation and others.
+ * Copyright (c) 2006, 2011 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
@@ -18,11 +18,10 @@ import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import java.util.StringTokenizer;
-import java.util.Map.Entry;
-import org.eclipse.core.expressions.EvaluationContext;
import org.eclipse.core.expressions.EvaluationResult;
import org.eclipse.core.expressions.Expression;
import org.eclipse.core.expressions.ExpressionConverter;
@@ -154,7 +153,7 @@ public class DetailPaneManager {
Expression expression = getEnablementExpression();
if (expression != null) {
List list = selection.toList();
- IEvaluationContext context = new EvaluationContext(null, list);
+ IEvaluationContext context = DebugUIPlugin.createEvaluationContext(list);
context.addVariable("selection", list); //$NON-NLS-1$
enabled = evalEnablementExpression(context, expression);
} else {
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ContextualLaunchAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ContextualLaunchAction.java
index 58fce27e4..3a412cdc6 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ContextualLaunchAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ContextualLaunchAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 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
@@ -17,7 +17,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-import org.eclipse.core.expressions.EvaluationContext;
import org.eclipse.core.expressions.Expression;
import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.core.runtime.CoreException;
@@ -208,7 +207,7 @@ public abstract class ContextualLaunchAction implements IObjectActionDelegate, I
if(o instanceof IEditorPart) {
selection.set(0, ((IEditorPart)o).getEditorInput());
}
- IEvaluationContext context = new EvaluationContext(null, selection);
+ IEvaluationContext context = DebugUIPlugin.createEvaluationContext(selection);
context.setAllowPluginActivation(true);
context.addVariable("selection", selection); //$NON-NLS-1$
while (iter.hasNext()) {
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchShortcutsAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchShortcutsAction.java
index 620654db4..a596253cf 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchShortcutsAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchShortcutsAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 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
@@ -16,7 +16,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Set;
-import org.eclipse.core.expressions.EvaluationContext;
import org.eclipse.core.expressions.Expression;
import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.core.runtime.CoreException;
@@ -144,7 +143,7 @@ public class LaunchShortcutsAction extends Action implements IMenuCreator, IWork
else {
list.addAll(ss.toList());
}
- IEvaluationContext context = new EvaluationContext(null, list);
+ IEvaluationContext context = DebugUIPlugin.createEvaluationContext(list);
context.setAllowPluginActivation(true);
context.addVariable("selection", list); //$NON-NLS-1$
return context;

Back to the top