summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCurtis Windatt2013-06-14 15:58:20 (EDT)
committerCurtis Windatt2013-06-14 15:58:20 (EDT)
commit32f69281a815efa3fc954f1fc03f7f597d7053bc (patch)
treefb901088d607d11800c1e3bef41a1f5e53bf126f
parenta2997341e208fd4906cb70eb866fbf24071ca79d (diff)
downloadeclipse.pde.ui-32f69281a815efa3fc954f1fc03f7f597d7053bc.zip
eclipse.pde.ui-32f69281a815efa3fc954f1fc03f7f597d7053bc.tar.gz
eclipse.pde.ui-32f69281a815efa3fc954f1fc03f7f597d7053bc.tar.bz2
Bug 305149 - PDE warns that symbolic names containing dash ('-')
characters are invalid when specified in the id attribute of the plugin element of a feature.xml Change-Id: I7e12f4d0069c625447983359ceb1e1ccf341bcac
-rw-r--r--ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDECoreMessages.java1
-rw-r--r--ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/FeatureErrorReporter.java43
-rw-r--r--ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/ManifestErrorReporter.java16
-rw-r--r--ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/pderesources.properties1
4 files changed, 39 insertions, 22 deletions
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDECoreMessages.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDECoreMessages.java
index 428aa33..1094fdb 100644
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDECoreMessages.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDECoreMessages.java
@@ -148,6 +148,7 @@ public class PDECoreMessages extends NLS {
public static String Builders_Manifest_attribute;
public static String Builders_Manifest_att_value;
public static String Builders_Manifest_compositeID;
+ public static String Builders_Manifest_pluginID;
public static String Builders_Manifest_simpleID;
public static String Builders_Manifest_non_ext_attribute;
public static String Builders_Manifest_non_ext_element;
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/FeatureErrorReporter.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/FeatureErrorReporter.java
index 6c93a8a..089528f 100644
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/FeatureErrorReporter.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/FeatureErrorReporter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2012 IBM Corporation and others.
+ * Copyright (c) 2005, 2013 IBM Corporation 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
@@ -22,6 +22,7 @@ import org.eclipse.pde.internal.core.ibundle.IBundlePluginModel;
import org.eclipse.pde.internal.core.ibundle.IManifestHeader;
import org.eclipse.pde.internal.core.ifeature.IFeatureModel;
import org.eclipse.pde.internal.core.util.CoreUtility;
+import org.eclipse.pde.internal.core.util.IdUtil;
import org.w3c.dom.*;
public class FeatureErrorReporter extends ManifestErrorReporter {
@@ -85,9 +86,6 @@ public class FeatureErrorReporter extends ManifestErrorReporter {
}
}
- /**
- * @param element
- */
private void validatePlugins(Element parent) {
NodeList list = getChildrenByName(parent, "plugin"); //$NON-NLS-1$
for (int i = 0; i < list.getLength(); i++) {
@@ -102,7 +100,7 @@ public class FeatureErrorReporter extends ManifestErrorReporter {
Attr attr = (Attr) attributes.item(j);
String name = attr.getName();
if (name.equals("id")) { //$NON-NLS-1$
- validatePluginID(plugin, attr, isFragment);
+ validatePluginExists(plugin, attr, isFragment);
} else if (name.equals("version")) { //$NON-NLS-1$
validateVersionAttribute(plugin, attr);
validateVersion(plugin, attr);
@@ -139,9 +137,9 @@ public class FeatureErrorReporter extends ManifestErrorReporter {
} else if (plugin != null && feature != null) {
reportExclusiveAttributes(element, "plugin", "feature", CompilerFlags.ERROR); //$NON-NLS-1$//$NON-NLS-2$
} else if (plugin != null) {
- validatePluginID(element, plugin, false);
+ validatePluginExists(element, plugin, false);
} else if (feature != null) {
- validateFeatureID(element, feature);
+ validateFeatureExists(element, feature);
}
NamedNodeMap attributes = element.getAttributes();
for (int j = 0; j < attributes.getLength(); j++) {
@@ -182,7 +180,7 @@ public class FeatureErrorReporter extends ManifestErrorReporter {
&& assertAttributeDefined(include, "version", //$NON-NLS-1$
CompilerFlags.ERROR)) {
- validateFeatureID(include, include.getAttributeNode("id")); //$NON-NLS-1$
+ validateFeatureExists(include, include.getAttributeNode("id")); //$NON-NLS-1$
}
NamedNodeMap attributes = include.getAttributes();
for (int j = 0; j < attributes.getLength(); j++) {
@@ -350,7 +348,7 @@ public class FeatureErrorReporter extends ManifestErrorReporter {
if (!attrs.contains(name)) {
reportUnknownAttribute(element, name, CompilerFlags.ERROR);
} else if (name.equals("id")) { //$NON-NLS-1$
- validatePluginID(element, (Attr) attributes.item(i));
+ validateFeatureID(element, (Attr) attributes.item(i));
} else if (name.equals("primary") || name.equals("exclusive")) { //$NON-NLS-1$ //$NON-NLS-2$
validateBoolean(element, (Attr) attributes.item(i));
} else if (name.equals("version")) { //$NON-NLS-1$
@@ -359,16 +357,31 @@ public class FeatureErrorReporter extends ManifestErrorReporter {
if (name.equals("primary")) { //$NON-NLS-1$
reportDeprecatedAttribute(element, (Attr) attributes.item(i));
} else if (name.equals("plugin")) { //$NON-NLS-1$
- validatePluginID(element, (Attr) attributes.item(i), false);
+ validatePluginExists(element, (Attr) attributes.item(i), false);
}
}
}
- private void validatePluginID(Element element, Attr attr, boolean isFragment) {
- String id = attr.getValue();
- if (!validatePluginID(element, attr)) {
- return;
+ /**
+ * Checks whether the given attribute value is a valid feature ID. If it is not valid, a marker
+ * is created on the element and <code>false</code> is returned. If valid, <code>true</code> is
+ * returned. Also see {@link #validatePluginID(Element, Attr)}
+ *
+ * @param element element to add the marker to if invalid
+ * @param attr the attribute to check the value of
+ * @return whether the given attribute value is a valid feature ID.
+ */
+ protected boolean validateFeatureID(Element element, Attr attr) {
+ if (!IdUtil.isValidCompositeID(attr.getValue())) {
+ String message = NLS.bind(PDECoreMessages.Builders_Manifest_compositeID, attr.getValue(), attr.getName());
+ report(message, getLine(element, attr.getName()), CompilerFlags.WARNING, PDEMarkerFactory.CAT_OTHER);
+ return false;
}
+ return true;
+ }
+
+ private void validatePluginExists(Element element, Attr attr, boolean isFragment) {
+ String id = attr.getValue();
int severity = CompilerFlags.getFlag(fProject, CompilerFlags.F_UNRESOLVED_PLUGINS);
if (severity != CompilerFlags.IGNORE) {
IPluginModelBase model = PluginRegistry.findModel(id);
@@ -378,7 +391,7 @@ public class FeatureErrorReporter extends ManifestErrorReporter {
}
}
- private void validateFeatureID(Element element, Attr attr) {
+ private void validateFeatureExists(Element element, Attr attr) {
int severity = CompilerFlags.getFlag(fProject, CompilerFlags.F_UNRESOLVED_FEATURES);
if (severity != CompilerFlags.IGNORE) {
IFeatureModel[] models = PDECore.getDefault().getFeatureModelManager().findFeatureModels(attr.getValue());
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/ManifestErrorReporter.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/ManifestErrorReporter.java
index 742165a..6b15490 100644
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/ManifestErrorReporter.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/ManifestErrorReporter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2012 IBM Corporation and others.
+ * Copyright (c) 2005, 2013 IBM Corporation 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
@@ -10,8 +10,6 @@
*******************************************************************************/
package org.eclipse.pde.internal.core.builders;
-import org.w3c.dom.Node;
-
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
@@ -118,13 +116,17 @@ public class ManifestErrorReporter extends XMLErrorReporter {
}
/**
- * @param element
- * @param attr
- * @return false if failed
+ * Checks whether the given attribute value is a valid bundle ID. If it is not valid, a marker
+ * is created on the element and <code>false</code> is returned. If valid, <code>true</code> is
+ * returned.
+ *
+ * @param element element to add the marker to if invalid
+ * @param attr the attribute to check the value of
+ * @return whether the given attribute value is a valid bundle ID.
*/
protected boolean validatePluginID(Element element, Attr attr) {
if (!IdUtil.isValidCompositeID3_0(attr.getValue())) {
- String message = NLS.bind(PDECoreMessages.Builders_Manifest_compositeID, attr.getValue(), attr.getName());
+ String message = NLS.bind(PDECoreMessages.Builders_Manifest_pluginID, attr.getValue(), attr.getName());
report(message, getLine(element, attr.getName()), CompilerFlags.WARNING, PDEMarkerFactory.CAT_OTHER);
return false;
}
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/pderesources.properties b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/pderesources.properties
index 72b8120..9841a7b 100644
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/pderesources.properties
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/pderesources.properties
@@ -85,6 +85,7 @@ Builders_Manifest_illegalRoot = Illegal root element
Builders_Manifest_attribute = Illegal attribute ''{0}''
Builders_Manifest_att_value = Illegal value ''{0}'' for attribute ''{1}''
Builders_Manifest_compositeID = Illegal value ''{0}'' for attribute ''{1}''. Legal token characters are "a-z", "A-Z", "0-9", "_". Tokens must be separated by "."
+Builders_Manifest_pluginID = Illegal value ''{0}'' for attribute ''{1}''. Legal token characters are "a-z", "A-Z", "0-9", "_", "-". Tokens must be separated by "."
Builders_Manifest_simpleID = Illegal value ''{0}'' for attribute "id". Legal characters are "a-z", "A-Z", "0-9", and "_"
Builders_Manifest_non_ext_attribute = The value for attribute ''{0}'' is not externalized. The value must begin with %
BuildErrorReporter_dirsMustEndSlash={0}: directory entries must end with ''/'' ("{0}/")