Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Tarassov2012-06-11 23:36:51 +0000
committerEugene Tarassov2012-06-12 00:05:49 +0000
commit717517dcf250e01f25e19ad6e863fea623457527 (patch)
tree785be4dd8d30f46165d97a254b5d6c09415ed178
parentd4fce15928897a3cb0c9757ea5abf50a93c49051 (diff)
downloadorg.eclipse.tcf-717517dcf250e01f25e19ad6e863fea623457527.tar.gz
org.eclipse.tcf-717517dcf250e01f25e19ad6e863fea623457527.tar.xz
org.eclipse.tcf-717517dcf250e01f25e19ad6e863fea623457527.zip
TCF Debugger: code cleanup, TCFContextQueryDescendants is converted to a function that implements ACPM transaction
-rw-r--r--plugins/org.eclipse.tcf.cdt.ui/plugin.xml4
-rw-r--r--plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFBreakpointScopeDetailPane.java113
-rw-r--r--plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFThreadFilterEditor.java4
-rw-r--r--plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/adapters/TCFLaunchLabelProvider.java46
-rw-r--r--plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFChildrenContextQuery.java155
-rw-r--r--plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFContextQueryDescendants.java85
-rw-r--r--plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFModel.java52
-rw-r--r--plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeExecContext.java163
-rw-r--r--plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeLaunch.java30
-rw-r--r--plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/model/TCFLaunch.java23
10 files changed, 227 insertions, 448 deletions
diff --git a/plugins/org.eclipse.tcf.cdt.ui/plugin.xml b/plugins/org.eclipse.tcf.cdt.ui/plugin.xml
index cb2668b4b..c3d8fdf18 100644
--- a/plugins/org.eclipse.tcf.cdt.ui/plugin.xml
+++ b/plugins/org.eclipse.tcf.cdt.ui/plugin.xml
@@ -451,7 +451,7 @@
</visibleWhen>
</command>
</menuContribution>
-
+
</extension>
<extension point="org.eclipse.debug.ui.detailPaneFactories">
<detailFactories
@@ -478,5 +478,5 @@
</enablement>
</detailFactories>
</extension>
-
+
</plugin>
diff --git a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFBreakpointScopeDetailPane.java b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFBreakpointScopeDetailPane.java
index 6f201090e..770ca1d13 100644
--- a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFBreakpointScopeDetailPane.java
+++ b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFBreakpointScopeDetailPane.java
@@ -12,6 +12,7 @@ package org.eclipse.tcf.internal.cdt.ui.breakpoints;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
@@ -52,17 +53,17 @@ import org.eclipse.tcf.debug.ui.ITCFDebugUIConstants;
import org.eclipse.tcf.internal.cdt.ui.ImageCache;
import org.eclipse.tcf.internal.debug.model.ITCFConstants;
import org.eclipse.tcf.internal.debug.model.TCFLaunch;
-import org.eclipse.tcf.internal.debug.ui.model.TCFContextQueryDescendants;
+import org.eclipse.tcf.internal.debug.ui.model.TCFChildrenContextQuery;
import org.eclipse.tcf.internal.debug.ui.model.TCFModel;
import org.eclipse.tcf.internal.debug.ui.model.TCFModelManager;
import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.ui.IWorkbenchPartSite;
/**
- * This detail pane uses a tree viewer to show which contexts a given breakpoint
+ * This detail pane uses a tree viewer to show which contexts a given breakpoint
* can potentially trigger.
*/
-@SuppressWarnings("restriction")
+@SuppressWarnings("restriction")
public class TCFBreakpointScopeDetailPane implements IDetailPane {
public static final String ID = "org.eclipse.tcf.debug.DetailPaneFactory";
@@ -70,17 +71,17 @@ public class TCFBreakpointScopeDetailPane implements IDetailPane {
public static final String DESC = "TCF Detail Pane";
private Composite fComposite;
- private Label fFilterName;
+ private Label fFilterName;
private TreeModelViewer fTreeViewer;
public static class ScopeDetailInputObject extends PlatformObject implements IElementContentProvider, IModelProxyFactory {
-
+
private final ContextQueryElement fContextQueryElement;
-
+
public ScopeDetailInputObject(ContextQueryElement query) {
fContextQueryElement = query;
}
-
+
@Override
public boolean equals(Object other) {
if (other instanceof ScopeDetailInputObject) {
@@ -88,19 +89,19 @@ public class TCFBreakpointScopeDetailPane implements IDetailPane {
}
return false;
}
-
+
@Override
public int hashCode() {
return fContextQueryElement.hashCode();
}
-
+
public void update(IChildrenCountUpdate[] updates) {
for (IChildrenCountUpdate update : updates) {
update.setChildCount(1);
update.done();
}
}
-
+
public void update(IChildrenUpdate[] updates) {
for (IChildrenUpdate update : updates) {
if (update.getOffset() == 0) {
@@ -109,14 +110,14 @@ public class TCFBreakpointScopeDetailPane implements IDetailPane {
}
}
}
-
+
public void update(IHasChildrenUpdate[] updates) {
for (IHasChildrenUpdate update : updates) {
update.setHasChilren(true);
update.done();
}
}
-
+
public IModelProxy createModelProxy(Object element, IPresentationContext context) {
return new AbstractModelProxy() {
@Override
@@ -129,59 +130,59 @@ public class TCFBreakpointScopeDetailPane implements IDetailPane {
};
}
}
-
- public static class ContextQueryElement extends PlatformObject
- implements IElementContentProvider, IElementLabelProvider, IModelProxyFactory
+
+ public static class ContextQueryElement extends PlatformObject
+ implements IElementContentProvider, IElementLabelProvider, IModelProxyFactory
{
private final String fQuery;
private Set<String> fContexts;
-
+
public ContextQueryElement(String query, Set<String> contexts) {
fQuery = query;
fContexts = contexts;
}
-
+
@Override
public boolean equals(Object other) {
if (other instanceof ContextQueryElement) {
ContextQueryElement element = (ContextQueryElement)other;
- return ((fQuery == null && element.fQuery == null) ||
+ return ((fQuery == null && element.fQuery == null) ||
(fQuery != null && fQuery.equals(element.fQuery))) &&
- ((fContexts == null && element.fContexts == null) ||
+ ((fContexts == null && element.fContexts == null) ||
(fContexts != null && fContexts.equals(element.fContexts)));
}
return false;
}
-
+
@Override
public int hashCode() {
return (fQuery != null ? fQuery.hashCode() : 0) + (fContexts != null ? fContexts.hashCode() : 0);
}
-
+
public void update(IChildrenCountUpdate[] updates) {
for (IViewerUpdate update : updates) {
getFilteredLaunches(update);
}
}
-
+
public void update(IChildrenUpdate[] updates) {
for (IViewerUpdate update : updates) {
getFilteredLaunches(update);
}
}
-
+
public void update(IHasChildrenUpdate[] updates) {
for (IViewerUpdate update : updates) {
getFilteredLaunches(update);
}
}
-
+
public void update(ILabelUpdate[] updates) {
for (ILabelUpdate update : updates) {
getQueryFilteredContexts(update);
}
}
-
+
private List<TCFLaunch> getTCFLaunches() {
List<TCFLaunch> tcfLaunches = new ArrayList<TCFLaunch>();
for (ILaunch launch : DebugPlugin.getDefault().getLaunchManager().getLaunches()) {
@@ -192,7 +193,7 @@ public class TCFBreakpointScopeDetailPane implements IDetailPane {
return tcfLaunches;
}
-
+
private void getFilteredLaunches (final IViewerUpdate update) {
Protocol.invokeLater( new Runnable() {
public void run() {
@@ -201,15 +202,13 @@ public class TCFBreakpointScopeDetailPane implements IDetailPane {
for (TCFLaunch launch : getTCFLaunches()) {
TCFModel model = modelManager.getModel(launch);
if (model != null && model.getRootNode() != null) {
- TCFContextQueryDescendants query_descendants = model.getRootNode().getContextQueryDescendants();
- if (!query_descendants.setQuery(fQuery, launch.getModelContexts(fContexts), this)) return;
- if (!query_descendants.validate(this)) return;
- if (query_descendants.getData() != null && !query_descendants.getData().isEmpty()) {
- filteredLaunches.add(launch);
- }
+ TCFChildrenContextQuery.Descendants des = TCFChildrenContextQuery.getDescendants(
+ model.getRootNode(), fQuery, fContexts, this);
+ if (des == null) return;
+ if (des.map != null && des.map.size() > 0) filteredLaunches.add(launch);
}
}
-
+
done(filteredLaunches, update);
}
});
@@ -219,31 +218,29 @@ public class TCFBreakpointScopeDetailPane implements IDetailPane {
Protocol.invokeLater( new Runnable() {
public void run() {
TCFModelManager modelManager = TCFModelManager.getModelManager();
- Set<String> set = new TreeSet<String>();
+ Set<String> descendants = new HashSet<String>();
for (TCFLaunch launch : getTCFLaunches()) {
TCFModel model = modelManager.getModel(launch);
if (model != null && model.getRootNode() != null) {
- TCFContextQueryDescendants query_descendants = model.getRootNode().getContextQueryDescendants();
- if (!query_descendants.setQuery(fQuery, launch.getModelContexts(fContexts), this)) return;
- if (!query_descendants.validate(this)) return;
- if (query_descendants.getData() != null) {
- set.addAll(query_descendants.getData());
- }
+ TCFChildrenContextQuery.Descendants des = TCFChildrenContextQuery.getDescendants(
+ model.getRootNode(), fQuery, fContexts, this);
+ if (des == null) return;
+ if (des.map != null) descendants.addAll(des.map.keySet());
}
}
-
+
StringBuffer label = new StringBuffer();
label.append("(");
- label.append(set.size());
+ label.append(descendants.size());
label.append(") ");
-
+
if (fQuery != null) {
label.append("Filter: ");
label.append(fQuery);
if (fContexts != null) {
label.append(", ");
}
- }
+ }
if (fContexts != null) {
label.append("Contexts: ");
label.append(fContexts);
@@ -254,7 +251,7 @@ public class TCFBreakpointScopeDetailPane implements IDetailPane {
}
});
}
-
+
private void done(List<TCFLaunch> launches, IViewerUpdate update) {
if (update instanceof IHasChildrenUpdate) {
((IHasChildrenUpdate)update).setHasChilren(!launches.isEmpty());
@@ -270,7 +267,7 @@ public class TCFBreakpointScopeDetailPane implements IDetailPane {
}
update.done();
}
-
+
public IModelProxy createModelProxy(Object element, IPresentationContext context) {
return new QueryInputObjectProxy();
}
@@ -288,7 +285,7 @@ public class TCFBreakpointScopeDetailPane implements IDetailPane {
fLaunchManager = DebugPlugin.getDefault().getLaunchManager();
fLaunchManager.addLaunchListener(this);
}
-
+
/* (non-Javadoc)
* @see org.eclipse.debug.internal.ui.viewers.provisional.AbstractModelProxy#installed(org.eclipse.jface.viewers.Viewer)
*/
@@ -334,11 +331,11 @@ public class TCFBreakpointScopeDetailPane implements IDetailPane {
/* (non-Javadoc)
* @see org.eclipse.debug.core.ILaunchesListener#launchesChanged(org.eclipse.debug.core.ILaunch[])
*/
- public void launchesChanged(ILaunch[] launches) {
+ public void launchesChanged(ILaunch[] launches) {
}
-
+
/**
- * Convenience method for firing a delta
+ * Convenience method for firing a delta
* @param launches the launches to set in the delta
* @param launchFlags the flags for the delta
*/
@@ -349,11 +346,11 @@ public class TCFBreakpointScopeDetailPane implements IDetailPane {
delta.addNode(launches[i], launchFlags);
}
}
- fireModelChanged(delta);
+ fireModelChanged(delta);
}
}
-
+
public Control createControl(Composite parent) {
fComposite = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_BOTH);
fFilterName = SWTFactory.createLabel(fComposite, "Scope", 1);
@@ -364,13 +361,13 @@ public class TCFBreakpointScopeDetailPane implements IDetailPane {
control.setLayoutData(treeLayoutData);
GridData gd = new GridData(GridData.FILL_BOTH);
control.setLayoutData(gd);
-
+
return fComposite;
}
public void display(IStructuredSelection selection) {
if (fTreeViewer == null) return;
-
+
TCFBreakpointScopeExtension extension = getTCFBreakpointScopeExtension((ICBreakpoint)selection.getFirstElement());
if (extension != null) {
String filter = extension.getPropertiesFilter();
@@ -378,10 +375,10 @@ public class TCFBreakpointScopeDetailPane implements IDetailPane {
filter = null;
}
String[] contexts = extension.getThreadFilters();
-
+
if (filter != null || contexts != null) {
fFilterName.setText("Scope");
- Set<String> contextsSet = contexts != null ? new TreeSet<String>(Arrays.asList(contexts)) : null;
+ Set<String> contextsSet = contexts != null ? new TreeSet<String>(Arrays.asList(contexts)) : null;
fTreeViewer.setInput( new ScopeDetailInputObject(
new ContextQueryElement(filter, contextsSet)) );
fTreeViewer.getPresentationContext().setProperty(ITCFDebugUIConstants.PROP_CONTEXT_QUERY, filter);
@@ -393,7 +390,7 @@ public class TCFBreakpointScopeDetailPane implements IDetailPane {
fFilterName.setText("No scope specified.");
fTreeViewer.setInput(null);
fTreeViewer.getPresentationContext().setProperty(ITCFDebugUIConstants.PROP_CONTEXT_QUERY, null);
- fTreeViewer.getPresentationContext().setProperty(ITCFDebugUIConstants.PROP_FILTER_CONTEXTS, null);
+ fTreeViewer.getPresentationContext().setProperty(ITCFDebugUIConstants.PROP_FILTER_CONTEXTS, null);
}
private TCFBreakpointScopeExtension getTCFBreakpointScopeExtension(ICBreakpoint bp) {
@@ -404,7 +401,7 @@ public class TCFBreakpointScopeDetailPane implements IDetailPane {
} catch (CoreException e) {}
return null;
}
-
+
public void dispose() {
if (fTreeViewer != null) {
fTreeViewer.getControl().dispose();
diff --git a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFThreadFilterEditor.java b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFThreadFilterEditor.java
index 1ee2a6205..bf6b66f40 100644
--- a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFThreadFilterEditor.java
+++ b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFThreadFilterEditor.java
@@ -18,9 +18,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.eclipse.cdt.debug.core.model.ICBreakpoint;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
@@ -59,7 +56,6 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.tcf.internal.cdt.ui.Activator;
import org.eclipse.tcf.internal.cdt.ui.ImageCache;
import org.eclipse.tcf.internal.cdt.ui.preferences.BreakpointPreferencePage;
-import org.eclipse.tcf.internal.debug.model.TCFBreakpointsModel;
import org.eclipse.tcf.internal.debug.model.TCFLaunch;
import org.eclipse.tcf.internal.debug.ui.model.TCFChildren;
import org.eclipse.tcf.internal.debug.ui.model.TCFModel;
diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/adapters/TCFLaunchLabelProvider.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/adapters/TCFLaunchLabelProvider.java
index 4a28eab82..43ed030fb 100644
--- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/adapters/TCFLaunchLabelProvider.java
+++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/adapters/TCFLaunchLabelProvider.java
@@ -12,7 +12,6 @@ package org.eclipse.tcf.internal.debug.ui.adapters;
import java.util.Collection;
import java.util.Map;
-import java.util.Set;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider;
@@ -23,7 +22,7 @@ import org.eclipse.swt.graphics.RGB;
import org.eclipse.tcf.debug.ui.ITCFDebugUIConstants;
import org.eclipse.tcf.internal.debug.model.TCFLaunch;
import org.eclipse.tcf.internal.debug.ui.ImageCache;
-import org.eclipse.tcf.internal.debug.ui.model.TCFContextQueryDescendants;
+import org.eclipse.tcf.internal.debug.ui.model.TCFChildrenContextQuery;
import org.eclipse.tcf.internal.debug.ui.model.TCFModel;
import org.eclipse.tcf.internal.debug.ui.model.TCFModelManager;
import org.eclipse.tcf.protocol.Protocol;
@@ -36,12 +35,13 @@ class TCFLaunchLabelProvider implements IElementLabelProvider {
String view_id = updates[i].getPresentationContext().getId();
if (ITCFDebugUIConstants.ID_CONTEXT_QUERY_VIEW.equals(view_id)) {
updateContextQueryViewLabel(updates[i]);
- } else {
+ }
+ else {
updateDebugViewLabel(updates[i]);
}
}
}
-
+
private void updateDebugViewLabel(ILabelUpdate result) {
final TCFLaunch launch = (TCFLaunch)result.getElement();
ImageDescriptor image = DebugUITools.getDefaultImageDescriptor(launch);
@@ -91,7 +91,7 @@ class TCFLaunchLabelProvider implements IElementLabelProvider {
result.setLabel(name + status, 0);
result.done();
}
-
+
private void updateContextQueryViewLabel(final ILabelUpdate result) {
Protocol.invokeLater(new Runnable() {
public void run() {
@@ -102,28 +102,23 @@ class TCFLaunchLabelProvider implements IElementLabelProvider {
StringBuffer label = new StringBuffer();
TCFModel model = TCFModelManager.getModelManager().getModel(launch);
-
+
if (model != null && model.getRootNode() != null) {
- String query = (String)result.getPresentationContext().getProperty(ITCFDebugUIConstants.PROP_CONTEXT_QUERY);
- @SuppressWarnings("unchecked")
- Set<String> contexts = (Set<String>)result.getPresentationContext().getProperty(ITCFDebugUIConstants.PROP_FILTER_CONTEXTS);
- TCFContextQueryDescendants query_descendents = model.getRootNode().getContextQueryDescendants();
- if (!query_descendents.setQuery(query, model.getLaunch().getModelContexts(contexts), this)) return;
- if (!query_descendents.validate(this)) return;
- if (query_descendents.getError() == null) {
- Set<String> descendants = query_descendents.getData();
- if (descendants != null && !descendants.isEmpty()) {
- label.append("(");
- label.append(descendants.size());
- label.append(") ");
- }
+ TCFChildrenContextQuery.Descendants des = TCFChildrenContextQuery.getDescendants(
+ model.getRootNode(), result, this);
+ if (des == null) return;
+ if (des.map != null && des.map.size() > 0) {
+ label.append("(");
+ label.append(des.map.size());
+ label.append(") ");
}
- }
-
+ }
+
ILaunchConfiguration cfg = launch.getLaunchConfiguration();
if (cfg != null) {
label.append( cfg.getName() );
- } else {
+ }
+ else {
label.append("?");
}
@@ -132,13 +127,12 @@ class TCFLaunchLabelProvider implements IElementLabelProvider {
label.append(" (");
label.append(peer_name);
label.append(")");
- }
-
+ }
+
result.setLabel(label.toString(), 0);
result.done();
}
});
-
- }
+ }
}
diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFChildrenContextQuery.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFChildrenContextQuery.java
index 506266f9f..63e3db810 100644
--- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFChildrenContextQuery.java
+++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFChildrenContextQuery.java
@@ -10,12 +10,15 @@
*******************************************************************************/
package org.eclipse.tcf.internal.debug.ui.model;
-import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate;
+import org.eclipse.tcf.debug.ui.ITCFDebugUIConstants;
import org.eclipse.tcf.util.TCFDataCache;
/**
@@ -26,14 +29,8 @@ import org.eclipse.tcf.util.TCFDataCache;
*/
public class TCFChildrenContextQuery extends TCFChildren {
- private final TCFChildren children;
-
- private String[] query_data;
- private Set<String> filter;
-
- TCFChildrenContextQuery(TCFNode node, TCFChildren children) {
+ TCFChildrenContextQuery(TCFNode node) {
super(node);
- this.children = children;
}
@Override
@@ -42,53 +39,135 @@ public class TCFChildrenContextQuery extends TCFChildren {
super.dispose();
}
- boolean setQuery(String query, Set<String> filter, Runnable done) {
- String[] query_data = null;
- TCFDataCache<String[]> query_cache = node.getModel().getLaunch().getContextQuery(query);
- if (query_cache != null) {
- if (!query_cache.validate(done)) return false;
- query_data = query_cache.getData();
+ public static class Descendants {
+ public Map<String,String> map;
+ public boolean include_parent;
+ }
+
+ private static String[] getFilterIDs(TCFModel model, Set<String> filter) {
+ if (filter != null) {
+ ILaunchConfiguration launchConfig = model.getLaunch().getLaunchConfiguration();
+ if (launchConfig != null) {
+ Set<String> set = new HashSet<String>();
+ String sessionId = launchConfig.getName();
+ for (String context : filter) {
+ int slashPos = context.indexOf('/');
+ if (slashPos > 0 && context.length() > slashPos + 1) {
+ if ( sessionId.equals(context.substring(0, slashPos)) ) {
+ set.add(context.substring(slashPos + 1));
+ }
+ }
+ }
+ return set.toArray(new String[set.size()]);
+ }
}
- if (!Arrays.equals(query_data, this.query_data)) reset();
- this.query_data = query_data;
- if (this.filter == filter) return true;
- if (filter != null && filter.equals(this.filter)) return true;
- this.filter = filter;
- reset();
- return true;
+ return null;
}
- private boolean retainAll(Map<String,TCFNode> map, String[] ids) {
+ private static boolean getDescendants(TCFNode node, String[] ids, Descendants res, Runnable done) {
+ Map<String,String> map = res.map;
+ boolean include_parent = res.include_parent;
+ res.map = new HashMap<String,String>();
TCFModel model = node.getModel();
- Set<String> set = new HashSet<String>();
for (String id : ids) {
- if (!model.createNode(id, this)) return false;
- if (isValid()) return true; // error creating a node
+ assert !(done instanceof TCFDataCache<?>);
+ if (!model.createNode(id, done)) return false;
TCFNode n = model.getNode(id);
while (n != null) {
- if (n.parent == node || (n.parent == null && !(node instanceof TCFNodeExecContext))) {
- set.add(n.getID());
+ if (n == node) {
+ res.include_parent = true;
break;
}
+ if (n.parent == node) {
+ res.map.put(id, n.id);
+ break;
+ }
n = n.parent;
}
}
- map.keySet().retainAll(set);
+ if (map != null) {
+ res.map.keySet().retainAll(map.keySet());
+ res.include_parent = res.include_parent && include_parent;
+ }
return true;
}
- @Override
- protected boolean startDataRetrieval() {
- if (!children.validate(this)) return false;
+ /**
+ * Get node descendants that match both query and filter.
+ * If both query and filter are null, return empty map.
+ * The map maps descendant ID to the node child ID.
+ */
+ public static Descendants getDescendants(TCFNode node, String query, Set<String> filter, Runnable done) {
+ Descendants res = new Descendants();
+
+ String[] query_data = null;
+ TCFDataCache<String[]> query_cache = node.getModel().getLaunch().getContextQuery(query);
+ if (query_cache != null) {
+ if (!query_cache.validate(done)) return null;
+ query_data = query_cache.getData();
+ if (query_data != null && !getDescendants(node, query_data, res, done)) return null;
+ }
+
+ String[] filter_ids = getFilterIDs(node.getModel(), filter);
+ if (filter_ids != null && !getDescendants(node, filter_ids, res, done)) return null;
+
+ return res;
+ }
+
+ /**
+ * Get node descendants that match both query and filter in presentation context of given update.
+ * If both query and filter are null, return empty map.
+ * The map maps descendant ID to the node child ID.
+ */
+ @SuppressWarnings("unchecked")
+ public static Descendants getDescendants(TCFNode node, IViewerUpdate update, Runnable done) {
+ IPresentationContext context = update.getPresentationContext();
+ String query = (String)context.getProperty(ITCFDebugUIConstants.PROP_CONTEXT_QUERY);
+ Set<String> filter = (Set<String>)context.getProperty(ITCFDebugUIConstants.PROP_FILTER_CONTEXTS);
+ return getDescendants(node, query, filter, done);
+ }
+
+ /**
+ * Get node children which descendants match both query and filter in presentation context of given update.
+ * If both query and filter are null, return unfiltered children list.
+ */
+ @SuppressWarnings("unchecked")
+ boolean setQuery(IViewerUpdate update, Runnable done) {
+ IPresentationContext context = update.getPresentationContext();
+ String query = (String)context.getProperty(ITCFDebugUIConstants.PROP_CONTEXT_QUERY);
+ Set<String> filter = (Set<String>)context.getProperty(ITCFDebugUIConstants.PROP_FILTER_CONTEXTS);
Map<String,TCFNode> map = new HashMap<String,TCFNode>();
- if (children.size() > 0) {
- for (TCFNode n : children.toArray()) map.put(n.id, n);
- if (query_data != null && !retainAll(map, query_data)) return false;
- if (isValid()) return true; // error creating a node
- if (filter != null && !retainAll(map, filter.toArray(new String[filter.size()]))) return false;
- if (isValid()) return true; // error creating a node
+
+ TCFChildren cache = null;
+ if (node instanceof TCFNodeExecContext) cache = ((TCFNodeExecContext)node).getChildren();
+ else if (node instanceof TCFNodeLaunch) cache = ((TCFNodeLaunch)node).getChildren();
+
+ if (cache != null) {
+ if (!cache.validate(done)) return false;
+ Map<String,TCFNode> cache_data = cache.getData();
+ if (cache_data != null && cache_data.size() > 0) {
+ if (query != null || filter != null) {
+ Descendants des = getDescendants(node, query, filter, done);
+ if (des == null) return false;
+ for (String id : des.map.values()) {
+ TCFNode n = cache_data.get(id);
+ if (n != null) map.put(id, n);
+ }
+ }
+ else {
+ map.putAll(cache_data);
+ }
+ }
}
- set(null, children.getError(), map);
+
+ reset(map);
+ return true;
+ }
+
+ @Override
+ protected boolean startDataRetrieval() {
+ // The method should not be called - the cache is always valid
+ assert false;
return true;
}
}
diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFContextQueryDescendants.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFContextQueryDescendants.java
deleted file mode 100644
index 6a283895d..000000000
--- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFContextQueryDescendants.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.internal.debug.ui.model;
-
-import java.util.Arrays;
-import java.util.Set;
-import java.util.TreeSet;
-
-import org.eclipse.tcf.util.TCFDataCache;
-
-/**
- * Cache item that contains children of the node.
- * The list of children is filtered according to the context query and context filter.
- * An element in the list either matches both query and filter,
- * or it is an ancestor of a matching node.
- */
-public class TCFContextQueryDescendants extends TCFDataCache<Set<String>> {
-
- private final TCFNode node;
-
- private String[] query_data;
- private Set<String> filter;
-
- TCFContextQueryDescendants(TCFNode node) {
- super(node.getChannel());
- this.node = node;
- }
-
- public boolean setQuery(String query, Set<String> filter, Runnable done) {
- String[] query_data = null;
- TCFDataCache<String[]> query_cache = node.getModel().getLaunch().getContextQuery(query);
- if (query_cache != null) {
- if (!query_cache.validate(done)) return false;
- query_data = query_cache.getData();
- }
- if (!Arrays.equals(query_data, this.query_data)) reset();
- this.query_data = query_data;
- if (this.filter == filter) return true;
- if (filter != null && filter.equals(this.filter)) return true;
- this.filter = filter;
- reset();
- return true;
- }
-
- private boolean getDescendants(Set<String> descendants, String[] ids) {
- TCFModel model = node.getModel();
- for (String id : ids) {
- if (!model.createNode(id, this)) return false;
- if (isValid()) return true; // error creating a node
- TCFNode n = model.getNode(id);
- while (n != null) {
- if ( n.parent == node || (n.parent == null && !(node instanceof TCFNodeExecContext)) ) {
- descendants.add(id);
- break;
- }
- n = n.parent;
- }
- }
- return true;
- }
-
-
- @Override
- protected boolean startDataRetrieval() {
- Set<String> set = new TreeSet<String>();
- if (query_data != null && !getDescendants(set, query_data)) return false;
- if (isValid()) return true; // error creating a node
- if (filter != null) {
- Set<String> filtered = new TreeSet<String>();
- if (!getDescendants(filtered, filter.toArray(new String[filter.size()]))) return false;
- set.retainAll(filtered);
- }
- if (isValid()) return true; // error creating a node
- set(null, null, set);
- return true;
- }
-}
diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFModel.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFModel.java
index 7afef674a..559f43dcd 100644
--- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFModel.java
+++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFModel.java
@@ -11,7 +11,6 @@
package org.eclipse.tcf.internal.debug.ui.model;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
@@ -19,8 +18,6 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.TreeMap;
-import java.util.TreeSet;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.DebugPlugin;
@@ -116,7 +113,6 @@ import org.eclipse.tcf.protocol.IErrorReport;
import org.eclipse.tcf.protocol.IService;
import org.eclipse.tcf.protocol.IToken;
import org.eclipse.tcf.protocol.Protocol;
-import org.eclipse.tcf.services.IContextQuery;
import org.eclipse.tcf.services.IDisassembly;
import org.eclipse.tcf.services.ILineNumbers;
import org.eclipse.tcf.services.IMemory;
@@ -320,34 +316,6 @@ public class TCFModel implements IElementContentProvider, IElementLabelProvider,
private TCFNodeLaunch launch_node;
private boolean disposed;
- private Map<String, TCFDataCache<Set<String>>> context_queries = new TreeMap<String, TCFDataCache<Set<String>>>();
-
- public TCFDataCache<Set<String>> getContextQuery(final String query) {
- TCFDataCache<Set<String>> data = context_queries.get(query);
- if (data == null) {
- data = new TCFDataCache<Set<String>>(channel) {
- @Override
- protected boolean startDataRetrieval() {
- assert command == null;
- IContextQuery service = channel.getRemoteService(IContextQuery.class);
- if (service == null) {
- set(null, null, null);
- return true;
- }
-
- command = service.query(query, new IContextQuery.DoneQuery() {
- public void doneQuery (IToken token, Exception error, String[] contexts) {
- set( token, error, new TreeSet<String>(Arrays.asList(contexts)) );
- }
- });
- return false;
- }
- };
- context_queries.put(query, data);
- }
- return data;
- }
-
private final IMemory.MemoryListener mem_listener = new IMemory.MemoryListener() {
public void contextAdded(IMemory.MemoryContext[] contexts) {
@@ -433,7 +401,6 @@ public class TCFModel implements IElementContentProvider, IElementLabelProvider,
}
public void contextAdded(IRunControl.RunControlContext[] contexts) {
- onContextAdded();
for (IRunControl.RunControlContext ctx : contexts) {
String id = ctx.getParentID();
if (id == null) {
@@ -923,13 +890,6 @@ public class TCFModel implements IElementContentProvider, IElementLabelProvider,
model_proxies.remove(ctx);
}
- private void onContextAdded() {
- for (TCFDataCache<?> query : context_queries.values()) {
- query.reset();
- }
- context_queries.clear();
- }
-
private void onContextRemoved(String[] context_ids) {
for (String id : context_ids) {
TCFNode node = getNode(id);
@@ -943,17 +903,7 @@ public class TCFModel implements IElementContentProvider, IElementLabelProvider,
expanded_nodes.remove(id);
if (mem_blocks_update != null) mem_blocks_update.changeset.remove(id);
}
-
- List<String> context_ids_list = Arrays.asList(context_ids);
- for (TCFDataCache<Set<String>> query : context_queries.values()) {
- if (query.isValid() && query.getError() == null) {
- Set<String> query_contexts = query.getData();
- query_contexts.removeAll(context_ids_list);
- query.reset(query_contexts);
- }
- }
- context_queries.clear();
-
+
launch_node.onAnyContextAddedOrRemoved();
// Close debug session if the last context is removed:
onContextOrProcessRemoved();
diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeExecContext.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeExecContext.java
index bc3b6c39b..3d48348f1 100644
--- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeExecContext.java
+++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeExecContext.java
@@ -12,7 +12,6 @@ package org.eclipse.tcf.internal.debug.ui.model;
import java.math.BigInteger;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
@@ -27,7 +26,6 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputUpdate;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.debug.ui.memory.IMemoryRenderingSite;
import org.eclipse.jface.resource.ImageDescriptor;
@@ -53,7 +51,6 @@ import org.eclipse.ui.IWorkbenchPart;
public class TCFNodeExecContext extends TCFNode implements ISymbolOwner {
private final TCFChildrenExecContext children_exec;
- private final TCFContextQueryDescendants query_descendants;
private final TCFChildrenStackTrace children_stack;
private final TCFChildrenRegisters children_regs;
private final TCFChildrenExpressions children_exps;
@@ -241,8 +238,7 @@ public class TCFNodeExecContext extends TCFNode implements ISymbolOwner {
children_hover_exps = new TCFChildrenHoverExpressions(this);
children_log_exps = new TCFChildrenLogExpressions(this);
children_modules = new TCFChildrenModules(this);
- children_query = new TCFChildrenContextQuery(this, children_exec);
- query_descendants = new TCFContextQueryDescendants(this);
+ children_query = new TCFChildrenContextQuery(this);
mem_context = new TCFData<IMemory.MemoryContext>(channel) {
@Override
protected boolean startDataRetrieval() {
@@ -785,44 +781,6 @@ public class TCFNodeExecContext extends TCFNode implements ISymbolOwner {
public TCFChildren getChildren() {
return children_exec;
}
-
-// public TCFQueryChildrenExecContext getQueryChildren(String query, Set<String> contexts) {
-// class QueryChildrenKey {
-// private final String fQuery;
-// private Set<String> fContexts;
-//
-// QueryChildrenKey(String query, Set<String> contexts) {
-// fQuery = query;
-// fContexts = contexts;
-// }
-//
-// @Override
-// public boolean equals(Object other) {
-// if (other instanceof QueryChildrenKey) {
-// QueryChildrenKey element = (QueryChildrenKey)other;
-// return ((fQuery == null && element.fQuery == null) ||
-// (fQuery != null && fQuery.equals(element.fQuery))) &&
-// ((fContexts == null && element.fContexts == null) ||
-// (fContexts != null && fContexts.equals(element.fContexts)));
-// }
-// return false;
-// }
-//
-// @Override
-// public int hashCode() {
-// return (fQuery != null ? fQuery.hashCode() : 0) + (fContexts != null ? fContexts.hashCode() : 0);
-// }
-//
-// }
-//
-// QueryChildrenKey key = new QueryChildrenKey(query, contexts);
-// TCFQueryChildrenExecContext children = query_children_exec_map.get(key);
-// if (children ==null) {
-// children = new TCFQueryChildrenExecContext(this, children_exec, query, contexts);
-// query_children_exec_map.put(key, children);
-// }
-// return children;
-// }
public TCFNodeStackFrame getLastTopFrame() {
if (!resume_pending) return null;
@@ -878,14 +836,6 @@ public class TCFNodeExecContext extends TCFNode implements ISymbolOwner {
return false;
}
- @SuppressWarnings("unchecked")
- private boolean setQuery(IViewerUpdate result, Runnable done) {
- IPresentationContext context = result.getPresentationContext();
- String query = (String)context.getProperty(ITCFDebugUIConstants.PROP_CONTEXT_QUERY);
- Set<String> filter = (Set<String>)context.getProperty(ITCFDebugUIConstants.PROP_FILTER_CONTEXTS);
- return children_query.setQuery(query, model.getLaunch().getModelContexts(filter), done);
- }
-
@Override
protected boolean getData(IChildrenCountUpdate result, Runnable done) {
TCFChildren children = null;
@@ -935,7 +885,7 @@ public class TCFNodeExecContext extends TCFNode implements ISymbolOwner {
if (ctx != null) children = children_modules;
}
else if (ITCFDebugUIConstants.ID_CONTEXT_QUERY_VIEW.equals(view_id)) {
- if (!setQuery(result, done)) return false;
+ if (!children_query.setQuery(result, done)) return false;
children = children_query;
}
if (children != null) {
@@ -1010,7 +960,7 @@ public class TCFNodeExecContext extends TCFNode implements ISymbolOwner {
if (ctx != null) children = children_modules;
}
else if (ITCFDebugUIConstants.ID_CONTEXT_QUERY_VIEW.equals(view_id)) {
- if (!setQuery(result, done)) return false;
+ if (!children_query.setQuery(result, done)) return false;
children = children_query;
}
if (children == null) return true;
@@ -1077,7 +1027,7 @@ public class TCFNodeExecContext extends TCFNode implements ISymbolOwner {
if (ctx != null) children = children_modules;
}
else if (ITCFDebugUIConstants.ID_CONTEXT_QUERY_VIEW.equals(view_id)) {
- if (!setQuery(result, done)) return false;
+ if (!children_query.setQuery(result, done)) return false;
children = children_query;
}
if (children != null) {
@@ -1094,14 +1044,6 @@ public class TCFNodeExecContext extends TCFNode implements ISymbolOwner {
@Override
protected boolean getData(ILabelUpdate result, Runnable done) {
- if ( ITCFDebugUIConstants.ID_CONTEXT_QUERY_VIEW.equals(result.getPresentationContext().getId()) ) {
- return getContextQueryViewData(result, done);
- } else {
- return getDebugViewData(result, done);
- }
- }
-
- private boolean getDebugViewData(ILabelUpdate result, Runnable done) {
if (!run_context.validate(done)) return false;
String image_name = null;
boolean suspended_by_bp = false;
@@ -1114,6 +1056,17 @@ public class TCFNodeExecContext extends TCFNode implements ISymbolOwner {
label.append(TCFModel.getErrorMessage(error, false));
}
else {
+ String view_id = result.getPresentationContext().getId();
+ if (ITCFDebugUIConstants.ID_CONTEXT_QUERY_VIEW.equals(view_id)) {
+ TCFChildrenContextQuery.Descendants des = TCFChildrenContextQuery.getDescendants(this, result, done);
+ if (des == null) return false;
+ if (des.map != null && des.map.size() > 0) {
+ label.append("(");
+ label.append(des.map.size());
+ label.append(") ");
+ }
+ if (!des.include_parent) result.setForeground(new RGB(128, 128, 128), 0);
+ }
IRunControl.RunControlContext ctx = run_context.getData();
if (ctx == null) {
label.append(id);
@@ -1131,7 +1084,10 @@ public class TCFNodeExecContext extends TCFNode implements ISymbolOwner {
label.append(nm != null ? nm : id);
Object info = ctx.getProperties().get("AdditionalInfo");
if (info != null) label.append(info.toString());
- if (ctx.hasState() && !TCFModel.ID_PINNED_VIEW.equals(result.getPresentationContext().getId())) {
+ if (TCFModel.ID_PINNED_VIEW.equals(view_id) || ITCFDebugUIConstants.ID_CONTEXT_QUERY_VIEW.equals(view_id)) {
+ image_name = ctx.hasState() ? ImageCache.IMG_THREAD_UNKNOWN_STATE : ImageCache.IMG_PROCESS_RUNNING;
+ }
+ else if (ctx.hasState()) {
// Thread
if (resume_pending && resumed_by_action || model.getActiveAction(id) != null) {
if (!state.validate(done)) return false;
@@ -1141,7 +1097,7 @@ public class TCFNodeExecContext extends TCFNode implements ISymbolOwner {
if (state_data.isReversing()) {
image_name = ImageCache.IMG_THREAD_REVERSING;
label.append(" (Reversing)");
- }
+ }
else {
image_name = ImageCache.IMG_THREAD_RUNNNIG;
label.append(" (Running)");
@@ -1235,74 +1191,6 @@ public class TCFNodeExecContext extends TCFNode implements ISymbolOwner {
return true;
}
- private boolean getContextQueryViewData(ILabelUpdate result, Runnable done) {
- if (!run_context.validate(done)) return false;
- String image_name = null;
- StringBuffer label = new StringBuffer();
- Throwable error = run_context.getError();
- if (error != null) {
- result.setForeground(new RGB(255, 0, 0), 0);
- label.append(id);
- label.append(": ");
- label.append(TCFModel.getErrorMessage(error, false));
- }
- else {
- String query = (String)result.getPresentationContext().getProperty(ITCFDebugUIConstants.PROP_CONTEXT_QUERY);
- @SuppressWarnings("unchecked")
- Set<String> contexts = (Set<String>)result.getPresentationContext().getProperty(ITCFDebugUIConstants.PROP_FILTER_CONTEXTS);
- if (contexts != null) contexts = model.getLaunch().getModelContexts(contexts);
- if (!query_descendants.setQuery(query, contexts, done)) return false;
- if (!query_descendants.validate(done)) return false;
- if (query_descendants.getError() == null) {
- Set<String> descendants = query_descendants.getData();
- if (descendants != null && !descendants.isEmpty()) {
- label.append("(");
- label.append(descendants.size());
- label.append(") ");
- }
- }
-
- TCFDataCache<String[]> query_data = model.getLaunch().getContextQuery(query);
- if (!query_data.validate(done)) return false;
- if ( (query_data.getData() != null && !Arrays.asList(query_data.getData()).contains(getID())) ||
- (contexts != null && !contexts.contains(getID())) )
- {
- result.setForeground(new RGB(128, 128, 128), 0);
- }
-
- IRunControl.RunControlContext ctx = run_context.getData();
- if (ctx == null) {
- label.append(id);
- }
- else {
- String nm = ctx.getName();
- if (nm == null && !ctx.hasState()) {
- String prs = ctx.getProcessID();
- if (prs != null) {
- if (!prs_context.validate(done)) return false;
- IProcesses.ProcessContext pctx = prs_context.getData();
- if (pctx != null) nm = pctx.getName();
- }
- }
- label.append(nm != null ? nm : id);
- Object info = ctx.getProperties().get("AdditionalInfo");
- if (info != null) label.append(info.toString());
- if (ctx.hasState()) {
- image_name = ImageCache.IMG_THREAD_UNKNOWN_STATE;
- }
- else {
- // Thread container (process)
- image_name = ImageCache.IMG_PROCESS_RUNNING;
-
- }
- }
- }
-
- result.setImageDescriptor(ImageCache.getImageDescriptor(image_name), 0);
- result.setLabel(label.toString(), 0);
- return true;
- }
-
@Override
protected boolean getData(IViewerInputUpdate result, Runnable done) {
result.setInputElement(this);
@@ -1364,7 +1252,8 @@ public class TCFNodeExecContext extends TCFNode implements ISymbolOwner {
if (IDebugUIConstants.ID_DEBUG_VIEW.equals(view_id)) {
/* Note: should use IModelDelta.INSERTED but it is broken in Eclipse 3.6 */
p.addDelta(this, IModelDelta.ADDED);
- } else if (ITCFDebugUIConstants.ID_CONTEXT_QUERY_VIEW.equals(view_id)) {
+ }
+ else if (ITCFDebugUIConstants.ID_CONTEXT_QUERY_VIEW.equals(view_id)) {
p.addDelta(parent, IModelDelta.CONTENT);
}
}
@@ -1390,7 +1279,8 @@ public class TCFNodeExecContext extends TCFNode implements ISymbolOwner {
String view_id = p.getPresentationContext().getId();
if (IDebugUIConstants.ID_DEBUG_VIEW.equals(view_id)) {
p.addDelta(this, IModelDelta.REMOVED);
- } else if (ITCFDebugUIConstants.ID_CONTEXT_QUERY_VIEW.equals(view_id)) {
+ }
+ else if (ITCFDebugUIConstants.ID_CONTEXT_QUERY_VIEW.equals(view_id)) {
p.addDelta(parent, IModelDelta.CONTENT);
}
}
@@ -1401,7 +1291,7 @@ public class TCFNodeExecContext extends TCFNode implements ISymbolOwner {
for (TCFModelProxy p : model.getModelProxies()) {
int flags = 0;
String view_id = p.getPresentationContext().getId();
- if ( (IDebugUIConstants.ID_DEBUG_VIEW.equals(view_id) ||
+ if ( (IDebugUIConstants.ID_DEBUG_VIEW.equals(view_id) ||
ITCFDebugUIConstants.ID_CONTEXT_QUERY_VIEW.equals(view_id)) &&
(launch.getContextActionsCount(id) == 0 || !model.getDelayStackUpdateUtilLastStep()))
{
@@ -1454,7 +1344,6 @@ public class TCFNodeExecContext extends TCFNode implements ISymbolOwner {
void onContextAdded(IRunControl.RunControlContext context) {
children_exec.onContextAdded(context);
- children_query.reset();
}
void onContextChanged(IRunControl.RunControlContext context) {
@@ -1472,7 +1361,6 @@ public class TCFNodeExecContext extends TCFNode implements ISymbolOwner {
children_stack.onSourceMappingChange();
children_regs.reset();
children_exec.onAncestorContextChanged();
- children_query.reset();
for (TCFNodeSymbol s : symbols.values()) s.onMemoryMapChanged();
postAllChangedDelta();
}
@@ -1501,7 +1389,6 @@ public class TCFNodeExecContext extends TCFNode implements ISymbolOwner {
dispose();
postContextRemovedDelta();
launch.removeContextActions(id);
- children_query.reset();
}
void onExpressionAddedOrRemoved() {
diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeLaunch.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeLaunch.java
index 1f7da09c8..ec0a64f0e 100644
--- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeLaunch.java
+++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeLaunch.java
@@ -18,8 +18,6 @@ import java.util.Set;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenCountUpdate;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IHasChildrenUpdate;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.tcf.debug.ui.ITCFDebugUIConstants;
import org.eclipse.tcf.services.IMemory;
@@ -32,13 +30,12 @@ public class TCFNodeLaunch extends TCFNode implements ISymbolOwner {
private final TCFChildren filtered_children;
private final TCFChildrenContextQuery children_query;
- private final TCFContextQueryDescendants query_descendants_count;
private final Map<String,TCFNodeSymbol> symbols = new HashMap<String,TCFNodeSymbol>();
TCFNodeLaunch(final TCFModel model) {
super(model);
children = new TCFChildrenExecContext(this);
- query_descendants_count = new TCFContextQueryDescendants(this);
+ children_query = new TCFChildrenContextQuery(this);
filtered_children = new TCFChildren(this) {
@Override
protected boolean startDataRetrieval() {
@@ -68,7 +65,6 @@ public class TCFNodeLaunch extends TCFNode implements ISymbolOwner {
super.dispose();
}
};
- children_query = new TCFChildrenContextQuery(this, children);
}
@Override
@@ -79,15 +75,6 @@ public class TCFNodeLaunch extends TCFNode implements ISymbolOwner {
super.dispose();
}
- @SuppressWarnings("unchecked")
- private boolean setQuery(IViewerUpdate result, Runnable done) {
- IPresentationContext context = result.getPresentationContext();
- String query = (String)context.getProperty(ITCFDebugUIConstants.PROP_CONTEXT_QUERY);
- Set<String> filter = (Set<String>)context.getProperty(ITCFDebugUIConstants.PROP_FILTER_CONTEXTS);
- return children_query.setQuery(query, model.getLaunch().getModelContexts(filter), done) &&
- children_query.validate(done);
- }
-
@Override
protected boolean getData(IChildrenCountUpdate result, Runnable done) {
String view_id = result.getPresentationContext().getId();
@@ -96,7 +83,8 @@ public class TCFNodeLaunch extends TCFNode implements ISymbolOwner {
result.setChildCount(filtered_children.size());
}
else if (ITCFDebugUIConstants.ID_CONTEXT_QUERY_VIEW.equals(view_id)) {
- if (!setQuery(result, done)) return false;
+ if (!children_query.setQuery(result, done)) return false;
+ if (!children_query.validate(done)) return false;
result.setChildCount(children_query.size());
}
else {
@@ -112,7 +100,7 @@ public class TCFNodeLaunch extends TCFNode implements ISymbolOwner {
return filtered_children.getData(result, done);
}
else if (ITCFDebugUIConstants.ID_CONTEXT_QUERY_VIEW.equals(view_id)) {
- if (!setQuery(result, done)) return false;
+ if (!children_query.setQuery(result, done)) return false;
return children_query.getData(result, done);
}
return true;
@@ -126,7 +114,8 @@ public class TCFNodeLaunch extends TCFNode implements ISymbolOwner {
result.setHasChilren(filtered_children.size() > 0);
}
else if (ITCFDebugUIConstants.ID_CONTEXT_QUERY_VIEW.equals(view_id)) {
- if (!setQuery(result, done)) return false;
+ if (!children_query.setQuery(result, done)) return false;
+ if (!children_query.validate(done)) return false;
result.setHasChilren(children_query.size() > 0);
}
else {
@@ -166,8 +155,6 @@ public class TCFNodeLaunch extends TCFNode implements ISymbolOwner {
void onAnyContextAddedOrRemoved() {
filtered_children.reset();
- children_query.reset();
- query_descendants_count.reset();
}
public void addSymbol(TCFNodeSymbol s) {
@@ -187,9 +174,4 @@ public class TCFNodeLaunch extends TCFNode implements ISymbolOwner {
public TCFChildren getFilteredChildren() {
return filtered_children;
}
-
- public TCFContextQueryDescendants getContextQueryDescendants() {
- return query_descendants_count;
- }
-
}
diff --git a/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/model/TCFLaunch.java b/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/model/TCFLaunch.java
index 31e4e3a8a..f3b8f590d 100644
--- a/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/model/TCFLaunch.java
+++ b/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/model/TCFLaunch.java
@@ -22,7 +22,6 @@ import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Set;
-import java.util.TreeSet;
import org.eclipse.core.resources.IStorage;
import org.eclipse.core.runtime.CoreException;
@@ -1209,6 +1208,7 @@ public class TCFLaunch extends Launch {
}
public TCFDataCache<String[]> getContextQuery(final String query) {
+ if (query == null) return null;
TCFDataCache<String[]> cache = context_query_cache.get(query);
if (cache == null) {
if (disconnected) return null;
@@ -1230,27 +1230,6 @@ public class TCFLaunch extends Launch {
return cache;
}
- public Set<String> getModelContexts(Set<String> contexts) {
- if (contexts != null) {
- ILaunchConfiguration launchConfig = getLaunchConfiguration();
- if (launchConfig != null) {
- Set<String> modelContexts = new TreeSet<String>();
- String sessionId = launchConfig.getName();
- for (String context : contexts) {
- int slashPos = context.indexOf('/');
- if (slashPos > 0 && context.length() > slashPos + 1) {
- if ( sessionId.equals(context.substring(0, slashPos)) ) {
- modelContexts.add(context.substring(slashPos + 1));
- }
- }
- }
- return modelContexts;
- }
- }
- return null;
- }
-
-
/**
* Activate TCF launch: open communication channel and perform all necessary launch steps.
* @param mode - on of launch mode constants defined in ILaunchManager.

Back to the top