-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate ToggleInstructionStepModeAction to
ToggleInstructionStepModeCommand. All the contributions of the the action has been replaced ToggleInstructionStepModeCommand. Enabled when introduced. Which enabled the command only when C/CPP application is under debug in Debug View. see #865
- Loading branch information
1 parent
abe036e
commit 6e9cff5
Showing
7 changed files
with
301 additions
and
274 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
...se.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CDTDebugPropertyTester.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 Advantest Europe GmbH and others. | ||
* | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Raghunandana Murthappa | ||
*******************************************************************************/ | ||
package org.eclipse.cdt.debug.internal.ui.actions; | ||
|
||
import org.eclipse.cdt.debug.core.model.ISteppingModeTarget; | ||
import org.eclipse.core.expressions.PropertyTester; | ||
import org.eclipse.core.runtime.IAdaptable; | ||
import org.eclipse.debug.core.model.IDebugElement; | ||
import org.eclipse.debug.core.model.IDebugTarget; | ||
import org.eclipse.debug.ui.IDebugUIConstants; | ||
import org.eclipse.debug.ui.IDebugView; | ||
import org.eclipse.jface.viewers.ISelection; | ||
import org.eclipse.jface.viewers.TreeSelection; | ||
import org.eclipse.ui.IViewPart; | ||
import org.eclipse.ui.IWorkbenchPage; | ||
import org.eclipse.ui.IWorkbenchWindow; | ||
import org.eclipse.ui.PlatformUI; | ||
|
||
/** | ||
*Tests whether an active C/C++ application is debugging. And selection inside Debug View is present on it. | ||
* | ||
*@author Raghunandana Murthappa | ||
*/ | ||
public class CDTDebugPropertyTester extends PropertyTester { | ||
|
||
public static final String IS_CDT_DEBUGGING = "isCDTDebugging"; //$NON-NLS-1$ | ||
|
||
@Override | ||
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { | ||
if (IS_CDT_DEBUGGING.equals(property)) { | ||
return isCppAppDebugging(); | ||
} | ||
return false; | ||
} | ||
|
||
private boolean isCppAppDebugging() { | ||
ISteppingModeTarget gdbTarget = getCppTargetFromDebugView(); | ||
return gdbTarget != null; | ||
} | ||
|
||
/** | ||
* Debug View can contain many targets at given point of time. This will check if {@code ISteppingModeTarget} present and it is selected. If yes returns it. | ||
* | ||
* @return Instruction stepping mode target. | ||
*/ | ||
public static ISteppingModeTarget getCppTargetFromDebugView() { | ||
IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); | ||
if (workbenchWindow == null) { | ||
return null; | ||
} | ||
|
||
IWorkbenchPage workbenchPage = workbenchWindow.getActivePage(); | ||
if (workbenchPage == null) { | ||
return null; | ||
} | ||
|
||
IViewPart debugView = workbenchPage.findView(IDebugUIConstants.ID_DEBUG_VIEW); | ||
if (debugView == null) { | ||
return null; | ||
} | ||
|
||
IDebugView debugViewClazz = debugView.getAdapter(IDebugView.class); | ||
ISelection selection = debugViewClazz.getViewer().getSelection(); | ||
if (selection.isEmpty() || !(selection instanceof TreeSelection)) { | ||
return null; | ||
} | ||
|
||
Object element = ((TreeSelection) selection).getFirstElement(); | ||
ISteppingModeTarget target = null; | ||
if (element instanceof IDebugElement) { | ||
IDebugTarget debugTarget = ((IDebugElement) element).getDebugTarget(); | ||
if (debugTarget instanceof ISteppingModeTarget) { | ||
target = (ISteppingModeTarget) debugTarget; | ||
} | ||
} | ||
if (target == null) { | ||
if (element instanceof IAdaptable) { | ||
target = ((IAdaptable) element).getAdapter(ISteppingModeTarget.class); | ||
} | ||
} | ||
return target; | ||
} | ||
} |
Oops, something went wrong.