diff --git a/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF index 4690cd405b2..c0de76dd8d1 100644 --- a/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF +++ b/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF @@ -23,7 +23,7 @@ Export-Package: org.eclipse.cdt.internal.corext;x-internal:=true, org.eclipse.cdt.internal.ui.dialogs;x-internal:=true, org.eclipse.cdt.internal.ui.dialogs.cpaths;x-internal:=true, org.eclipse.cdt.internal.ui.dnd;x-internal:=true, - org.eclipse.cdt.internal.ui.editor;x-friends:="org.eclipse.cdt.codan.ui,org.eclipse.cdt.codan.ui.cxx", + org.eclipse.cdt.internal.ui.editor;x-friends:="org.eclipse.cdt.codan.ui,org.eclipse.cdt.codan.ui.cxx,org.eclipse.cdt.dsf.ui", org.eclipse.cdt.internal.ui.editor.asm;x-internal:=true, org.eclipse.cdt.internal.ui.filters;x-internal:=true, org.eclipse.cdt.internal.ui.help;x-internal:=true, @@ -50,7 +50,7 @@ Export-Package: org.eclipse.cdt.internal.corext;x-internal:=true, org.eclipse.cdt.internal.ui.resources, org.eclipse.cdt.internal.ui.search;x-internal:=true, org.eclipse.cdt.internal.ui.search.actions;x-internal:=true, - org.eclipse.cdt.internal.ui.text;x-friends:="org.eclipse.cdt.codan.ui.cxx", + org.eclipse.cdt.internal.ui.text;x-friends:="org.eclipse.cdt.codan.ui.cxx,org.eclipse.cdt.dsf.ui", org.eclipse.cdt.internal.ui.text.asm;x-internal:=true, org.eclipse.cdt.internal.ui.text.c.hover;x-internal:=true, org.eclipse.cdt.internal.ui.text.contentassist;x-internal:=true, diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbAdapterFactory.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbAdapterFactory.java index fb440c46362..03bb6e2823b 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbAdapterFactory.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbAdapterFactory.java @@ -41,7 +41,6 @@ import org.eclipse.cdt.dsf.debug.ui.actions.DsfStepIntoSelectionCommand; import org.eclipse.cdt.dsf.debug.ui.actions.DsfStepOverCommand; import org.eclipse.cdt.dsf.debug.ui.actions.DsfStepReturnCommand; import org.eclipse.cdt.dsf.debug.ui.actions.DsfSuspendCommand; -import org.eclipse.cdt.dsf.debug.ui.actions.IDsfStepIntoSelection; import org.eclipse.cdt.dsf.debug.ui.sourcelookup.DsfSourceDisplayAdapter; import org.eclipse.cdt.dsf.debug.ui.viewmodel.SteppingController; import org.eclipse.cdt.dsf.debug.ui.viewmodel.actions.DefaultRefreshAllTarget; @@ -211,7 +210,6 @@ public class GdbAdapterFactory session.registerModelAdapter(ISelectNextTraceRecordHandler.class, fSelectNextRecordTarget); session.registerModelAdapter(ISelectPrevTraceRecordHandler.class, fSelectPrevRecordTarget); session.registerModelAdapter(IPinProvider.class, fPinProvider); - session.registerModelAdapter(IDsfStepIntoSelection.class, fStepIntoSelectionCommand); fDebugModelProvider = new IDebugModelProvider() { // @see org.eclipse.debug.core.model.IDebugModelProvider#getModelIdentifiers() diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/actions/DsfStepIntoSelectionCommand.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/actions/DsfStepIntoSelectionCommand.java index 7ec6ce2e0bb..d9b1f179452 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/actions/DsfStepIntoSelectionCommand.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/actions/DsfStepIntoSelectionCommand.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013 Ericsson AB and others. + * Copyright (c) 2013, 2014 Ericsson AB 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 @@ -44,8 +44,11 @@ import org.eclipse.swt.widgets.Display; * @since 2.4 */ public class DsfStepIntoSelectionCommand extends AbstractDebugCommand implements IStepIntoSelectionHandler, IDsfStepIntoSelection { + private final DsfSession fSession; private final DsfServicesTracker fTracker; + public DsfStepIntoSelectionCommand(DsfSession session) { + fSession = session; fTracker = new DsfServicesTracker(DsfUIPlugin.getBundleContext(), session.getId()); } @@ -84,40 +87,7 @@ public class DsfStepIntoSelectionCommand extends AbstractDebugCommand implements } final IExecutionDMContext dmc = DMContexts.getAncestorOfType(((IDMVMContext) targets[0]).getDMContext(), IExecutionDMContext.class); - if (dmc == null) { - return false; - } - - return isExecutable(dmc, fTracker); - } - - private boolean isExecutable(final IExecutionDMContext dmc, final DsfServicesTracker tracker) { - final DsfSession session = DsfSession.getSession(dmc.getSessionId()); - if (session != null && session.isActive()) { - try { - Query query = new Query() { - @Override - protected void execute(DataRequestMonitor rm) { - IRunControl3 runControl = tracker.getService(IRunControl3.class); - if (runControl != null) { - // The selection may not be up to date, this is indicated with - // the selectedFunction being set to null - runControl.canStepIntoSelection(dmc, null, 0, null, rm); - } else { - rm.setData(false); - rm.done(); - } - } - }; - - session.getExecutor().execute(query); - return query.get(); - } catch (InterruptedException e) { - } catch (ExecutionException e) { - } - } - - return false; + return isExecutable(dmc); } @Override @@ -138,43 +108,54 @@ public class DsfStepIntoSelectionCommand extends AbstractDebugCommand implements if (dmc == null) { return false; } - - DsfServicesTracker tracker = new DsfServicesTracker(DsfUIPlugin.getBundleContext(), dmc.getSessionId()); - boolean result = isExecutable(dmc, tracker); - tracker.dispose(); - return result; + + if (fSession != null && fSession.isActive()) { + try { + Query query = new Query() { + @Override + protected void execute(DataRequestMonitor rm) { + IRunControl3 runControl = fTracker.getService(IRunControl3.class); + if (runControl == null) { + rm.done(false); + return; + } + + // The selection may not be up to date, this is indicated with + // the selectedFunction being set to null + runControl.canStepIntoSelection(dmc, null, 0, null, rm); + } + }; + + fSession.getExecutor().execute(query); + return query.get(); + } catch (InterruptedException e) { + } catch (ExecutionException e) { + } + } + + return false; } @Override public void runToSelection(final String fileName, final int lineLocation, final IFunctionDeclaration selectedFunction, final IExecutionDMContext dmc) { - final DsfSession session = DsfSession.getSession(dmc.getSessionId()); - if (session != null && session.isActive()) { + if (fSession != null && fSession.isActive()) { Throwable exception = null; try { Query query = new Query() { @Override protected void execute(final DataRequestMonitor rm) { - DsfServicesTracker tracker = new DsfServicesTracker(DsfUIPlugin.getBundleContext(), session.getId()); - - boolean skipBreakpoints = DebugUITools.getPreferenceStore().getBoolean(IDebugUIConstants.PREF_SKIP_BREAKPOINTS_DURING_RUN_TO_LINE); - - IRunControl3 runControl = tracker.getService(IRunControl3.class); - tracker.dispose(); - StringBuilder eMessage = null; - if (runControl != null) { - runControl.stepIntoSelection(dmc, fileName, lineLocation, skipBreakpoints, selectedFunction, rm); + IRunControl3 runControl = fTracker.getService(IRunControl3.class); + if (runControl == null) { + rm.done(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfStatusConstants.NOT_SUPPORTED, "IRunControl3 service not available", null)); //$NON-NLS-1$ return; - } else { - eMessage = new StringBuilder("IRunControl3 service not available"); //$NON-NLS-1$ } - // Either runControl is null or an Exception has occurred - rm.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfStatusConstants.NOT_SUPPORTED, eMessage.toString(), null)); - rm.done(); + boolean skipBreakpoints = DebugUITools.getPreferenceStore().getBoolean(IDebugUIConstants.PREF_SKIP_BREAKPOINTS_DURING_RUN_TO_LINE); + runControl.stepIntoSelection(dmc, fileName, lineLocation, skipBreakpoints, selectedFunction, rm); } }; - session.getExecutor().execute(query); + fSession.getExecutor().execute(query); query.get(); } catch (RejectedExecutionException e) { exception = e; diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/actions/DsfStepIntoSelectionHyperlinkDetector.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/actions/DsfStepIntoSelectionHyperlinkDetector.java index 5c2a5a09d03..7095126cda1 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/actions/DsfStepIntoSelectionHyperlinkDetector.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/actions/DsfStepIntoSelectionHyperlinkDetector.java @@ -13,6 +13,7 @@ package org.eclipse.cdt.dsf.debug.ui.actions; import org.eclipse.cdt.core.model.ICLanguageKeywords; import org.eclipse.cdt.core.model.ILanguage; import org.eclipse.cdt.core.model.IWorkingCopy; +import org.eclipse.cdt.debug.core.model.IStepIntoSelectionHandler; import org.eclipse.cdt.dsf.datamodel.DMContexts; import org.eclipse.cdt.dsf.datamodel.IDMContext; import org.eclipse.cdt.dsf.debug.internal.ui.Messages; @@ -138,8 +139,11 @@ public class DsfStepIntoSelectionHyperlinkDetector extends AbstractHyperlinkDete return null; } - IDsfStepIntoSelection stepIntoSelectionCommand = (IDsfStepIntoSelection) session.getModelAdapter(IDsfStepIntoSelection.class); - if (stepIntoSelectionCommand == null) { + IDsfStepIntoSelection stepIntoSelectionCommand = null; + IStepIntoSelectionHandler stepIntoSelectionHandler = (IStepIntoSelectionHandler) session.getModelAdapter(IStepIntoSelectionHandler.class); + if (stepIntoSelectionHandler instanceof IDsfStepIntoSelection) { + stepIntoSelectionCommand = (IDsfStepIntoSelection)stepIntoSelectionHandler; + } else { return null; } @@ -191,7 +195,6 @@ public class DsfStepIntoSelectionHyperlinkDetector extends AbstractHyperlinkDete * Returns the identifier at the given offset, or {@code null} if the there is no identifier at the offset. */ private static IRegion getIdentifier(IDocument document, int offset, ILanguage language) throws BadLocationException { - @SuppressWarnings("restriction") IRegion wordRegion = CWordFinder.findWord(document, offset); if (wordRegion != null && wordRegion.getLength() > 0) { String word = document.get(wordRegion.getOffset(), wordRegion.getLength());