mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 455094 - StepIntoSelection cleanup after review
Change-Id: Id591e5c46ed86744b92c0931079fc798e39498ed Signed-off-by: Marc Khouzam <marc.khouzam@ericsson.com> Reviewed-on: https://git.eclipse.org/r/38177
This commit is contained in:
parent
0498b96805
commit
5beb56ed69
4 changed files with 46 additions and 64 deletions
|
@ -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;x-internal:=true,
|
||||||
org.eclipse.cdt.internal.ui.dialogs.cpaths;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.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.editor.asm;x-internal:=true,
|
||||||
org.eclipse.cdt.internal.ui.filters;x-internal:=true,
|
org.eclipse.cdt.internal.ui.filters;x-internal:=true,
|
||||||
org.eclipse.cdt.internal.ui.help;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.resources,
|
||||||
org.eclipse.cdt.internal.ui.search;x-internal:=true,
|
org.eclipse.cdt.internal.ui.search;x-internal:=true,
|
||||||
org.eclipse.cdt.internal.ui.search.actions;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.asm;x-internal:=true,
|
||||||
org.eclipse.cdt.internal.ui.text.c.hover;x-internal:=true,
|
org.eclipse.cdt.internal.ui.text.c.hover;x-internal:=true,
|
||||||
org.eclipse.cdt.internal.ui.text.contentassist;x-internal:=true,
|
org.eclipse.cdt.internal.ui.text.contentassist;x-internal:=true,
|
||||||
|
|
|
@ -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.DsfStepOverCommand;
|
||||||
import org.eclipse.cdt.dsf.debug.ui.actions.DsfStepReturnCommand;
|
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.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.sourcelookup.DsfSourceDisplayAdapter;
|
||||||
import org.eclipse.cdt.dsf.debug.ui.viewmodel.SteppingController;
|
import org.eclipse.cdt.dsf.debug.ui.viewmodel.SteppingController;
|
||||||
import org.eclipse.cdt.dsf.debug.ui.viewmodel.actions.DefaultRefreshAllTarget;
|
import org.eclipse.cdt.dsf.debug.ui.viewmodel.actions.DefaultRefreshAllTarget;
|
||||||
|
@ -211,7 +210,6 @@ public class GdbAdapterFactory
|
||||||
session.registerModelAdapter(ISelectNextTraceRecordHandler.class, fSelectNextRecordTarget);
|
session.registerModelAdapter(ISelectNextTraceRecordHandler.class, fSelectNextRecordTarget);
|
||||||
session.registerModelAdapter(ISelectPrevTraceRecordHandler.class, fSelectPrevRecordTarget);
|
session.registerModelAdapter(ISelectPrevTraceRecordHandler.class, fSelectPrevRecordTarget);
|
||||||
session.registerModelAdapter(IPinProvider.class, fPinProvider);
|
session.registerModelAdapter(IPinProvider.class, fPinProvider);
|
||||||
session.registerModelAdapter(IDsfStepIntoSelection.class, fStepIntoSelectionCommand);
|
|
||||||
|
|
||||||
fDebugModelProvider = new IDebugModelProvider() {
|
fDebugModelProvider = new IDebugModelProvider() {
|
||||||
// @see org.eclipse.debug.core.model.IDebugModelProvider#getModelIdentifiers()
|
// @see org.eclipse.debug.core.model.IDebugModelProvider#getModelIdentifiers()
|
||||||
|
|
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -44,8 +44,11 @@ import org.eclipse.swt.widgets.Display;
|
||||||
* @since 2.4
|
* @since 2.4
|
||||||
*/
|
*/
|
||||||
public class DsfStepIntoSelectionCommand extends AbstractDebugCommand implements IStepIntoSelectionHandler, IDsfStepIntoSelection {
|
public class DsfStepIntoSelectionCommand extends AbstractDebugCommand implements IStepIntoSelectionHandler, IDsfStepIntoSelection {
|
||||||
|
private final DsfSession fSession;
|
||||||
private final DsfServicesTracker fTracker;
|
private final DsfServicesTracker fTracker;
|
||||||
|
|
||||||
public DsfStepIntoSelectionCommand(DsfSession session) {
|
public DsfStepIntoSelectionCommand(DsfSession session) {
|
||||||
|
fSession = session;
|
||||||
fTracker = new DsfServicesTracker(DsfUIPlugin.getBundleContext(), session.getId());
|
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);
|
final IExecutionDMContext dmc = DMContexts.getAncestorOfType(((IDMVMContext) targets[0]).getDMContext(), IExecutionDMContext.class);
|
||||||
if (dmc == null) {
|
return isExecutable(dmc);
|
||||||
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<Boolean> query = new Query<Boolean>() {
|
|
||||||
@Override
|
|
||||||
protected void execute(DataRequestMonitor<Boolean> 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -138,43 +108,54 @@ public class DsfStepIntoSelectionCommand extends AbstractDebugCommand implements
|
||||||
if (dmc == null) {
|
if (dmc == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
DsfServicesTracker tracker = new DsfServicesTracker(DsfUIPlugin.getBundleContext(), dmc.getSessionId());
|
if (fSession != null && fSession.isActive()) {
|
||||||
boolean result = isExecutable(dmc, tracker);
|
try {
|
||||||
tracker.dispose();
|
Query<Boolean> query = new Query<Boolean>() {
|
||||||
return result;
|
@Override
|
||||||
|
protected void execute(DataRequestMonitor<Boolean> 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
|
@Override
|
||||||
public void runToSelection(final String fileName, final int lineLocation, final IFunctionDeclaration selectedFunction, final IExecutionDMContext dmc) {
|
public void runToSelection(final String fileName, final int lineLocation, final IFunctionDeclaration selectedFunction, final IExecutionDMContext dmc) {
|
||||||
final DsfSession session = DsfSession.getSession(dmc.getSessionId());
|
if (fSession != null && fSession.isActive()) {
|
||||||
if (session != null && session.isActive()) {
|
|
||||||
Throwable exception = null;
|
Throwable exception = null;
|
||||||
try {
|
try {
|
||||||
Query<Object> query = new Query<Object>() {
|
Query<Object> query = new Query<Object>() {
|
||||||
@Override
|
@Override
|
||||||
protected void execute(final DataRequestMonitor<Object> rm) {
|
protected void execute(final DataRequestMonitor<Object> rm) {
|
||||||
DsfServicesTracker tracker = new DsfServicesTracker(DsfUIPlugin.getBundleContext(), session.getId());
|
IRunControl3 runControl = fTracker.getService(IRunControl3.class);
|
||||||
|
if (runControl == null) {
|
||||||
boolean skipBreakpoints = DebugUITools.getPreferenceStore().getBoolean(IDebugUIConstants.PREF_SKIP_BREAKPOINTS_DURING_RUN_TO_LINE);
|
rm.done(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfStatusConstants.NOT_SUPPORTED, "IRunControl3 service not available", null)); //$NON-NLS-1$
|
||||||
|
|
||||||
IRunControl3 runControl = tracker.getService(IRunControl3.class);
|
|
||||||
tracker.dispose();
|
|
||||||
StringBuilder eMessage = null;
|
|
||||||
if (runControl != null) {
|
|
||||||
runControl.stepIntoSelection(dmc, fileName, lineLocation, skipBreakpoints, selectedFunction, rm);
|
|
||||||
return;
|
return;
|
||||||
} else {
|
|
||||||
eMessage = new StringBuilder("IRunControl3 service not available"); //$NON-NLS-1$
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Either runControl is null or an Exception has occurred
|
boolean skipBreakpoints = DebugUITools.getPreferenceStore().getBoolean(IDebugUIConstants.PREF_SKIP_BREAKPOINTS_DURING_RUN_TO_LINE);
|
||||||
rm.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfStatusConstants.NOT_SUPPORTED, eMessage.toString(), null));
|
runControl.stepIntoSelection(dmc, fileName, lineLocation, skipBreakpoints, selectedFunction, rm);
|
||||||
rm.done();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
session.getExecutor().execute(query);
|
fSession.getExecutor().execute(query);
|
||||||
query.get();
|
query.get();
|
||||||
} catch (RejectedExecutionException e) {
|
} catch (RejectedExecutionException e) {
|
||||||
exception = e;
|
exception = e;
|
||||||
|
|
|
@ -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.ICLanguageKeywords;
|
||||||
import org.eclipse.cdt.core.model.ILanguage;
|
import org.eclipse.cdt.core.model.ILanguage;
|
||||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
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.DMContexts;
|
||||||
import org.eclipse.cdt.dsf.datamodel.IDMContext;
|
import org.eclipse.cdt.dsf.datamodel.IDMContext;
|
||||||
import org.eclipse.cdt.dsf.debug.internal.ui.Messages;
|
import org.eclipse.cdt.dsf.debug.internal.ui.Messages;
|
||||||
|
@ -138,8 +139,11 @@ public class DsfStepIntoSelectionHyperlinkDetector extends AbstractHyperlinkDete
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
IDsfStepIntoSelection stepIntoSelectionCommand = (IDsfStepIntoSelection) session.getModelAdapter(IDsfStepIntoSelection.class);
|
IDsfStepIntoSelection stepIntoSelectionCommand = null;
|
||||||
if (stepIntoSelectionCommand == null) {
|
IStepIntoSelectionHandler stepIntoSelectionHandler = (IStepIntoSelectionHandler) session.getModelAdapter(IStepIntoSelectionHandler.class);
|
||||||
|
if (stepIntoSelectionHandler instanceof IDsfStepIntoSelection) {
|
||||||
|
stepIntoSelectionCommand = (IDsfStepIntoSelection)stepIntoSelectionHandler;
|
||||||
|
} else {
|
||||||
return null;
|
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.
|
* 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 {
|
private static IRegion getIdentifier(IDocument document, int offset, ILanguage language) throws BadLocationException {
|
||||||
@SuppressWarnings("restriction")
|
|
||||||
IRegion wordRegion = CWordFinder.findWord(document, offset);
|
IRegion wordRegion = CWordFinder.findWord(document, offset);
|
||||||
if (wordRegion != null && wordRegion.getLength() > 0) {
|
if (wordRegion != null && wordRegion.getLength() > 0) {
|
||||||
String word = document.get(wordRegion.getOffset(), wordRegion.getLength());
|
String word = document.get(wordRegion.getOffset(), wordRegion.getLength());
|
||||||
|
|
Loading…
Add table
Reference in a new issue