*** empty log message ***
diff --git a/ui/org.eclipse.pde.ui/Eclipse PDE UI/org/eclipse/pde/internal/PDEResources.properties b/ui/org.eclipse.pde.ui/Eclipse PDE UI/org/eclipse/pde/internal/PDEResources.properties index 146877c..f92148b 100644 --- a/ui/org.eclipse.pde.ui/Eclipse PDE UI/org/eclipse/pde/internal/PDEResources.properties +++ b/ui/org.eclipse.pde.ui/Eclipse PDE UI/org/eclipse/pde/internal/PDEResources.properties
@@ -577,4 +577,10 @@ Builders.Schema.compilingSchemas=Compiling extension point schemas... Builders.Schema.removing = Removing {0} ... +Builders.Schema.Verifier.booleanInvalid= Element "{0}", attribute "{1}": "boolean" type is invalid in this context +Builders.Schema.Verifier.restrictionInvalid = Element "{0}", attribute "{1}": "restriction" cannot be used in this context +Builders.Schema.Verifier.basedOnInvalid = Element "{0}", attribute "{1}": "basedOn" can only be used with the "java" kind +Builders.Schema.Verifier.valueWithoutDefault = Element "{0}", attribute "{1}": "value" cannot be used if "use" it not "default" +Builders.Schema.Verifier.defaultWithoutValue = Element "{0}", attribute "{1}": when "use" is "default", "value" must be set + Builders.Fragment.brokenLink = Referenced plug-in "{0} {1}" not found \ No newline at end of file
diff --git a/ui/org.eclipse.pde.ui/Eclipse PDE UI/org/eclipse/pde/internal/builders/SchemaTransformer.java b/ui/org.eclipse.pde.ui/Eclipse PDE UI/org/eclipse/pde/internal/builders/SchemaTransformer.java index f6b4882..01eba7e 100644 --- a/ui/org.eclipse.pde.ui/Eclipse PDE UI/org/eclipse/pde/internal/builders/SchemaTransformer.java +++ b/ui/org.eclipse.pde.ui/Eclipse PDE UI/org/eclipse/pde/internal/builders/SchemaTransformer.java
@@ -14,6 +14,11 @@ import org.eclipse.pde.internal.PDEPlugin; public class SchemaTransformer implements ISchemaTransformer { + private static final String KEY_BOOLEAN_INVALID="Builders.Schema.Verifier.booleanInvalid"; + private static final String KEY_RESTRICTION_INVALID="Builders.Schema.Verifier.restrictionInvalid"; + private static final String KEY_BASED_ON_INVALID="Builders.Schema.Verifier.basedOnInvalid"; + private static final String KEY_VALUE_WITHOUT_DEFAULT="Builders.Schema.Verifier.valueWithoutDefault"; + private static final String KEY_DEFAULT_WITHOUT_VALUE="Builders.Schema.Verifier.defaultWithoutValue"; private void appendAttlist( StringBuffer out, @@ -30,8 +35,10 @@ } // add data type ISchemaSimpleType type = att.getType(); - ISchemaRestriction restriction = type.getRestriction(); - String typeName = type.getName().toLowerCase(); + ISchemaRestriction restriction = null; + if (type!=null) + restriction = type.getRestriction(); + String typeName = type!=null ? type.getName().toLowerCase() : "string"; if (typeName.equals("boolean")) { out.append("(true | false) \"false\""); } else @@ -103,8 +110,84 @@ if (root==null) return; Schema schema = new Schema((ISchemaDescriptor)null, null); schema.traverseDocumentTree(root); - transform(out, schema); + if (verifySchema(schema, reporter)) + transform(out, schema); } + +private boolean verifySchema(Schema schema, PluginErrorReporter reporter) { + if (schema.isLoaded()==false) return false; + ISchemaElement [] elements = schema.getElements(); + int errors = 0; + for (int i=0; i<elements.length; i++) { + ISchemaElement element = elements[i]; + ISchemaAttribute [] attributes = element.getAttributes(); + for (int j=0; j<attributes.length; j++) { + ISchemaAttribute attribute = attributes[j]; + errors +=verifyAttribute(element, attribute, reporter); + } + } + return (errors == 0); +} + +private int verifyAttribute(ISchemaElement element, ISchemaAttribute attribute, PluginErrorReporter reporter) { + int errors=0; + ISchemaType type = attribute.getType(); + String message; + String [] args = new String [] { element.getName(), attribute.getName() }; + + if (attribute.getKind() != ISchemaAttribute.STRING) { + if (type!=null) { + if (type.getName().equals("boolean")) { + message=PDEPlugin.getFormattedMessage(KEY_BOOLEAN_INVALID, args); + // this kind cannot have boolean type + reporter.reportError(message); + errors++; + } + if (type instanceof SchemaSimpleType && + ((SchemaSimpleType)type).getRestriction()!=null) { + // should not have restriction + message=PDEPlugin.getFormattedMessage(KEY_RESTRICTION_INVALID, args); + reporter.reportError(message); + errors++; + } + } + } + if (attribute.getKind() != ISchemaAttribute.JAVA) { + if (attribute.getBasedOn()!=null) { + // basedOn makes no sense + message=PDEPlugin.getFormattedMessage(KEY_BASED_ON_INVALID, args); + reporter.reportError(message); + errors++; + } + } + if (type!=null && type.getName().equals("boolean")) { + if (type instanceof SchemaSimpleType && + ((SchemaSimpleType)type).getRestriction()!=null) { + // should not have restriction + message=PDEPlugin.getFormattedMessage(KEY_RESTRICTION_INVALID, args); + reporter.reportError(message); + errors++; + } + } + if (attribute.getUse() != ISchemaAttribute.DEFAULT) { + if (attribute.getValue()!=null) { + // value makes no sense without 'default' use + message=PDEPlugin.getFormattedMessage(KEY_VALUE_WITHOUT_DEFAULT, args); + reporter.reportError(message); + errors++; + } + } + else { + if (attribute.getValue()==null) { + // there must be a value set for this use + message=PDEPlugin.getFormattedMessage(KEY_DEFAULT_WITHOUT_VALUE, args); + reporter.reportError(message); + errors++; + } + } + return errors; +} + public void transform(StringBuffer out, ISchema schema) { out.append("<HTML>\n"); out.append("<BODY>\n");
diff --git a/ui/org.eclipse.pde.ui/Eclipse PDE UI/org/eclipse/pde/internal/editor/schema/AttributePropertySource.java b/ui/org.eclipse.pde.ui/Eclipse PDE UI/org/eclipse/pde/internal/editor/schema/AttributePropertySource.java index 3392626..7988bdc 100644 --- a/ui/org.eclipse.pde.ui/Eclipse PDE UI/org/eclipse/pde/internal/editor/schema/AttributePropertySource.java +++ b/ui/org.eclipse.pde.ui/Eclipse PDE UI/org/eclipse/pde/internal/editor/schema/AttributePropertySource.java
@@ -145,6 +145,7 @@ if (att.getType() instanceof SchemaSimpleType) { SchemaSimpleType type = (SchemaSimpleType) att.getType(); type.setRestriction(restriction); + att.setType(type); } } else if (value instanceof String) {
diff --git a/ui/org.eclipse.pde.ui/Eclipse PDE UI/org/eclipse/pde/internal/schema/Schema.java b/ui/org.eclipse.pde.ui/Eclipse PDE UI/org/eclipse/pde/internal/schema/Schema.java index cab4029..ee0f873 100644 --- a/ui/org.eclipse.pde.ui/Eclipse PDE UI/org/eclipse/pde/internal/schema/Schema.java +++ b/ui/org.eclipse.pde.ui/Eclipse PDE UI/org/eclipse/pde/internal/schema/Schema.java
@@ -297,8 +297,9 @@ String baseName = getAttribute(node, "base"); - if (baseName.equals("string")==false) return null; - + if (baseName.equals("string")==false) { + return new SchemaSimpleType(attribute.getSchema(), "string"); + } SchemaSimpleType type = new SchemaSimpleType(attribute.getSchema(), baseName); Vector items = new Vector();
diff --git a/ui/org.eclipse.pde.ui/Eclipse PDE UI/org/eclipse/pde/internal/schema/SchemaAttribute.java b/ui/org.eclipse.pde.ui/Eclipse PDE UI/org/eclipse/pde/internal/schema/SchemaAttribute.java index e73d3e8..fcf72d5 100644 --- a/ui/org.eclipse.pde.ui/Eclipse PDE UI/org/eclipse/pde/internal/schema/SchemaAttribute.java +++ b/ui/org.eclipse.pde.ui/Eclipse PDE UI/org/eclipse/pde/internal/schema/SchemaAttribute.java
@@ -20,6 +20,7 @@ public static final String P_KIND = "kindProperty"; public static final String P_TYPE = "typeProperty"; public static final String P_BASED_ON = "basedOnProperty"; + private boolean verifying; public SchemaAttribute(ISchemaAttribute att, String newName) { super(att.getParent(), newName); @@ -53,27 +54,70 @@ public void setBasedOn(java.lang.String newBasedOn) { basedOn = newBasedOn; getSchema().fireModelObjectChanged(this, P_BASED_ON); + verifyProperties(); } public void setKind(int newKind) { kind = newKind; getSchema().fireModelObjectChanged(this, P_KIND); + verifyProperties(); } public void setType(ISchemaSimpleType newType) { type = newType; getSchema().fireModelObjectChanged(this, P_TYPE); + verifyProperties(); } public void setUse(int newUse) { use = newUse; getSchema().fireModelObjectChanged(this, P_USE); + verifyProperties(); } public void setValue(String value) { this.value = value; getSchema().fireModelObjectChanged(this, P_VALUE); + verifyProperties(); } public void setValueFilter(String valueFilter) { this.valueFilter = valueFilter; getSchema().fireModelObjectChanged(this, P_VALUE_FILTER); } + +private void verifyProperties() { + if (verifying) return; + verifying=true; +// check if the current combination of properties +// make sense. + if (kind != STRING) { + // type must be 'string' and no restriction + ensureStringType(); + ensureNoRestriction(); + } + if (kind != JAVA) { + // basedOn makes no sense + setBasedOn(null); + } + if (type!=null && type.getName().equals("boolean")) + // no restriction for boolean + ensureNoRestriction(); + if (use != DEFAULT) + // value makes no sense without 'default' use + setValue(null); + verifying = false; +} + +private void ensureStringType() { + if (type==null || type.getName().equals("boolean")) + setType(new SchemaSimpleType(getSchema(), "string")); +} + +private void ensureNoRestriction() { + if (type instanceof SchemaSimpleType && + ((SchemaSimpleType)type).getRestriction()!=null) { + SchemaSimpleType simpleType = (SchemaSimpleType)type; + simpleType.setRestriction(null); + setType(simpleType); + } +} + public void write(String indent, PrintWriter writer) { writeComments(writer); boolean annotation=false;