Skip to main content
summaryrefslogtreecommitdiffstats
path: root/jaxb
diff options
context:
space:
mode:
authorpfullbright2011-10-19 21:26:25 +0000
committerpfullbright2011-10-19 21:26:25 +0000
commit45d2456f8acce590bbbcf3d78951a8e0fa85356f (patch)
tree9df622d9b6232e2292a018c769ee341c3ff3f8b6 /jaxb
parent7b2194e6e130ada0e52f41e0a58a31bf2716a981 (diff)
downloadwebtools.dali-45d2456f8acce590bbbcf3d78951a8e0fa85356f.tar.gz
webtools.dali-45d2456f8acce590bbbcf3d78951a8e0fa85356f.tar.xz
webtools.dali-45d2456f8acce590bbbcf3d78951a8e0fa85356f.zip
added XmlType.propOrder validation and content assit
Diffstat (limited to 'jaxb')
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/property_files/jaxb_validation.properties6
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbAttributeMapping.java12
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbClassMapping.java10
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/AbstractJavaAttributeMapping.java10
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/AbstractJavaType.java31
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/AbstractJavaTypeMapping.java2
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaClassMapping.java163
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementMapping.java5
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefMapping.java5
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefsMapping.java5
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementsMapping.java5
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlTransientMapping.java5
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/NullXmlTypeAnnotation.java17
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryXmlTypeAnnotation.java17
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlTypeAnnotation.java41
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/validation/JaxbValidationMessages.java6
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlTypeAnnotation.java38
17 files changed, 345 insertions, 33 deletions
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/property_files/jaxb_validation.properties b/jaxb/plugins/org.eclipse.jpt.jaxb.core/property_files/jaxb_validation.properties
index 9ea4973509..8f25ce2cc2 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/property_files/jaxb_validation.properties
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/property_files/jaxb_validation.properties
@@ -17,7 +17,11 @@ PACKAGE_XML_JAVA_TYPE_ADAPTER_TYPE_NOT_SPECIFIED = The type must be specified fo
XML_SCHEMA__MISMATCHED_ATTRIBUTE_FORM_DEFAULT = The attribute form default conflicts with what is specified on the schema
XML_SCHEMA__MISMATCHED_ELEMENT_FORM_DEFAULT = The element form default conflicts with what is specified on the schema
-XML_TYPE_UNMATCHING_NAMESPACE_FOR_ANONYMOUS_TYPE = The namespace for an anonymous type should not be different from its package
+XML_TYPE__UNMATCHING_NAMESPACE_FOR_ANONYMOUS_TYPE = The namespace for an anonymous type should not be different from its package
+XML_TYPE__DUPLICATE_PROP = Duplicate property ''{0}''.
+XML_TYPE__MISSING_PROP = Missing required property ''{0}''.
+XML_TYPE__NONEXISTENT_PROP = Nonexistent property ''{0}''.
+XML_TYPE__TRANSIENT_PROP = The property ''{0}'' is transient and should not be included in the property order.
XML_ROOT_ELEMENT_TYPE_CONFLICTS_WITH_XML_TYPE = The xml type of the element declaration with name ''{0}'' and namespace ''{1}'' conflicts with the xml type of the associated class
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbAttributeMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbAttributeMapping.java
index fa9d8b146a..1b12b20a6f 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbAttributeMapping.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbAttributeMapping.java
@@ -65,4 +65,16 @@ public interface JaxbAttributeMapping
* (Used for constructing Jaxb context)
*/
Iterable<String> getReferencedXmlTypeNames();
+
+ /**
+ * Return whether the attribute is mapped to a particle
+ * (e.g. XmlElement, XmlElements, XmlElementRef, XmlElementRefs)
+ */
+ boolean isParticleMapping();
+
+ /**
+ * Return whether the attribute is specifically excluded from being mapped
+ * (e.g. XmlTransient)
+ */
+ boolean isTransient();
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbClassMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbClassMapping.java
index 74533f0794..6fb2ad37ee 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbClassMapping.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbClassMapping.java
@@ -53,6 +53,8 @@ public interface JaxbClassMapping
*/
ListIterable<String> getPropOrder();
+ String getProp(int index);
+
int getPropOrderSize();
void addProp(int index, String prop);
@@ -96,7 +98,13 @@ public interface JaxbClassMapping
int getIncludedAttributesSize();
- // ***** inherited attributes *****
+ // ***** misc attributes *****
+
+ /**
+ * Return all attributes that are defined by this class.
+ * This is the combined set of #getAttributes() and #getIncludedAttributes()
+ */
+ Iterable<JaxbPersistentAttribute> getAllLocallyDefinedAttributes();
/**
* <i>Inherited</i> attributes are any attributes this class mapping has whose source
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/AbstractJavaAttributeMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/AbstractJavaAttributeMapping.java
index 97b7623e5a..5842c7b6e7 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/AbstractJavaAttributeMapping.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/AbstractJavaAttributeMapping.java
@@ -124,4 +124,14 @@ public abstract class AbstractJavaAttributeMapping<A extends Annotation>
public Iterable<String> getReferencedXmlTypeNames() {
return new SingleElementIterable(getValueTypeName());
}
+
+ /* default impl */
+ public boolean isParticleMapping() {
+ return false;
+ }
+
+ /* default impl */
+ public boolean isTransient() {
+ return false;
+ }
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/AbstractJavaType.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/AbstractJavaType.java
index 723f0acb90..be64693272 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/AbstractJavaType.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/AbstractJavaType.java
@@ -16,6 +16,8 @@ import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.common.core.internal.resource.java.source.SourceNode;
import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType;
import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.common.utility.Filter;
+import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
import org.eclipse.jpt.jaxb.core.context.JaxbContextNode;
import org.eclipse.jpt.jaxb.core.context.JaxbPackage;
@@ -264,6 +266,35 @@ public abstract class AbstractJavaType
}
+ // ***** content assist *****
+
+ @Override
+ public Iterable<String> getJavaCompletionProposals(
+ int pos, Filter<String> filter, CompilationUnit astRoot) {
+
+ Iterable<String> result = super.getJavaCompletionProposals(pos, filter, astRoot);
+ if (! CollectionTools.isEmpty(result)) {
+ return result;
+ }
+
+ if (this.mapping != null) {
+ result = this.mapping.getJavaCompletionProposals(pos, filter, astRoot);
+ if (! CollectionTools.isEmpty(result)) {
+ return result;
+ }
+ }
+
+ if (this.xmlJavaTypeAdapter != null) {
+ result = this.xmlJavaTypeAdapter.getJavaCompletionProposals(pos, filter, astRoot);
+ if (! CollectionTools.isEmpty(result)) {
+ return result;
+ }
+ }
+
+ return EmptyIterable.instance();
+ }
+
+
// ***** validation *****
/**
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/AbstractJavaTypeMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/AbstractJavaTypeMapping.java
index d082e261e9..834c77847f 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/AbstractJavaTypeMapping.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/AbstractJavaTypeMapping.java
@@ -438,7 +438,7 @@ public abstract class AbstractJavaTypeMapping
messages.add(
DefaultValidationMessages.buildMessage(
IMessage.HIGH_SEVERITY,
- JaxbValidationMessages.XML_TYPE_UNMATCHING_NAMESPACE_FOR_ANONYMOUS_TYPE,
+ JaxbValidationMessages.XML_TYPE__UNMATCHING_NAMESPACE_FOR_ANONYMOUS_TYPE,
this,
getXmlTypeAnnotation().getNamespaceTextRange(astRoot)));
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaClassMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaClassMapping.java
index 099dcee7f8..196f3c85ed 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaClassMapping.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaClassMapping.java
@@ -17,11 +17,15 @@ import java.util.Set;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.common.core.internal.utility.JDTTools;
import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
+import org.eclipse.jpt.common.core.utility.TextRange;
import org.eclipse.jpt.common.utility.Filter;
+import org.eclipse.jpt.common.utility.internal.Bag;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
+import org.eclipse.jpt.common.utility.internal.StringTools;
import org.eclipse.jpt.common.utility.internal.iterables.ChainIterable;
import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
+import org.eclipse.jpt.common.utility.internal.iterables.EmptyListIterable;
import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable;
import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneIterable;
@@ -201,6 +205,10 @@ public class GenericJavaClassMapping
return this.propOrderContainer.getContextElements();
}
+ public String getProp(int index) {
+ return this.propOrderContainer.getContextElement(index);
+ }
+
public int getPropOrderSize() {
return this.propOrderContainer.getContextElementsSize();
}
@@ -233,7 +241,11 @@ public class GenericJavaClassMapping
}
protected ListIterable<String> getResourcePropOrder() {
- return this.getXmlTypeAnnotation().getPropOrder();
+ ListIterable<String> result = getXmlTypeAnnotation().getPropOrder();
+ if (CollectionTools.size(result) == 1 && StringTools.EMPTY_STRING.equals(CollectionTools.get(result, 0))) {
+ return EmptyListIterable.instance();
+ }
+ return result;
}
@@ -584,20 +596,14 @@ public class GenericJavaClassMapping
};
}
- public String getJavaResourceAttributeOwningTypeName(JaxbPersistentAttribute attribute) {
- if (attribute.getParent() != this) {
- throw new IllegalArgumentException("The attribute is not owned by this JaxbClassMapping"); //$NON-NLS-1$
- }
- for (JaxbClassMapping superclass : this.includedAttributesContainers.keySet()) {
- if (CollectionTools.contains(this.includedAttributesContainers.get(superclass).getAttributes(), attribute)) {
- return superclass.getJaxbType().getSimpleName();
- }
- }
- throw new IllegalArgumentException("The attribute is not an inherited attribute"); //$NON-NLS-1$
- }
+ // ***** misc attributes *****
- // ***** inherited attributes *****
+ public Iterable<JaxbPersistentAttribute> getAllLocallyDefinedAttributes() {
+ return new CompositeIterable<JaxbPersistentAttribute>(
+ getAttributes(),
+ getIncludedAttributes());
+ }
public Iterable<JaxbPersistentAttribute> getInheritedAttributes() {
return new CompositeIterable<JaxbPersistentAttribute>(
@@ -727,6 +733,10 @@ public class GenericJavaClassMapping
return result;
}
+ if (propTouches(pos, astRoot)) {
+ return getPropProposals(filter);
+ }
+
// TODO - factory methods?
for (JaxbPersistentAttribute attribute : this.getAttributes()) {
@@ -739,6 +749,18 @@ public class GenericJavaClassMapping
return EmptyIterable.instance();
}
+ protected Iterable<String> getPropProposals(Filter<String> filter) {
+ return StringTools.convertToJavaStringLiterals(
+ new FilteringIterable<String>(
+ new TransformationIterable<JaxbPersistentAttribute, String>(getAllLocallyDefinedAttributes()) {
+ @Override
+ protected String transform(JaxbPersistentAttribute o) {
+ return o.getName();
+ }
+ },
+ filter));
+ }
+
// ***** validation *****
@@ -748,6 +770,8 @@ public class GenericJavaClassMapping
// TODO - factory method?
+ validatePropOrder(messages, reporter, astRoot);
+
validateXmlAnyAttributeMapping(messages, astRoot);
validateXmlAnyElementMapping(messages, astRoot);
validateXmlValueMapping(messages, astRoot);
@@ -758,6 +782,99 @@ public class GenericJavaClassMapping
}
}
+ public void validatePropOrder(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
+ if (CollectionTools.isEmpty(getPropOrder())) {
+ return;
+ }
+
+ // no duplicates
+ // all attributes/included attributes with XmlElement/s/Ref/s must be listed
+ // no nonexistent attributes (attributes mapped otherwise allowed) ...
+ // *except* no transient attributes allowed
+
+ Bag<String> props = CollectionTools.bag(getPropOrder());
+ Set<String> allAttributes = new HashSet<String>();
+ Set<String> requiredAttributes = new HashSet<String>();
+ Set<String> transientAttributes = new HashSet<String>();
+
+ for (JaxbPersistentAttribute attribute : getAllLocallyDefinedAttributes()) {
+ allAttributes.add(attribute.getName());
+
+ if (attribute.getMapping().isParticleMapping()) {
+ requiredAttributes.add(attribute.getName());
+ }
+
+ if (attribute.getMapping().isTransient()) {
+ transientAttributes.add(attribute.getName());
+ }
+ }
+
+ Set<Integer> duplicateProps = new HashSet<Integer>();
+ Set<String> missingProps = new HashSet<String>(requiredAttributes);
+ Set<Integer> nonexistentProps = new HashSet<Integer>();
+ Set<Integer> transientProps = new HashSet<Integer>();
+
+ for (int i = 0; i < getPropOrderSize(); i ++ ) {
+ String prop = getProp(i);
+
+ if (props.count(prop) > 1) {
+ duplicateProps.add(i);
+ }
+
+ if (missingProps.contains(prop)) {
+ missingProps.remove(prop);
+ }
+
+ if (! allAttributes.contains(prop)) {
+ nonexistentProps.add(i);
+ }
+
+ if (transientAttributes.contains(prop)) {
+ transientProps.add(i);
+ }
+ }
+
+ for (int i : duplicateProps) {
+ messages.add(
+ DefaultValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ JaxbValidationMessages.XML_TYPE__DUPLICATE_PROP,
+ new String[] { getProp(i) },
+ this,
+ getPropTextRange(i, astRoot)));
+ }
+
+ for (String missingProp : missingProps) {
+ messages.add(
+ DefaultValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ JaxbValidationMessages.XML_TYPE__MISSING_PROP,
+ new String[] { missingProp },
+ this,
+ getPropOrderTextRange(astRoot)));
+ }
+
+ for (int i : nonexistentProps) {
+ messages.add(
+ DefaultValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ JaxbValidationMessages.XML_TYPE__NONEXISTENT_PROP,
+ new String[] { getProp(i) },
+ this,
+ getPropTextRange(i, astRoot)));
+ }
+
+ for (int i : transientProps) {
+ messages.add(
+ DefaultValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ JaxbValidationMessages.XML_TYPE__TRANSIENT_PROP,
+ new String [] { getProp(i) },
+ this,
+ getPropTextRange(i, astRoot)));
+ }
+ }
+
protected void validateXmlAnyAttributeMapping(List<IMessage> messages, CompilationUnit astRoot) {
Set<JaxbPersistentAttribute> localAttributes = new HashSet<JaxbPersistentAttribute>();
Set<JaxbPersistentAttribute> allAttributes = new HashSet<JaxbPersistentAttribute>();
@@ -907,6 +1024,26 @@ public class GenericJavaClassMapping
}
}
+ protected TextRange getPropOrderTextRange(CompilationUnit astRoot) {
+ TextRange result = getXmlTypeAnnotation().getPropOrderTextRange(astRoot);
+ return (result != null) ? result : getValidationTextRange(astRoot);
+ }
+
+ protected TextRange getPropTextRange(int index, CompilationUnit astRoot) {
+ return getXmlTypeAnnotation().getPropTextRange(index, astRoot);
+ }
+
+ protected boolean propTouches(int pos, CompilationUnit astRoot) {
+ if (getXmlTypeAnnotation().propOrderTouches(pos, astRoot)) {
+ for (int i = 0; i < getXmlTypeAnnotation().getPropOrderSize(); i ++ ) {
+ if (getXmlTypeAnnotation().propTouches(i, pos, astRoot)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
/**
* xml prop order container
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementMapping.java
index 55d24fc653..a115e1914e 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementMapping.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementMapping.java
@@ -167,6 +167,11 @@ public class GenericJavaXmlElementMapping
this.xmlElement.getReferencedXmlTypeNames());
}
+ @Override
+ public boolean isParticleMapping() {
+ return true;
+ }
+
// ***** content assist *****
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefMapping.java
index fad57e19cf..d116239ec1 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefMapping.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefMapping.java
@@ -228,6 +228,11 @@ public class GenericJavaXmlElementRefMapping
return this.xmlElementRef.getReferencedXmlTypeNames();
}
+ @Override
+ public boolean isParticleMapping() {
+ return true;
+ }
+
// ***** content assist *****
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefsMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefsMapping.java
index 0419921d16..92f9ad8143 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefsMapping.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefsMapping.java
@@ -236,6 +236,11 @@ public class GenericJavaXmlElementRefsMapping
return this.xmlElementRefs.getReferencedXmlTypeNames();
}
+ @Override
+ public boolean isParticleMapping() {
+ return true;
+ }
+
// ***** content assist *****
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementsMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementsMapping.java
index 4cd85daa80..0892b8948e 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementsMapping.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementsMapping.java
@@ -282,6 +282,11 @@ public class GenericJavaXmlElementsMapping
}));
}
+ @Override
+ public boolean isParticleMapping() {
+ return true;
+ }
+
// ***** content assist *****
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlTransientMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlTransientMapping.java
index eb9efe3671..ba23f4ee1c 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlTransientMapping.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlTransientMapping.java
@@ -35,4 +35,9 @@ public class GenericJavaXmlTransientMapping
public Iterable<String> getReferencedXmlTypeNames() {
return EmptyIterable.instance();
}
+
+ @Override
+ public boolean isTransient() {
+ return true;
+ }
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/NullXmlTypeAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/NullXmlTypeAnnotation.java
index 26477a84af..848b54d55f 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/NullXmlTypeAnnotation.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/NullXmlTypeAnnotation.java
@@ -142,5 +142,20 @@ public final class NullXmlTypeAnnotation
public void removeProp(String prop) {
throw new UnsupportedOperationException();
}
-
+
+ public TextRange getPropOrderTextRange(CompilationUnit astRoot) {
+ return null;
+ }
+
+ public boolean propOrderTouches(int pos, CompilationUnit astRoot) {
+ return false;
+ }
+
+ public TextRange getPropTextRange(int index, CompilationUnit astRoot) {
+ return null;
+ }
+
+ public boolean propTouches(int index, int pos, CompilationUnit astRoot) {
+ return false;
+ }
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryXmlTypeAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryXmlTypeAnnotation.java
index 673d826194..a2d08f7f2c 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryXmlTypeAnnotation.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryXmlTypeAnnotation.java
@@ -209,5 +209,20 @@ public final class BinaryXmlTypeAnnotation
public void removeProp(int index) {
throw new UnsupportedOperationException();
}
-
+
+ public TextRange getPropOrderTextRange(CompilationUnit astRoot) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean propOrderTouches(int pos, CompilationUnit astRoot) {
+ throw new UnsupportedOperationException();
+ }
+
+ public TextRange getPropTextRange(int index, CompilationUnit astRoot) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean propTouches(int index, int pos, CompilationUnit astRoot) {
+ throw new UnsupportedOperationException();
+ }
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlTypeAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlTypeAnnotation.java
index 1630a98a72..0ae69baaf0 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlTypeAnnotation.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlTypeAnnotation.java
@@ -17,6 +17,7 @@ import org.eclipse.jpt.common.core.internal.utility.jdt.ASTTools;
import org.eclipse.jpt.common.core.internal.utility.jdt.AnnotatedElementAnnotationElementAdapter;
import org.eclipse.jpt.common.core.internal.utility.jdt.AnnotationStringArrayExpressionConverter;
import org.eclipse.jpt.common.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.common.core.internal.utility.jdt.IndexedConversionDeclarationAnnotationElementAdapter;
import org.eclipse.jpt.common.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
import org.eclipse.jpt.common.core.internal.utility.jdt.SimpleTypeStringExpressionConverter;
import org.eclipse.jpt.common.core.resource.java.JavaResourceAnnotatedElement;
@@ -26,6 +27,8 @@ import org.eclipse.jpt.common.core.utility.jdt.AnnotationElementAdapter;
import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationAdapter;
import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationElementAdapter;
import org.eclipse.jpt.common.core.utility.jdt.ExpressionConverter;
+import org.eclipse.jpt.common.core.utility.jdt.IndexedDeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.common.core.utility.jdt.IndexedExpressionConverter;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneListIterable;
@@ -59,7 +62,7 @@ public final class SourceXmlTypeAnnotation
private final AnnotationElementAdapter<String> namespaceAdapter;
private String namespace;
- private final DeclarationAnnotationElementAdapter<String[]> propOrderDeclarationAdapter;
+ private final IndexedDeclarationAnnotationElementAdapter<String> propOrderDeclarationAdapter;
private final AnnotationElementAdapter<String[]> propOrderAdapter;
private final Vector<String> propOrder = new Vector<String>();
@@ -77,12 +80,12 @@ public final class SourceXmlTypeAnnotation
return new AnnotatedElementAnnotationElementAdapter<String>(this.annotatedElement, daea);
}
- private static DeclarationAnnotationElementAdapter<String[]> buildArrayAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) {
+ private static IndexedDeclarationAnnotationElementAdapter<String> buildArrayAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) {
return buildArrayAnnotationElementAdapter(annotationAdapter, elementName, AnnotationStringArrayExpressionConverter.forStrings());
}
- private static DeclarationAnnotationElementAdapter<String[]> buildArrayAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, ExpressionConverter<String[]> converter) {
- return new ConversionDeclarationAnnotationElementAdapter<String[]>(annotationAdapter, elementName, converter);
+ private static IndexedDeclarationAnnotationElementAdapter<String> buildArrayAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, IndexedExpressionConverter<String> converter) {
+ return new IndexedConversionDeclarationAnnotationElementAdapter<String>(annotationAdapter, elementName, converter);
}
private AnnotationElementAdapter<String[]> buildArrayAnnotationElementAdapter(DeclarationAnnotationElementAdapter<String[]> daea) {
@@ -248,19 +251,20 @@ public final class SourceXmlTypeAnnotation
}
- // ***** prop order
+ // ***** prop order *****
+
public ListIterable<String> getPropOrder() {
return new LiveCloneListIterable<String>(this.propOrder);
}
-
+
public int getPropOrderSize() {
return this.propOrder.size();
}
-
+
public void addProp(String prop) {
this.addProp(this.propOrder.size(), prop);
}
-
+
public void addProp(int index, String prop) {
this.propOrder.add(index, prop);
this.writePropOrder();
@@ -296,8 +300,24 @@ public final class SourceXmlTypeAnnotation
String[] astPropOrder = this.propOrderAdapter.getValue(astRoot);
this.synchronizeList(Arrays.asList(astPropOrder), this.propOrder, PROP_ORDER_LIST);
}
-
-
+
+ public TextRange getPropOrderTextRange(CompilationUnit astRoot) {
+ return getElementTextRange(this.propOrderDeclarationAdapter, astRoot);
+ }
+
+ public boolean propOrderTouches(int pos, CompilationUnit astRoot) {
+ return elementTouches(this.propOrderDeclarationAdapter, pos, astRoot);
+ }
+
+ public TextRange getPropTextRange(int index, CompilationUnit astRoot) {
+ return getElementTextRange(getAnnotationElementSubvalueTextRange(this.propOrderDeclarationAdapter, index, astRoot), astRoot);
+ }
+
+ public boolean propTouches(int index, int pos, CompilationUnit astRoot) {
+ return textRangeTouches(getAnnotationElementSubvalueTextRange(this.propOrderDeclarationAdapter, index, astRoot), pos);
+ }
+
+
//*********** static methods ****************
private static DeclarationAnnotationElementAdapter<String> buildFactoryClassAdapter() {
@@ -319,5 +339,4 @@ public final class SourceXmlTypeAnnotation
private static DeclarationAnnotationElementAdapter<String> buildNamespaceAdapter() {
return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JAXB.XML_TYPE__NAMESPACE);
}
-
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/validation/JaxbValidationMessages.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/validation/JaxbValidationMessages.java
index 5dd7c8e182..1a339e3659 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/validation/JaxbValidationMessages.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/validation/JaxbValidationMessages.java
@@ -33,7 +33,11 @@ public interface JaxbValidationMessages {
// validation on type
- String XML_TYPE_UNMATCHING_NAMESPACE_FOR_ANONYMOUS_TYPE = "XML_TYPE_UNMATCHING_NAMESPACE_FOR_ANONYMOUS_TYPE";
+ String XML_TYPE__UNMATCHING_NAMESPACE_FOR_ANONYMOUS_TYPE = "XML_TYPE__UNMATCHING_NAMESPACE_FOR_ANONYMOUS_TYPE";
+ String XML_TYPE__DUPLICATE_PROP = "XML_TYPE__DUPLICATE_PROP";
+ String XML_TYPE__MISSING_PROP = "XML_TYPE__MISSING_PROP";
+ String XML_TYPE__NONEXISTENT_PROP = "XML_TYPE__NONEXISTENT_PROP";
+ String XML_TYPE__TRANSIENT_PROP = "XML_TYPE__TRANSIENT_PROP";
String XML_ROOT_ELEMENT_TYPE_CONFLICTS_WITH_XML_TYPE = "XML_ROOT_ELEMENT_TYPE_CONFLICTS_WITH_XML_TYPE";
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlTypeAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlTypeAnnotation.java
index 3a8c03b7cd..fab1f81581 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlTypeAnnotation.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlTypeAnnotation.java
@@ -83,12 +83,21 @@ public interface XmlTypeAnnotation
*/
TextRange getFactoryMethodTextRange(CompilationUnit astRoot);
+
+ // ***** prop order *****
+
+ String PROP_ORDER_LIST = "propOrder"; //$NON-NLS-1$
+
+ /**
+ * A single element empty string array should be interpreted as unspecified
+ */
+ String[] DEFAULT_PROP_ORDER = new String[] { "" };
+
/**
* Corresponds to the 'propOrder' element of the XmlType annotation.
* Return an empty iterator if the element does not exist in Java.
*/
ListIterable<String> getPropOrder();
- String PROP_ORDER_LIST = "propOrder"; //$NON-NLS-1$
/**
* Corresponds to the 'propOrder' element of the XmlType annotation.
@@ -109,14 +118,37 @@ public interface XmlTypeAnnotation
* Corresponds to the 'propOrder' element of the XmlType annotation.
*/
void moveProp(int targetIndex, int sourceIndex);
-
+
/**
* Corresponds to the 'propOrder' element of the XmlType annotation.
*/
void removeProp(String prop);
-
+
/**
* Corresponds to the 'propOrder' element of the XmlType annotation.
*/
void removeProp(int index);
+
+ /**
+ * Return the text range of the 'propOrder' element of the XmlType annotation.
+ */
+ TextRange getPropOrderTextRange(CompilationUnit astRoot);
+
+ /**
+ * Return whether the specified position touches the 'propOrder' element.
+ * Return false if the element does not exist.
+ */
+ boolean propOrderTouches(int pos, CompilationUnit astRoot);
+
+ /**
+ * Return the text range of the prop at the specified index
+ * @throws ArrayIndexOutOfBoundsException if the index is out of range
+ */
+ TextRange getPropTextRange(int index, CompilationUnit astRoot);
+
+ /**
+ * Return whether the specified position touches the prop at the specified index.
+ * @throws ArrayIndexOutOfBoundsException if the index is out of range
+ */
+ boolean propTouches(int index, int pos, CompilationUnit astRoot);
}

Back to the top