Skip to content

Commit 9155d5a

Browse files
committed
[E4 XPath] Deprecate unsuitable XPathContextFactory methods for removal
1 parent 35966f3 commit 9155d5a

File tree

9 files changed

+25
-8
lines changed

9 files changed

+25
-8
lines changed

bundles/org.eclipse.e4.emf.xpath/META-INF/MANIFEST.MF

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: %Bundle-Name
4-
Bundle-SymbolicName: org.eclipse.e4.emf.xpath
4+
Bundle-SymbolicName: org.eclipse.e4.emf.xpath;deprecated:="This bundle is deprecated since 2025-03 (removal in 2027-03 or later)"
55
Bundle-Version: 0.6.0.qualifier
66
Bundle-RequiredExecutionEnvironment: JavaSE-17
77
Require-Bundle: org.eclipse.emf.ecore;bundle-version="2.35.0",

bundles/org.eclipse.e4.emf.xpath/src/org/eclipse/e4/emf/xpath/EcoreXPathContextFactory.java

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
*
2222
* @since 1.0
2323
*/
24+
@Deprecated(forRemoval = true, since = "2025-03 (removal in 2027-03 or later)")
2425
public class EcoreXPathContextFactory {
2526

2627
/**

bundles/org.eclipse.e4.emf.xpath/src/org/eclipse/e4/emf/xpath/XPathContext.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2010, 2024 BestSolution.at and others.
2+
* Copyright (c) 2010, 2025 BestSolution.at and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -23,7 +23,11 @@
2323
* Context in which the xpath is executed
2424
*
2525
* @since 1.0
26+
* @deprecated To query an E4-model use
27+
* {@code org.eclipse.e4.ui.workbench.modeling.EModelService#findMatchingElements(org.eclipse.e4.ui.model.application.MApplicationElement, String, Class)}
28+
* instead.
2629
*/
30+
@Deprecated(forRemoval = true, since = "2025-03 (removal in 2027-03 or later)")
2731
public interface XPathContext {
2832

2933
/**

bundles/org.eclipse.e4.emf.xpath/src/org/eclipse/e4/emf/xpath/XPathContextFactory.java

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2010, 2024 BestSolution.at and others.
2+
* Copyright (c) 2010, 2025 BestSolution.at and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -19,7 +19,11 @@
1919
* Factory responsible to create an XPath-Context
2020
*
2121
* @param <T> the object type the XPath is created for
22+
* @deprecated To query an E4-model use
23+
* {@code org.eclipse.e4.ui.workbench.modeling.EModelService#findMatchingElements(org.eclipse.e4.ui.model.application.MApplicationElement, String, Class)}
24+
* instead.
2225
*/
26+
@Deprecated(forRemoval = true, since = "2025-03 (removal in 2027-03 or later)")
2327
public abstract class XPathContextFactory<T> {
2428

2529
/**
@@ -38,10 +42,15 @@ public abstract class XPathContextFactory<T> {
3842
* @param parentContext parent context
3943
* @param contextBean Object
4044
* @return XPathContext
45+
* @deprecated The parent-context does not provide any real value. Just use
46+
* {@link #newContext(Object)}
4147
*/
4248
public abstract XPathContext newContext(XPathContext parentContext, T contextBean);
4349

4450
/**
51+
* Creates a new {@code XPathContextFactory<EObject>} that's suitable to query
52+
* the E4-model.
53+
*
4554
* @param <T> the object type the xpath is created for
4655
* @return Create a new XPath-Factory
4756
*/

bundles/org.eclipse.e4.emf.xpath/src/org/eclipse/e4/emf/xpath/XPathNotFoundException.java

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
*
2121
* @since 0.6
2222
*/
23+
@Deprecated(forRemoval = true, since = "2025-03 (removal in 2027-03 or later)")
2324
public class XPathNotFoundException extends IllegalArgumentException {
2425
private static final long serialVersionUID = -4174244860692153739L;
2526

bundles/org.eclipse.e4.emf.xpath/src/org/eclipse/e4/emf/xpath/internal/java/JavaXPathContextFactoryImpl.java

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
import org.w3c.dom.Node;
5858
import org.w3c.dom.NodeList;
5959

60+
@SuppressWarnings({ "deprecation", "removal" })
6061
public class JavaXPathContextFactoryImpl<T> extends XPathContextFactory<T> {
6162

6263
private static final XPathFactory XPATH_FACTORY = XPathFactory.newInstance();

bundles/org.eclipse.e4.ui.model.workbench/src/org/eclipse/e4/ui/model/ModelXPathEvaluator.java

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
public class ModelXPathEvaluator {
2121

22+
@SuppressWarnings({ "deprecation", "removal" })
2223
public static <T> Stream<T> findMatchingElements(MApplicationElement searchRoot, String xPath, Class<T> clazz) {
2324
return XPathContextFactory.newInstance().newContext(searchRoot).stream(xPath, clazz);
2425
}

tests/org.eclipse.e4.emf.xpath.test/src/org/eclipse/e4/emf/xpath/test/ExampleQueriesApplicationTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
import java.util.List;
2121

22-
import org.eclipse.e4.emf.xpath.EcoreXPathContextFactory;
2322
import org.eclipse.e4.emf.xpath.XPathContext;
2423
import org.eclipse.e4.emf.xpath.XPathContextFactory;
2524
import org.eclipse.e4.ui.internal.workbench.E4XMIResourceFactory;
@@ -43,6 +42,7 @@
4342
import org.junit.Before;
4443
import org.junit.Test;
4544

45+
@SuppressWarnings({ "deprecation", "removal" })
4646
public class ExampleQueriesApplicationTest {
4747

4848
private ResourceSet resourceSet;
@@ -69,11 +69,11 @@ public void setUp() {
6969

7070
URI uri = URI.createPlatformPluginURI("/org.eclipse.e4.emf.xpath.test/model/Application.e4xmi", true);
7171
resource = resourceSet.getResource(uri, true);
72-
XPathContextFactory<EObject> f = EcoreXPathContextFactory.newInstance();
72+
XPathContextFactory<EObject> f = XPathContextFactory.newInstance();
7373
xpathContext = f.newContext(resource.getContents().get(0));
7474
URI childUri = URI.createPlatformPluginURI("/org.eclipse.e4.emf.xpath.test/model/fragment.e4xmi", true);
7575
childResource = resourceSet.getResource(childUri, true);
76-
xpathChildContext = f.newContext(xpathContext, childResource.getContents().get(0));
76+
xpathChildContext = f.newContext(childResource.getContents().get(0));
7777
}
7878

7979
@After

tests/org.eclipse.e4.emf.xpath.test/src/org/eclipse/e4/emf/xpath/test/ExampleQueriesTestCase.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import java.util.Iterator;
2626
import java.util.List;
2727

28-
import org.eclipse.e4.emf.xpath.EcoreXPathContextFactory;
2928
import org.eclipse.e4.emf.xpath.XPathContext;
3029
import org.eclipse.e4.emf.xpath.XPathContextFactory;
3130
import org.eclipse.e4.emf.xpath.XPathNotFoundException;
@@ -44,6 +43,7 @@
4443
import org.junit.Before;
4544
import org.junit.Test;
4645

46+
@SuppressWarnings({ "deprecation", "removal" })
4747
public class ExampleQueriesTestCase {
4848

4949
private ResourceSet resourceSet;
@@ -61,7 +61,7 @@ public void setUp() {
6161
resourceSet.getPackageRegistry().put(XpathtestPackage.eNS_URI, XpathtestPackage.eINSTANCE);
6262
URI uri = URI.createPlatformPluginURI("/org.eclipse.e4.emf.xpath.test/model/Test.xmi", true);
6363
resource = resourceSet.getResource(uri, true);
64-
xpathContextFactory = EcoreXPathContextFactory.newInstance();
64+
xpathContextFactory = XPathContextFactory.newInstance();
6565
xpathContext = xpathContextFactory.newContext(resource.getContents().get(0));
6666
}
6767

0 commit comments

Comments
 (0)