Skip to main content
summaryrefslogtreecommitdiffstats
path: root/debug
diff options
context:
space:
mode:
authorRandy Rohrbach2013-01-14 17:19:44 -0500
committerRandy Rohrbach2013-01-14 17:27:05 -0500
commitdc114aff98849341abb32e858cb23018ea9ebd48 (patch)
treef614f6c5788911e8cf51f39dedd469ed53ace8d9 /debug
parent997f7b660705a717b99f3e97b6bb76d28be76c6c (diff)
downloadorg.eclipse.cdt-dc114aff98849341abb32e858cb23018ea9ebd48.tar.gz
org.eclipse.cdt-dc114aff98849341abb32e858cb23018ea9ebd48.tar.xz
org.eclipse.cdt-dc114aff98849341abb32e858cb23018ea9ebd48.zip
Bug 398136 - ILaunchable is confusing
Bug 398137 - Exporters/Importers should be filterable based on the address size they support
Diffstat (limited to 'debug')
-rw-r--r--debug/org.eclipse.cdt.debug.ui/plugin.xml6
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/InvalidLaunchableAdapterFactory.java88
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/LaunchMessages.properties3
3 files changed, 94 insertions, 3 deletions
diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.xml b/debug/org.eclipse.cdt.debug.ui/plugin.xml
index fa6769bbf6..0188aa81f4 100644
--- a/debug/org.eclipse.cdt.debug.ui/plugin.xml
+++ b/debug/org.eclipse.cdt.debug.ui/plugin.xml
@@ -128,17 +128,17 @@
<!-- Adapters for contextual launch -->
<extension point="org.eclipse.core.runtime.adapters">
<factory
- class=""
+ class="org.eclipse.cdt.debug.internal.ui.launch.InvalidLaunchableAdapterFactory"
adaptableType="org.eclipse.cdt.core.model.IBinary">
<adapter type="org.eclipse.debug.ui.actions.ILaunchable"/>
</factory>
<factory
- class=""
+ class="org.eclipse.cdt.debug.internal.ui.launch.InvalidLaunchableAdapterFactory"
adaptableType="org.eclipse.core.resources.IResource">
<adapter type="org.eclipse.debug.ui.actions.ILaunchable"/>
</factory>
<factory
- class=""
+ class="org.eclipse.cdt.debug.internal.ui.launch.InvalidLaunchableAdapterFactory"
adaptableType="org.eclipse.cdt.core.model.ICProject">
<adapter type="org.eclipse.debug.ui.actions.ILaunchable"/>
</factory>
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/InvalidLaunchableAdapterFactory.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/InvalidLaunchableAdapterFactory.java
new file mode 100644
index 0000000000..10ff510a19
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/InvalidLaunchableAdapterFactory.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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 implementation
+ *******************************************************************************/
+package org.eclipse.cdt.debug.internal.ui.launch;
+
+import java.util.ArrayList;
+
+import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.ui.actions.ILaunchable;
+
+/**
+ * This is an invalid Adapter factory which insures that there are no false
+ * usages of this class when defining ILaunchable contexts. Please reference
+ * the ILaunchable interface and Bugzilla : 396822.
+ */
+public class InvalidLaunchableAdapterFactory implements IAdapterFactory {
+
+ private static final Class<?>[] TYPES = { ILaunchable.class };
+
+ private static ArrayList<String> currentTraces = new ArrayList<String>();
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
+ */
+ @Override
+ @SuppressWarnings("rawtypes")
+ public Object getAdapter(Object adaptableObject, Class adapterType) {
+ /*
+ * Calculate the trace to see if we already have seen this one. We only
+ * want to report new instances of the violation.
+ */
+ String trace = getStackTrace();
+
+ if ( ! currentTraces.contains( trace ) ) {
+ /*
+ * Note we have seen this one for the first time.
+ */
+ currentTraces.add( trace );
+
+ /*
+ * Generate a message for this in the log file.
+ */
+ String msg = LaunchMessages.getString("Launch.ILaunchable.Interface.Error"); //$NON-NLS-1$
+
+ CDebugUIPlugin.log( new Status( IStatus.INFO, CDebugUIPlugin.PLUGIN_ID, 0, msg, new Throwable( "" ) ) ); //$NON-NLS-1$
+ }
+
+ /*
+ * We do not actually provide an adapter factory for this.
+ */
+ return null;
+ }
+
+ /*
+ * Constructs the stack trace for comparison to see if we have seen this exact trace before.
+ * We only report each unique instance once.
+ */
+ private String getStackTrace() {
+ String trace = ""; //$NON-NLS-1$
+ for (StackTraceElement elem : new Throwable().getStackTrace()) {
+ trace += elem.getClassName() + elem.getMethodName() + elem.getFileName() + elem.getLineNumber();
+ }
+ return trace;
+ }
+
+ /*
+ * Indicates that we are adapting ILaunchable.
+ *
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
+ */
+ @Override
+ @SuppressWarnings("rawtypes")
+ public Class[] getAdapterList() {
+ return TYPES;
+ }
+}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/LaunchMessages.properties b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/LaunchMessages.properties
index 65d1b918be..d83a53bd82 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/LaunchMessages.properties
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/LaunchMessages.properties
@@ -32,3 +32,6 @@ CApplicationLaunchShortcut.Launch_failed_no_project_selected=Launch failed no pr
Launch.common.BinariesColon=Binaries:
Launch.common.QualifierColon=Qualifier:
+
+Launch.ILaunchable.Interface.Error=An attempt to instantiate an adapter factory for ILaunchable. By API specification this is not allowed. Use hasAdapter() to determine existense.
+

Back to the top