Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Chuong2011-03-30 09:56:31 -0400
committerPatrick Chuong2011-03-30 09:56:31 -0400
commitc1d6a1cffe3eb58e5b41caef41ff3b40490c42ab (patch)
tree5d6ee952ab18c981d368ad4b8f10f80aee72d893 /debug/org.eclipse.cdt.debug.ui
parent16fdcfdd185330e552f89a7b3681f29928c2a6c5 (diff)
downloadorg.eclipse.cdt-c1d6a1cffe3eb58e5b41caef41ff3b40490c42ab.tar.gz
org.eclipse.cdt-c1d6a1cffe3eb58e5b41caef41ff3b40490c42ab.tar.xz
org.eclipse.cdt-c1d6a1cffe3eb58e5b41caef41ff3b40490c42ab.zip
Bug 340177 - [breakpoints] Update CDT ToggleBreakpointTargetFactory enablement
Diffstat (limited to 'debug/org.eclipse.cdt.debug.ui')
-rw-r--r--debug/org.eclipse.cdt.debug.ui/plugin.xml54
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ToggleCBreakpointTester.java126
2 files changed, 156 insertions, 24 deletions
diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.xml b/debug/org.eclipse.cdt.debug.ui/plugin.xml
index 94262f5193..7bb1df689b 100644
--- a/debug/org.eclipse.cdt.debug.ui/plugin.xml
+++ b/debug/org.eclipse.cdt.debug.ui/plugin.xml
@@ -1754,6 +1754,23 @@
</attribute>
</breakpointLabels>
</extension>
+ <extension
+ point="org.eclipse.core.expressions.propertyTesters">
+ <propertyTester
+ class="org.eclipse.cdt.debug.internal.ui.ToggleCBreakpointTester"
+ id="org.eclipse.cdt.debug.ui.editorToggleBreakpointTester"
+ namespace="org.eclipse.cdt.debug.ui"
+ properties="isCEditorSupportsCBreakpoint,isAsmEditorSupportsCBreakpoint,isDisassemblyEditorSupportsCBreakpoint"
+ type="org.eclipse.ui.IWorkbenchPart">
+ </propertyTester>
+ <propertyTester
+ class="org.eclipse.cdt.debug.internal.ui.ToggleCBreakpointTester"
+ id="org.eclipse.cdt.debug.ui.declarationToggleBreakpointTester"
+ namespace="org.eclipse.cdt.debug.ui"
+ properties="isCDeclarationSupportsCBreakpoint"
+ type="java.util.List">
+ </propertyTester>
+ </extension>
<extension point="org.eclipse.debug.ui.toggleBreakpointsTargetFactories">
<toggleTargetFactory
@@ -1762,19 +1779,15 @@
<enablement>
<!-- Enable the breakpoint toggle for CDT's editors and model elements -->
<or>
- <instanceof value="org.eclipse.cdt.internal.ui.editor.CEditor"/>
- <instanceof value="org.eclipse.cdt.internal.ui.editor.asm.AsmTextEditor"/>
- <instanceof value="org.eclipse.cdt.debug.internal.ui.disassembly.editor.DisassemblyEditor"/>
+ <test property="org.eclipse.cdt.debug.ui.isCEditorSupportsCBreakpoint"/>
+ <test property="org.eclipse.cdt.debug.ui.isAsmEditorSupportsCBreakpoint"/>
+ <test
+ property="org.eclipse.cdt.debug.ui.isDisassemblyEditorSupportsCBreakpoint">
+ </test>
<with variable="selection">
<count value="1"/>
- <iterate>
- <or>
- <instanceof value="org.eclipse.cdt.core.model.IFunction"/>
- <instanceof value="org.eclipse.cdt.core.model.IMethod"/>
- <instanceof value="org.eclipse.cdt.core.model.IVariable"/>
- </or>
- </iterate>
- </with>
+ <test property="org.eclipse.cdt.debug.ui.isCDeclarationSupportsCBreakpoint"/>
+ </with>
</or>
</enablement>
</toggleTargetFactory>
@@ -1788,19 +1801,12 @@
definitionId="org.eclipse.cdt.debug.ui.testIsTracepointActionSetActive">
</reference>
<or>
- <instanceof value="org.eclipse.cdt.internal.ui.editor.CEditor"/>
- <instanceof value="org.eclipse.cdt.internal.ui.editor.asm.AsmTextEditor"/>
- <instanceof value="org.eclipse.cdt.debug.internal.ui.disassembly.editor.DisassemblyEditor"/>
- <with variable="selection">
- <count value="1"/>
- <iterate>
- <or>
- <instanceof value="org.eclipse.cdt.core.model.IFunction"/>
- <instanceof value="org.eclipse.cdt.core.model.IMethod"/>
- <instanceof value="org.eclipse.cdt.core.model.IVariable"/>
- </or>
- </iterate>
- </with>
+ <test property="org.eclipse.cdt.debug.ui.isCEditorSupportsCBreakpoint"/>
+ <test property="org.eclipse.cdt.debug.ui.isAsmEditorSupportsCBreakpoint"/>
+ <with variable="selection">
+ <count value="1"/>
+ <test property="org.eclipse.cdt.debug.ui.isCDeclarationSupportsCBreakpoint"/>
+ </with>
</or>
</and>
</enablement>
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ToggleCBreakpointTester.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ToggleCBreakpointTester.java
new file mode 100644
index 0000000000..4a494ad263
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ToggleCBreakpointTester.java
@@ -0,0 +1,126 @@
+/*****************************************************************
+ * Copyright (c) 2011 Texas Instruments 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:
+ * Patrick Chuong (Texas Instruments) -
+ * Update CDT ToggleBreakpointTargetFactory enablement (340177)
+ *****************************************************************/
+package org.eclipse.cdt.debug.internal.ui;
+
+import java.util.List;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IDeclaration;
+import org.eclipse.cdt.core.model.IFunctionDeclaration;
+import org.eclipse.cdt.core.model.IMethodDeclaration;
+import org.eclipse.cdt.core.model.IVariableDeclaration;
+import org.eclipse.cdt.debug.core.CDebugUtils;
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.internal.ui.editor.asm.AsmTextEditor;
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.core.resources.IResource;
+
+/**
+ * Toggle breakpoint factor enablement tester for editors and IDeclaration.
+ *
+ * @since 7.1
+ */
+public class ToggleCBreakpointTester extends PropertyTester {
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
+ */
+ public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
+ // test for CEditor
+ if ("isCEditorSupportsCBreakpoint".equals(property) && (receiver instanceof CEditor)) { //$NON-NLS-1$
+ if (!CDebugUtils.isCustomToggleBreakpointFactory())
+ return true;
+
+ CEditor editor = (CEditor) receiver;
+ ICElement cElement = editor.getInputCElement();
+ if (cElement != null) {
+ ICProject cproject = cElement.getCProject();
+ if (cproject != null) {
+ // Handles the case for external file, check to see whether the file exist.
+ // This is to workaround the EditorUtility wrongly assign the project for
+ // external file.
+ IResource resource = cElement.getResource();
+ if (resource == null || !resource.exists())
+ return true;
+
+ if (CDebugUtils.isStandardCBreakpointFactory(cproject.getProject()))
+ return true;
+
+ } else {
+ return true; // can't figure the associated project, enable it by default.
+ }
+ }
+
+ // test for AsmEditor
+ } else if ("isAsmEditorSupportsCBreakpoint".equals(property) && (receiver instanceof AsmTextEditor)) { //$NON-NLS-1$
+ if (!CDebugUtils.isCustomToggleBreakpointFactory())
+ return true;
+
+ AsmTextEditor editor = (AsmTextEditor) receiver;
+ ICElement cElement = editor.getInputCElement();
+ if (cElement != null) {
+ // Handles the case for external file, check to see whether the file exist.
+ // This is to workaround the EditorUtility wrongly assign the project for
+ // external file.
+ IResource resource = cElement.getResource();
+ if (resource == null || !resource.exists())
+ return true;
+
+ ICProject cproject = cElement.getCProject();
+ if (cproject != null) {
+ if (CDebugUtils.isStandardCBreakpointFactory(cproject.getProject()))
+ return true;
+
+ } else {
+ return true; // can't figure the associated project, enable it by default.
+ }
+ }
+
+ // test for IVariableDeclaration, IFunctionDeclaration, IMethodDeclaration
+ } else if ("isCDeclarationSupportsCBreakpoint".equals(property) && (receiver instanceof List<?>)) { //$NON-NLS-1$
+ if (!CDebugUtils.isCustomToggleBreakpointFactory())
+ return true;
+
+ List<?> list = (List<?>) receiver;
+ if (list.size() == 1) {
+ Object element = list.get(0);
+ if ((element instanceof IDeclaration) &&
+ (element instanceof IVariableDeclaration ||
+ element instanceof IFunctionDeclaration ||
+ element instanceof IMethodDeclaration)) {
+
+ IDeclaration cElement = (IDeclaration) element;
+
+ // Handles the case for external file, check to see whether the file exist.
+ // This is to workaround the EditorUtility wrongly assign the project for
+ // external file.
+ IResource resource = cElement.getResource();
+ if (resource == null || !resource.exists())
+ return true;
+
+ ICProject cproject = cElement.getCProject();
+ if (cproject != null) {
+ if (CDebugUtils.isStandardCBreakpointFactory(cproject.getProject()))
+ return true;
+
+ } else {
+ return true; // can't figure the associated project, enable it by default.
+ }
+ }
+ }
+ }
+
+ return false;
+ }
+}

Back to the top