diff options
author | akosyakov | 2014-07-08 15:56:47 +0000 |
---|---|---|
committer | akosyakov | 2014-07-23 11:27:22 +0000 |
commit | ed4a5afff53343242837d9fe7f0014d5419fcb81 (patch) | |
tree | 084a09c61673ac6d88e6f154330cbee2e5af0da5 | |
parent | 6f5ea075142efa6fcb01862036789ecc76ecfe3b (diff) | |
download | eclipse.platform.debug-ed4a5afff53343242837d9fe7f0014d5419fcb81.tar.gz eclipse.platform.debug-ed4a5afff53343242837d9fe7f0014d5419fcb81.tar.xz eclipse.platform.debug-ed4a5afff53343242837d9fe7f0014d5419fcb81.zip |
[bug 438621][debug]: provided step filters extension point
Change-Id: I26b55e35ab210527d52516cefc216ec40576c1d8
Signed-off-by: akosyakov <anton.kosyakov@itemis.de>
14 files changed, 406 insertions, 15 deletions
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java index 44b3e4adc..2a36552e2 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java @@ -49,6 +49,7 @@ import org.eclipse.debug.core.model.IDisconnect; import org.eclipse.debug.core.model.IDropToFrame; import org.eclipse.debug.core.model.IProcess; import org.eclipse.debug.core.model.IStep; +import org.eclipse.debug.core.model.IStepFilter; import org.eclipse.debug.core.model.IStepFilters; import org.eclipse.debug.core.model.ISuspendResume; import org.eclipse.debug.core.model.ITerminate; @@ -210,6 +211,14 @@ public class DebugPlugin extends Plugin { public static final String EXTENSION_POINT_BREAKPOINT_IMPORT_PARTICIPANTS = "breakpointImportParticipants"; //$NON-NLS-1$ /** + * Simple identifier constant (value <code>"stepFilters"</code>) for the + * step filters extension point. + * + * @since 3.9 + */ + public static final String EXTENSION_POINT_STEP_FILTERS = "stepFilters"; //$NON-NLS-1$ + + /** * Status code indicating an unexpected error. * * @since 3.4 @@ -1568,6 +1577,20 @@ public class DebugPlugin extends Plugin { } /** + * Returns any step filters that have been contributed for the given model + * identifier. + * + * @param modelIdentifier the model identifier + * @return step filters that have been contributed for the given model + * identifier, possibly an empty collection + * @since 3.9 + * @see org.eclipse.debug.core.model.IStepFilter + */ + public static IStepFilter[] getStepFilters(String modelIdentifier) { + return getStepFilterManager().getStepFilters(modelIdentifier); + } + + /** * Returns the step filter manager. * * @return step filter manager diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/model/IStepFilter.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/model/IStepFilter.java new file mode 100644 index 000000000..ce1162cb6 --- /dev/null +++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/model/IStepFilter.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2014 itemis AG (http://www.itemis.eu) 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 + *******************************************************************************/ +package org.eclipse.debug.core.model; + +/** + * Provides the ability to filter out steps based on some object. Associated + * with a step filter extension. + * + * <p> + * The following is an example of a step filter extension: + * + * <pre> + * <extension point="org.eclipse.debug.core.stepFilters"> + * <stepFilters + * class="com.example.ExampleStepFilters" + * modelIdentifier="com.example.debug.model"> + * </stepFilters> + * </extension> + * </pre> + * + * </p> + * In the example above, the specified step filter will be used for the + * <code>com.example.debug.model</code> debug model. </p> + * + * <p> + * Clients contributing step filters must implement this interface. + * </p> + * + * @since 3.9 + * @see org.eclipse.debug.core.model.IStep + * + */ +public interface IStepFilter { + + /** + * Returns whether the step for the given object should be filtered. + * + * @param object the object to filter + * @return whether the step for the given object should be filtered. + */ + public boolean isFiltered(Object object); + +} diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.java index c0d7eb8ae..4bdda7c68 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.java @@ -67,7 +67,7 @@ public class DebugCoreMessages extends NLS { public static String LogicalStructureProvider_0; public static String LogicalStructureProvider_1; public static String LogicalStructureType_1; - public static String SystemPropertyResolver_0; + public static String SystemPropertyResolver_0; public static String InputStreamMonitor_label; public static String Launch_terminate_failed; public static String LaunchConfiguration_Failed_to_delete_launch_configuration__1; @@ -104,6 +104,8 @@ public class DebugCoreMessages extends NLS { public static String RefreshingResourcesError; public static String RefreshUtil_0; public static String RefreshUtil_1; + public static String StepFilter_0; + public static String StepFilter_1; static { // load message values from bundle file diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.properties b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.properties index 11b69f9f5..9a90a2400 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.properties +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.properties @@ -105,3 +105,5 @@ RefreshingResources=Refresh resources... RefreshingResourcesError=Exception(s) occurred during refresh. RefreshUtil_0=Unable to restore resource memento: {0} RefreshUtil_1=Refresh scope refers to non-existent resource {0} +StepFilter_0=Required attribute modelIdentifier missing for stepFilter extension. +StepFilter_1=Required attribute class missing for stepFilter extension. diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/StepFilter.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/StepFilter.java new file mode 100644 index 000000000..7069a3cde --- /dev/null +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/StepFilter.java @@ -0,0 +1,73 @@ +/******************************************************************************* + * Copyright (c) 2014 itemis AG (http://www.itemis.eu) 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 + *******************************************************************************/ +package org.eclipse.debug.internal.core; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.model.IStepFilter; + +/** + * Manage step filter extensions. + * + * @see IConfigurationElementConstants + */ +public class StepFilter { + + private IConfigurationElement fConfigurationElement; + + private String fModelIdentifier; + + private IStepFilter fDelegate; + + public StepFilter(IConfigurationElement element) throws CoreException { + fConfigurationElement = element; + fModelIdentifier = fConfigurationElement.getAttribute(IConfigurationElementConstants.MODEL_IDENTIFIER); + if (fModelIdentifier == null) { + throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugPlugin.ERROR, DebugCoreMessages.StepFilter_0, null)); + } + String className = fConfigurationElement.getAttribute(IConfigurationElementConstants.CLASS); + if (className == null) { + throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugPlugin.ERROR, DebugCoreMessages.StepFilter_1, null)); + } + } + + /** + * Returns step filters for the given model identifier. + * + * @param modelIdentifier the model identifier for which step filters are + * requested + * @return step filters + */ + public IStepFilter[] getStepFilters(String modelIdentifier) { + if (fModelIdentifier.equals(modelIdentifier)) { + IStepFilter delegate = getDelegate(); + return new IStepFilter[] { delegate }; + } + return new IStepFilter[0]; + } + + /** + * Returns the IStepFilter for this extension. + * + * @return the {@link IStepFilter} + */ + protected IStepFilter getDelegate() { + if (fDelegate == null) { + try { + fDelegate = (IStepFilter) fConfigurationElement.createExecutableExtension(IConfigurationElementConstants.CLASS); + } catch (CoreException e) { + DebugPlugin.log(e); + } + } + return fDelegate; + } + +} diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/StepFilterManager.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/StepFilterManager.java index 37f05ced6..12266e2fd 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/StepFilterManager.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/StepFilterManager.java @@ -10,11 +10,18 @@ *******************************************************************************/ package org.eclipse.debug.internal.core; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.Platform; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunchListener; import org.eclipse.debug.core.commands.IStepFiltersHandler; +import org.eclipse.debug.core.model.IStepFilter; import org.eclipse.debug.internal.core.commands.DebugCommandRequest; /** @@ -88,4 +95,42 @@ public class StepFilterManager implements ILaunchListener { */ @Override public void launchRemoved(ILaunch launch) {} + + /** + * Returns any step filters that have been contributed for the given model + * identifier. + * + * @param modelIdentifier the model identifier + * @return step filters that have been contributed for the given model + * identifier, possibly an empty collection + * @since 3.9 + * @see org.eclipse.debug.core.model.IStepFilter + */ + public IStepFilter[] getStepFilters(String modelIdentifier) { + initialize(); + List<IStepFilter> select = new ArrayList<IStepFilter>(); + for (StepFilter extension : stepFilters) { + for (IStepFilter stepFilter : extension.getStepFilters(modelIdentifier)) { + select.add(stepFilter); + } + } + return select.toArray(new IStepFilter[select.size()]); + } + + private List<StepFilter> stepFilters = null; + + private synchronized void initialize() { + if (stepFilters == null) { + IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(DebugPlugin.getUniqueIdentifier(), DebugPlugin.EXTENSION_POINT_STEP_FILTERS); + IConfigurationElement[] extensions = point.getConfigurationElements(); + stepFilters = new ArrayList<StepFilter>(); + for (IConfigurationElement extension : extensions) { + try { + stepFilters.add(new StepFilter(extension)); + } catch (CoreException e) { + DebugPlugin.log(e); + } + } + } + } } diff --git a/org.eclipse.debug.core/plugin.properties b/org.eclipse.debug.core/plugin.properties index 4cc7b0879..4878f35d1 100644 --- a/org.eclipse.debug.core/plugin.properties +++ b/org.eclipse.debug.core/plugin.properties @@ -24,6 +24,7 @@ watchExpressionDelegatesName= Watch Expression Delegates processFactoriesExtensionPointName=Process Factories logicalStructureTypesExtensionPointName=Logical Structure Types logicalStructureProvidersExtensionPointName=Logical Structure Providers +stepFiltersExtensionPointName=Step Filters sourceContainerTypesName = Source Container Types sourcePathComputersName = Source Path Computers diff --git a/org.eclipse.debug.core/plugin.xml b/org.eclipse.debug.core/plugin.xml index 989b29a13..b5ef8fde5 100644 --- a/org.eclipse.debug.core/plugin.xml +++ b/org.eclipse.debug.core/plugin.xml @@ -30,6 +30,7 @@ <extension-point id="sourcePathComputers" name="%sourcePathComputersName" schema="schema/sourcePathComputers.exsd"/> <extension-point id="logicalStructureProviders" name="%logicalStructureProvidersExtensionPointName" schema="schema/logicalStructureProviders.exsd"/> <extension-point id="breakpointImportParticipants" name="%breakpointImportParticipantsExtensionPoint.name" schema="schema/breakpointImportParticipants.exsd"/> + <extension-point id="stepFilters" name="%stepFiltersExtensionPointName" schema="schema/stepFilters.exsd"/> <!-- Extensions --> <extension diff --git a/org.eclipse.debug.core/schema/stepFilters.exsd b/org.eclipse.debug.core/schema/stepFilters.exsd new file mode 100644 index 000000000..7c10e1105 --- /dev/null +++ b/org.eclipse.debug.core/schema/stepFilters.exsd @@ -0,0 +1,126 @@ +<?xml version='1.0' encoding='UTF-8'?> +<!-- Schema file written by PDE --> +<schema targetNamespace="org.eclipse.debug.core" xmlns="http://www.w3.org/2001/XMLSchema"> +<annotation> + <appInfo> + <meta.schema plugin="org.eclipse.debug.core" id="stepFilters" name="Step Filters"/> + </appInfo> + <documentation> + This extension point allows contributors to provide multiple step filters for a model identifier. + </documentation> + </annotation> + + <element name="extension"> + <annotation> + <appInfo> + <meta.element /> + </appInfo> + </annotation> + <complexType> + <sequence> + <element ref="stepFilter" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + <attribute name="point" type="string" use="required"> + <annotation> + <documentation> + a fully qualified identifier of the target extension point + </documentation> + </annotation> + </attribute> + <attribute name="id" type="string"> + <annotation> + <documentation> + an optional identifier of the extension instance + </documentation> + </annotation> + </attribute> + <attribute name="name" type="string"> + <annotation> + <documentation> + an optional name of the extension instance + </documentation> + <appInfo> + <meta.attribute translatable="true"/> + </appInfo> + </annotation> + </attribute> + </complexType> + </element> + + <element name="stepFilter"> + <complexType> + <attribute name="class" type="string" use="required"> + <annotation> + <documentation> + fully qualified name of a Java class that implements <code>IStepFilter</code>. + </documentation> + <appInfo> + <meta.attribute kind="java" basedOn=":org.eclipse.debug.core.model.IStepFilter"/> + </appInfo> + </annotation> + </attribute> + <attribute name="modelIdentifier" type="string" use="required"> + <annotation> + <documentation> + identifier of the debug model this step filter is associated with + </documentation> + </annotation> + </attribute> + </complexType> + </element> + + <annotation> + <appInfo> + <meta.section type="since"/> + </appInfo> + <documentation> + 3.9 + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="examples"/> + </appInfo> + <documentation> + The following is an example of a step filter extension point: + +<p> +<pre> + <extension point="org.eclipse.debug.core.stepFilters"> + <stepFilter + class="com.example.ExampleStepFilter" + modelIdentifier="com.example.debug.model"> + </stepFilter> + </extension> +</pre> +</p> + +In the example above, the specified step filter will be used for the <code>com.example.debug.model</code> debug model. + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="apiInfo"/> + </appInfo> + <documentation> + Value of the attribute <b>class</b> must be a fully qualified name of a Java class that implements the interface <b>org.eclipse.debug.core.model.IStepFilter</b>. + </documentation> + </annotation> + + + <annotation> + <appInfo> + <meta.section type="copyright"/> + </appInfo> + <documentation> + Copyright (c) 2014 itemis AG (http://www.itemis.eu) and others.<br> +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 +<a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a> + </documentation> + </annotation> + +</schema> diff --git a/org.eclipse.debug.tests/META-INF/MANIFEST.MF b/org.eclipse.debug.tests/META-INF/MANIFEST.MF index 54d5bec36..cc3622a9d 100644 --- a/org.eclipse.debug.tests/META-INF/MANIFEST.MF +++ b/org.eclipse.debug.tests/META-INF/MANIFEST.MF @@ -22,5 +22,6 @@ Export-Package: org.eclipe.debug.tests.launching, org.eclipse.debug.tests, org.eclipse.debug.tests.breakpoint, org.eclipse.debug.tests.expressions, - org.eclipse.debug.tests.statushandlers + org.eclipse.debug.tests.statushandlers, + org.eclipse.debug.tests.stepfilters Eclipse-BundleShape: dir diff --git a/org.eclipse.debug.tests/plugin.xml b/org.eclipse.debug.tests/plugin.xml index 62504e846..db6a364c1 100644 --- a/org.eclipse.debug.tests/plugin.xml +++ b/org.eclipse.debug.tests/plugin.xml @@ -95,5 +95,12 @@ icon="icons/image2.gif" id="type.image.2"> </launchConfigurationTypeImage> + </extension> + <extension + point="org.eclipse.debug.core.stepFilters"> + <stepFilter + class="org.eclipse.debug.tests.stepfilters.TestStepFilter" + modelIdentifier="com.example.debug.model"> + </stepFilter> </extension> </plugin> diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/AutomatedSuite.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/AutomatedSuite.java index 7fb3eacdc..a9af48ed1 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/AutomatedSuite.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/AutomatedSuite.java @@ -34,32 +34,33 @@ import org.eclipe.debug.tests.viewer.model.VirtualViewerStateTests; import org.eclipe.debug.tests.viewer.model.VirtualViewerUpdateTests; import org.eclipse.debug.tests.breakpoint.BreakpointOrderingTests; import org.eclipse.debug.tests.statushandlers.StatusHandlerTests; +import org.eclipse.debug.tests.stepfilters.StepFiltersTests; /** * Tests for integration and nightly builds. - * - * @since 3.6 + * + * @since 3.6 */ public class AutomatedSuite extends TestSuite { /** * Returns the suite. This is required to use the JUnit Launcher. - * + * * @return the test suite */ public static Test suite() { return new AutomatedSuite(); } - + /** - * Constructs the automated test suite. Adds all tests. + * Constructs the automated test suite. Adds all tests. */ public AutomatedSuite() { addTest(new TestSuite(BreakpointOrderingTests.class)); - // Note: jface viewer tests were moved out of nightly tests - // due to frequent problems on nightly build machines. - // (Bug 343308). - + // Note: jface viewer tests were moved out of nightly tests + // due to frequent problems on nightly build machines. + // (Bug 343308). + // Virtual viewer tests addTest(new TestSuite(VirtualViewerDeltaTests.class)); addTest(new TestSuite(VirtualViewerContentTests.class)); @@ -68,15 +69,15 @@ public class AutomatedSuite extends TestSuite { addTest(new TestSuite(VirtualViewerStateTests.class)); addTest(new TestSuite(VirtualViewerUpdateTests.class)); addTest(new TestSuite(VirtualViewerFilterTests.class)); - + // Viewer neutral tests addTest(new TestSuite(FilterTransformTests.class)); addTest(new TestSuite(ChildrenUpdateTests.class)); addTest(new TestSuite(PresentationContextTests.class)); - + // Memory view addTest(new TestSuite(MemoryRenderingTests.class)); - + // Launch framework addTest(new TestSuite(LaunchConfigurationTests.class)); addTest(new TestSuite(AcceleratorSubstitutionTests.class)); @@ -85,8 +86,11 @@ public class AutomatedSuite extends TestSuite { addTest(new TestSuite(LaunchManagerTests.class)); addTest(new TestSuite(RefreshTabTests.class)); addTest(new TestSuite(ArgumentParsingTests.class)); - + // Status handlers addTest(new TestSuite(StatusHandlerTests.class)); + + // Step filters + addTest(new TestSuite(StepFiltersTests.class)); } } diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/stepfilters/StepFiltersTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/stepfilters/StepFiltersTests.java new file mode 100644 index 000000000..d93ec822a --- /dev/null +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/stepfilters/StepFiltersTests.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2014 itemis AG (http://www.itemis.eu) 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 + *******************************************************************************/ +package org.eclipse.debug.tests.stepfilters; + +import junit.framework.TestCase; + +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.model.IStepFilter; + +/** + * Tests step filters + */ +public class StepFiltersTests extends TestCase { + + public void testStepFitlersExtension_01() { + IStepFilter[] stepFilters = DebugPlugin.getStepFilters("com.example.lalala.model"); //$NON-NLS-1$ + assertNotNull(stepFilters); + assertEquals(0, stepFilters.length); + } + + public void testStepFitlersExtension_02() { + IStepFilter[] stepFilters = DebugPlugin.getStepFilters("com.example.debug.model"); //$NON-NLS-1$ + assertNotNull(stepFilters); + assertEquals(1, stepFilters.length); + + assertTrue(stepFilters[0].isFiltered(Boolean.TRUE)); + assertFalse(stepFilters[0].isFiltered(Boolean.FALSE)); + assertFalse(stepFilters[0].isFiltered(new Object())); + } + +} diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/stepfilters/TestStepFilter.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/stepfilters/TestStepFilter.java new file mode 100644 index 000000000..613ca7adf --- /dev/null +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/stepfilters/TestStepFilter.java @@ -0,0 +1,22 @@ +/******************************************************************************* + * Copyright (c) 2014 itemis AG (http://www.itemis.eu) 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 + *******************************************************************************/ +package org.eclipse.debug.tests.stepfilters; + +import org.eclipse.debug.core.model.IStepFilter; + +public class TestStepFilter implements IStepFilter { + + @Override + public boolean isFiltered(Object object) { + if (object instanceof Boolean) { + return (Boolean) object; + } + return false; + } + +} |