Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2021-08-12 20:32:43 +0000
committerPatrick Tessier2021-08-25 12:44:07 +0000
commit9f4df380ada74ce151aa8b13662778e6d91347a7 (patch)
tree17646ace5b6784220f6178989f390ea59a5d34b4
parentba3b120d290e31570535b2e418bdc4fa3cfc8879 (diff)
downloadorg.eclipse.papyrus-9f4df380ada74ce151aa8b13662778e6d91347a7.tar.gz
org.eclipse.papyrus-9f4df380ada74ce151aa8b13662778e6d91347a7.tar.xz
org.eclipse.papyrus-9f4df380ada74ce151aa8b13662778e6d91347a7.zip
Bug 575376: [Toolsmiths - Builder] Duplicate markers for Manifest validation
- define a new Java Problem Marker subtype for Papyrus plug-in problems to avoid interference with Java problems - implement the clean step in all Papyrus builders Change-Id: Idbd705494884f821d5a561a281325b421641d575 Signed-off-by: Christian W. Damus <give.a.damus@gmail.com>
-rwxr-xr-xplugins/toolsmiths/builder/org.eclipse.papyrus.toolsmiths.plugin.builder/META-INF/MANIFEST.MF4
-rw-r--r--plugins/toolsmiths/builder/org.eclipse.papyrus.toolsmiths.plugin.builder/OSGI-INF/l10n/bundle.properties10
-rwxr-xr-xplugins/toolsmiths/builder/org.eclipse.papyrus.toolsmiths.plugin.builder/plugin.xml40
-rw-r--r--[-rwxr-xr-x]plugins/toolsmiths/builder/org.eclipse.papyrus.toolsmiths.plugin.builder/src/org/eclipse/papyrus/toolsmiths/plugin/builder/AbstractPapyrusBuilder.java39
-rw-r--r--plugins/toolsmiths/builder/org.eclipse.papyrus.toolsmiths.plugin.builder/src/org/eclipse/papyrus/toolsmiths/plugin/builder/GenericEMFModelBuilder.java19
-rw-r--r--plugins/toolsmiths/builder/org.eclipse.papyrus.toolsmiths.plugin.builder/src/org/eclipse/papyrus/toolsmiths/plugin/builder/PluginCheckerBuilder.java21
-rw-r--r--plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.architecture/src/org/eclipse/papyrus/toolsmiths/validation/architecture/internal/checkers/ArchitectureCustomValidator.java9
7 files changed, 107 insertions, 35 deletions
diff --git a/plugins/toolsmiths/builder/org.eclipse.papyrus.toolsmiths.plugin.builder/META-INF/MANIFEST.MF b/plugins/toolsmiths/builder/org.eclipse.papyrus.toolsmiths.plugin.builder/META-INF/MANIFEST.MF
index a2145eac7ba..4a81a262de1 100755
--- a/plugins/toolsmiths/builder/org.eclipse.papyrus.toolsmiths.plugin.builder/META-INF/MANIFEST.MF
+++ b/plugins/toolsmiths/builder/org.eclipse.papyrus.toolsmiths.plugin.builder/META-INF/MANIFEST.MF
@@ -1,9 +1,9 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
-Bundle-Name: Papyrus Toolsmiths - Papyrus Plugin Builder
+Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.eclipse.papyrus.toolsmiths.plugin.builder;singleton:=true
Bundle-Version: 1.1.0.qualifier
-Bundle-Vendor: Eclipse Modeling Project
+Bundle-Vendor: %Bundle-Vendor
Automatic-Module-Name: org.eclipse.papyrus.infra.nattable.builder
Bundle-RequiredExecutionEnvironment: JavaSE-11
Bundle-ActivationPolicy: lazy
diff --git a/plugins/toolsmiths/builder/org.eclipse.papyrus.toolsmiths.plugin.builder/OSGI-INF/l10n/bundle.properties b/plugins/toolsmiths/builder/org.eclipse.papyrus.toolsmiths.plugin.builder/OSGI-INF/l10n/bundle.properties
new file mode 100644
index 00000000000..ef453820caf
--- /dev/null
+++ b/plugins/toolsmiths/builder/org.eclipse.papyrus.toolsmiths.plugin.builder/OSGI-INF/l10n/bundle.properties
@@ -0,0 +1,10 @@
+#Properties file for org.eclipse.papyrus.toolsmiths.plugin.builder
+Bundle-Vendor = Eclipse Modeling Project
+Bundle-Name = Papyrus Toolsmiths - Papyrus Plugin Builder
+builder.name = Papyrus Plugin Builder
+nature.name = Papyrus Plugin - Nature
+command.convert.name = Convert To Papyrus Plugin Command
+command.convert.label = Convert To Papyrus Plugin
+prefpage.name = Papyrus Plugin Builder
+problem.name = Papyrus Toolsmiths Plug-in Problem
+diagnostic.name = Papyrus Toolsmiths Model Problem
diff --git a/plugins/toolsmiths/builder/org.eclipse.papyrus.toolsmiths.plugin.builder/plugin.xml b/plugins/toolsmiths/builder/org.eclipse.papyrus.toolsmiths.plugin.builder/plugin.xml
index 5b575e475ab..3ad20034c64 100755
--- a/plugins/toolsmiths/builder/org.eclipse.papyrus.toolsmiths.plugin.builder/plugin.xml
+++ b/plugins/toolsmiths/builder/org.eclipse.papyrus.toolsmiths.plugin.builder/plugin.xml
@@ -3,7 +3,7 @@
<plugin>
<extension
id="org.eclipse.papyrus.plugin.builder"
- name="Papyrus Plugin Builder"
+ name="%builder.name"
point="org.eclipse.core.resources.builders">
<builder
callOnEmptyDelta="true"
@@ -16,7 +16,7 @@
</extension>
<extension
id="org.eclipse.papyrus.plugin.nature"
- name="Papyrus Plugin - Nature"
+ name="%nature.name"
point="org.eclipse.core.resources.natures">
<runtime>
<run
@@ -38,7 +38,7 @@
<command
defaultHandler="org.eclipse.papyrus.toolsmiths.plugin.builder.nature.AddPapyrusPluginNatureHandler"
id="org.eclipse.papyrus.toolsmiths.plugin.builder.addPapyrusNatureCommand"
- name="Convert To Papyrus Plugin Command">
+ name="%command.convert.name">
</command>
</extension>
<extension
@@ -49,7 +49,7 @@
<command
commandId="org.eclipse.papyrus.toolsmiths.plugin.builder.addPapyrusNatureCommand"
icon="icons/papyrus.png"
- label="Convert To Papyrus Plugin"
+ label="%command.convert.label"
style="push">
<visibleWhen
checkEnabled="true">
@@ -79,7 +79,7 @@
point="org.eclipse.ui.ide.markerResolution">
<markerResolutionGenerator
class="org.eclipse.papyrus.toolsmiths.plugin.builder.quickfix.ManifestResolutionGenerator"
- markerType="org.eclipse.jdt.core.problem">
+ markerType="org.eclipse.papyrus.toolsmiths.plugin.builder.problem">
</markerResolutionGenerator>
</extension>
<extension
@@ -87,7 +87,7 @@
<page
class="org.eclipse.papyrus.toolsmiths.plugin.builder.preferences.PluginBuilderPreferencePage"
id="org.eclipse.papyrus.toolsmiths.plugin.builder.BuilderPreferencePage"
- name="Papyrus Plugin Builder">
+ name="%prefpage.name">
</page>
</extension>
<extension
@@ -96,4 +96,32 @@
class="org.eclipse.papyrus.toolsmiths.plugin.builder.preferences.PluginBuilderPreferencesInitializer">
</initializer>
</extension>
+ <extension
+ id="problem"
+ name="%problem.name"
+ point="org.eclipse.core.resources.markers">
+ <super
+ type="org.eclipse.core.resources.problemmarker">
+ </super>
+ <super
+ type="org.eclipse.jdt.core.problem">
+ </super>
+ <persistent
+ value="true">
+ </persistent>
+ </extension>
+ <extension
+ id="diagnostic"
+ name="%diagnostic.name"
+ point="org.eclipse.core.resources.markers">
+ <super
+ type="org.eclipse.core.resources.problemmarker">
+ </super>
+ <super
+ type="org.eclipse.jdt.core.problem">
+ </super>
+ <persistent
+ value="true">
+ </persistent>
+ </extension>
</plugin>
diff --git a/plugins/toolsmiths/builder/org.eclipse.papyrus.toolsmiths.plugin.builder/src/org/eclipse/papyrus/toolsmiths/plugin/builder/AbstractPapyrusBuilder.java b/plugins/toolsmiths/builder/org.eclipse.papyrus.toolsmiths.plugin.builder/src/org/eclipse/papyrus/toolsmiths/plugin/builder/AbstractPapyrusBuilder.java
index 1f33d2eab0f..f8c9ec57ea6 100755..100644
--- a/plugins/toolsmiths/builder/org.eclipse.papyrus.toolsmiths.plugin.builder/src/org/eclipse/papyrus/toolsmiths/plugin/builder/AbstractPapyrusBuilder.java
+++ b/plugins/toolsmiths/builder/org.eclipse.papyrus.toolsmiths.plugin.builder/src/org/eclipse/papyrus/toolsmiths/plugin/builder/AbstractPapyrusBuilder.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2020 CEA LIST and others.
+ * Copyright (c) 2020, 2021 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -10,6 +10,7 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) <vincent.lorenzo@cea.fr> - Initial API and implementation
+ * Christian W. Damus - bug 575376
*
*****************************************************************************/
package org.eclipse.papyrus.toolsmiths.plugin.builder;
@@ -31,8 +32,38 @@ import org.eclipse.papyrus.emf.helpers.ProjectDependencyHelper;
*/
public abstract class AbstractPapyrusBuilder {
+ /** Problem marker ID for plug-in problems. */
+ public static final String PLUGIN_PROBLEM = Activator.PLUGIN_ID + ".problem"; //$NON-NLS-1$
+
+ /** Problem marker ID for generic model problems. */
+ public static final String MODEL_PROBLEM = Activator.PLUGIN_ID + ".diagnostic"; //$NON-NLS-1$
+
private ProjectDependencyHelper DEPENDENCY_HELPER = ProjectDependencyHelper.INSTANCE;
+ private final String defaultMarkerType;
+
+ public AbstractPapyrusBuilder(String defaultMarkerType) {
+ super();
+
+ this.defaultMarkerType = defaultMarkerType;
+ }
+
+ /**
+ * Initializes me with the <em>Papyrus Plug-in Problem</em> marker type.
+ */
+ public AbstractPapyrusBuilder() {
+ this(PLUGIN_PROBLEM);
+ }
+
+ /**
+ * Query the default marker type used for markers when the type is not otherwise specified.
+ *
+ * @return the default marker type
+ */
+ protected String getDefaultMarkerType() {
+ return defaultMarkerType;
+ }
+
/**
* Run the build on the specified project.
*
@@ -60,7 +91,7 @@ public abstract class AbstractPapyrusBuilder {
* @throws CoreException
*/
public void clean(IProgressMonitor monitor, IProject iProject) throws CoreException {
- // default implementation does nothing
+ iProject.deleteMarkers(getDefaultMarkerType(), true, IResource.DEPTH_INFINITE);
}
/**
@@ -77,9 +108,9 @@ public abstract class AbstractPapyrusBuilder {
// later, we can create our own type, with a specific handler to open our own error dialog appearing during the launching of a new Eclipse runtime
IMarker marker = null;
try {
- marker = res.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER);
+ marker = res.createMarker(getDefaultMarkerType());
- marker.setAttribute(IMarker.MESSAGE, Messages.AbstractPapyrusBuilder_PapyrusBuilder + message); //$NON-NLS-1$
+ marker.setAttribute(IMarker.MESSAGE, Messages.AbstractPapyrusBuilder_PapyrusBuilder + message);
marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
marker.setAttribute("code", 10000); //$NON-NLS-1$
marker.setAttribute(IMarker.SOURCE_ID, Activator.PLUGIN_ID);
diff --git a/plugins/toolsmiths/builder/org.eclipse.papyrus.toolsmiths.plugin.builder/src/org/eclipse/papyrus/toolsmiths/plugin/builder/GenericEMFModelBuilder.java b/plugins/toolsmiths/builder/org.eclipse.papyrus.toolsmiths.plugin.builder/src/org/eclipse/papyrus/toolsmiths/plugin/builder/GenericEMFModelBuilder.java
index 0040afcaa9a..4ee998081d5 100644
--- a/plugins/toolsmiths/builder/org.eclipse.papyrus.toolsmiths.plugin.builder/src/org/eclipse/papyrus/toolsmiths/plugin/builder/GenericEMFModelBuilder.java
+++ b/plugins/toolsmiths/builder/org.eclipse.papyrus.toolsmiths.plugin.builder/src/org/eclipse/papyrus/toolsmiths/plugin/builder/GenericEMFModelBuilder.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) <vincent.lorenzo@cea.fr> - Initial API and implementation
- * Christian W. Damus - bugs 569357, 570097, 572644, 573408
+ * Christian W. Damus - bugs 569357, 570097, 572644, 573408, 575376
*
*****************************************************************************/
@@ -57,7 +57,6 @@ import org.eclipse.emf.ecore.util.Diagnostician;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.xmi.XMLResource;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
-import org.eclipse.jdt.core.IJavaModelMarker;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
@@ -151,6 +150,10 @@ public class GenericEMFModelBuilder extends AbstractPapyrusBuilder {
// IGNORED_NS_URI.add("http://www.eclipse.org/uml2/schemas/Ecore/5");
}
+ public GenericEMFModelBuilder() {
+ super(MODEL_PROBLEM);
+ }
+
@Override
public IProject[] build(IProject builtProject, PapyrusPluginBuilder papyrusBuilder, int kind, Map<String, String> args, IProgressMonitor monitor) throws CoreException {
if (true) {
@@ -345,8 +348,14 @@ public class GenericEMFModelBuilder extends AbstractPapyrusBuilder {
if (!isIgnoredNS_URI(current.getURI().toString()) && managedFileExtension(current.getURI().fileExtension())
&& !hasSpecificBuilder(current.getURI())) {
try {
- dependencies.add(getBundleNameFromResource(current));
- dependencies.addAll(getModelBundleDependenciesFromXML(resource));
+ String bundleName = getBundleNameFromResource(current);
+ if (bundleName != null) {
+ dependencies.add(bundleName);
+ }
+ Set<String> modelDependencies = getModelBundleDependenciesFromXML(resource);
+ if (modelDependencies != null && !modelDependencies.isEmpty()) {
+ dependencies.addAll(modelDependencies);
+ }
} catch (Exception e) {
}
}
@@ -529,7 +538,7 @@ public class GenericEMFModelBuilder extends AbstractPapyrusBuilder {
}
protected String getMarkerType() {
- return IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER;
+ return getDefaultMarkerType();
}
/**
diff --git a/plugins/toolsmiths/builder/org.eclipse.papyrus.toolsmiths.plugin.builder/src/org/eclipse/papyrus/toolsmiths/plugin/builder/PluginCheckerBuilder.java b/plugins/toolsmiths/builder/org.eclipse.papyrus.toolsmiths.plugin.builder/src/org/eclipse/papyrus/toolsmiths/plugin/builder/PluginCheckerBuilder.java
index 64e49f148f9..00ca8c7ad20 100644
--- a/plugins/toolsmiths/builder/org.eclipse.papyrus.toolsmiths.plugin.builder/src/org/eclipse/papyrus/toolsmiths/plugin/builder/PluginCheckerBuilder.java
+++ b/plugins/toolsmiths/builder/org.eclipse.papyrus.toolsmiths.plugin.builder/src/org/eclipse/papyrus/toolsmiths/plugin/builder/PluginCheckerBuilder.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2020 CEA LIST, EclipseSource, Christian W. Damus, and others.
+ * Copyright (c) 2020, 2021 CEA LIST, EclipseSource, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -10,7 +10,7 @@
*
* Contributors:
* Remi Schnekenburger - Initial API and implementation
- * Christian W. Damus - bug 569357
+ * Christian W. Damus - bugs 569357, 575376
*
*****************************************************************************/
@@ -26,7 +26,6 @@ import java.util.stream.Stream;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.SubMonitor;
@@ -46,7 +45,6 @@ import com.google.common.collect.ListMultimap;
*/
public class PluginCheckerBuilder extends AbstractPapyrusBuilder {
- private final String defaultMarkerType;
private final Function<? super IProject, ListMultimap<IFile, ? extends EObject>> mapperFunction;
private final List<IPluginChecker2.Factory> checkerFactories = new ArrayList<>();
@@ -56,9 +54,8 @@ public class PluginCheckerBuilder extends AbstractPapyrusBuilder {
* Initializes me with a function that maps files in the validated project to EMF model elements.
* By default, I create PDE Problem markers.
*/
- @SuppressWarnings("restriction")
public PluginCheckerBuilder(Function<? super IProject, ListMultimap<IFile, ? extends EObject>> mapperFunction) {
- this(org.eclipse.pde.internal.core.builders.PDEMarkerFactory.MARKER_ID, mapperFunction);
+ this(PLUGIN_PROBLEM, mapperFunction);
}
/**
@@ -66,9 +63,8 @@ public class PluginCheckerBuilder extends AbstractPapyrusBuilder {
* and a specific default marker type to create.
*/
public PluginCheckerBuilder(String defaultMarkerType, Function<? super IProject, ListMultimap<IFile, ? extends EObject>> mapperFunction) {
- super();
+ super(defaultMarkerType);
- this.defaultMarkerType = defaultMarkerType;
this.mapperFunction = mapperFunction;
}
@@ -98,11 +94,6 @@ public class PluginCheckerBuilder extends AbstractPapyrusBuilder {
}
@Override
- public void clean(IProgressMonitor monitor, IProject iProject) throws CoreException {
- iProject.deleteMarkers(defaultMarkerType, true, IResource.DEPTH_INFINITE);
- }
-
- @Override
public IProject[] build(IProject builtProject, PapyrusPluginBuilder papyrusBuilder, int kind, Map<String, String> args, IProgressMonitor monitor) throws CoreException {
if (papyrusBuilder.isInterrupted() || monitor.isCanceled()) {
return null;
@@ -176,7 +167,7 @@ public class PluginCheckerBuilder extends AbstractPapyrusBuilder {
}
private IMarker createMarker(IFile file, Diagnostic diagnostic) {
- return MarkersService.createMarker(file, IPluginChecker2.getMarkerType(diagnostic).orElse(defaultMarkerType), diagnostic);
+ return MarkersService.createMarker(file, IPluginChecker2.getMarkerType(diagnostic).orElse(getDefaultMarkerType()), diagnostic);
}
/**
@@ -186,7 +177,7 @@ public class PluginCheckerBuilder extends AbstractPapyrusBuilder {
*/
private Diagnostic wrap(Diagnostic diagnostic) {
return IPluginChecker2.getMarkerType(diagnostic).isEmpty()
- ? diagnosticEquivalence.wrap(diagnostic, IPluginChecker2.markerType(defaultMarkerType))
+ ? diagnosticEquivalence.wrap(diagnostic, IPluginChecker2.markerType(getDefaultMarkerType()))
: diagnosticEquivalence.wrap(diagnostic);
}
diff --git a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.architecture/src/org/eclipse/papyrus/toolsmiths/validation/architecture/internal/checkers/ArchitectureCustomValidator.java b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.architecture/src/org/eclipse/papyrus/toolsmiths/validation/architecture/internal/checkers/ArchitectureCustomValidator.java
index 77567166dab..ca3a7741e5c 100644
--- a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.architecture/src/org/eclipse/papyrus/toolsmiths/validation/architecture/internal/checkers/ArchitectureCustomValidator.java
+++ b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.architecture/src/org/eclipse/papyrus/toolsmiths/validation/architecture/internal/checkers/ArchitectureCustomValidator.java
@@ -20,6 +20,7 @@ import static org.eclipse.papyrus.toolsmiths.validation.common.internal.utils.Pr
import static org.eclipse.papyrus.toolsmiths.validation.common.internal.utils.ProjectManagementUtils.resourcePathIs;
import java.util.Collection;
+import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@@ -83,9 +84,11 @@ public class ArchitectureCustomValidator extends CustomModelChecker.SwitchValida
}
private void validateElementTypesContextID(ArchitectureContext architecture, ElementTypeSetConfiguration typeSet, DiagnosticChain diagnostics, Map<Object, Object> context) {
- Collection<IPluginElement> registrations = getExtensionElements(IElementTypeSetExtensionPoint.EXTENSION_POINT_ID, ELEM_ELEMENT_TYPE_SET)
- .filter(resourcePathIs(IElementTypeSetExtensionPoint.PATH, typeSet.eResource().getURI()))
- .collect(Collectors.toList());
+ Collection<IPluginElement> registrations = typeSet == null || typeSet.eIsProxy()
+ ? List.of()
+ : getExtensionElements(IElementTypeSetExtensionPoint.EXTENSION_POINT_ID, ELEM_ELEMENT_TYPE_SET)
+ .filter(resourcePathIs(IElementTypeSetExtensionPoint.PATH, typeSet.eResource().getURI()))
+ .collect(Collectors.toList());
if (!registrations.isEmpty() && registrations.stream().noneMatch(hasAttribute(IElementTypeSetExtensionPoint.CLIENT_CONTEXT_ID, architecture.getId()::equals))) {
diagnostics.add(createDiagnostic(Diagnostic.WARNING, architecture, format(Messages.ArchitectureCustomValidator_2, context, typeSet)));

Back to the top