diff options
Diffstat (limited to 'jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal')
5 files changed, 26 insertions, 19 deletions
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaElementFactoryMethod.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaElementFactoryMethod.java index 5e69ee5e9a..61e1c75034 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaElementFactoryMethod.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaElementFactoryMethod.java @@ -11,7 +11,6 @@ package org.eclipse.jpt.jaxb.core.internal.context.java; import java.util.List; import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.common.core.internal.utility.JDTTools; import org.eclipse.jpt.common.core.resource.java.JavaResourceMethod; import org.eclipse.jpt.common.core.utility.TextRange; import org.eclipse.jpt.common.utility.Filter; @@ -211,20 +210,26 @@ public class GenericJavaElementFactoryMethod this.substitutionHeadQName.validate(messages, reporter, astRoot); JavaResourceMethod resourceMethod = getResourceMethod(); - if (! JAXB.JAXB_ELEMENT.equals(resourceMethod.getTypeName())) { + validateMethodReturnType(resourceMethod, messages, astRoot); + + if (resourceMethod.getParametersSize() != 1) { messages.add( DefaultValidationMessages.buildMessage( IMessage.HIGH_SEVERITY, - JaxbValidationMessages.XML_ELEMENT_DECL__INVALID_METHOD_SIGNATURE_RETURN_TYPE, + JaxbValidationMessages.XML_ELEMENT_DECL__INVALID_METHOD_SIGNATURE_PARAM, this, getValidationTextRange(astRoot))); } - if (resourceMethod.getParametersSize() != 1 || - ! JDTTools.typeIsSubType(getJaxbProject().getJavaProject(), resourceMethod.getParameterTypeName(0), Object.class.getName())) { + } + + protected void validateMethodReturnType( + JavaResourceMethod resourceMethod, List<IMessage> messages, CompilationUnit astRoot) { + + if (! JAXB.JAXB_ELEMENT.equals(resourceMethod.getTypeName())) { messages.add( DefaultValidationMessages.buildMessage( IMessage.HIGH_SEVERITY, - JaxbValidationMessages.XML_ELEMENT_DECL__INVALID_METHOD_SIGNATURE_PARAM, + JaxbValidationMessages.XML_ELEMENT_DECL__INVALID_METHOD_SIGNATURE_RETURN_TYPE, this, getValidationTextRange(astRoot))); } diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlAnyElementMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlAnyElementMapping.java index 4068e3116e..a5d9f92acf 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlAnyElementMapping.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlAnyElementMapping.java @@ -500,7 +500,7 @@ public class GenericJavaXmlAnyElementMapping protected XmlElementRefAnnotation annotation; - protected XmlElementRefContext(XmlElementRefAnnotation annotation) { + public XmlElementRefContext(XmlElementRefAnnotation annotation) { this.annotation = annotation; } diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRef.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRef.java index 31760f8c12..9141e40481 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRef.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRef.java @@ -195,16 +195,18 @@ public class GenericJavaXmlElementRef public Iterable<String> getReferencedXmlTypeNames() { // only return the specified type - the default type should already be included - if (this.specifiedType != null) { - String fqType = getFullyQualifiedType(); - if (! JAXB.JAXB_ELEMENT.equals(fqType)) { - return new SingleElementIterable(fqType); - } + if (this.specifiedType != null + && ! isTypeJAXBElement()) { + return new SingleElementIterable(getFullyQualifiedType()); } return EmptyIterable.instance(); } + protected boolean isTypeJAXBElement() { + return (StringTools.stringsAreEqual(JAXB.JAXB_ELEMENT, getFullyQualifiedType())); + } + // ***** content assist ***** @@ -256,13 +258,13 @@ public class GenericJavaXmlElementRef else if (! StringTools.stringIsEmpty(this.specifiedType) // verify that type actually exists before validating && JDTTools.findType(getJaxbProject().getJavaProject(), fqType) != null) { - String attributeBaseType = getPersistentAttribute().getJavaResourceAttributeBaseTypeName(); - if (! JDTTools.typeIsSubType(getJaxbProject().getJavaProject(), fqType, attributeBaseType)) { + String attributeValueType = getContext().getAttributeMapping().getValueTypeName(); + if (! JDTTools.typeIsSubType(getJaxbProject().getJavaProject(), fqType, attributeValueType)) { messages.add( DefaultValidationMessages.buildMessage( IMessage.HIGH_SEVERITY, JaxbValidationMessages.XML_ELEMENT_REF__ILLEGAL_TYPE, - new String[] { attributeBaseType }, + new String[] { attributeValueType }, this, getTypeTextRange(astRoot))); @@ -275,7 +277,7 @@ public class GenericJavaXmlElementRef DefaultValidationMessages.buildMessage( IMessage.HIGH_SEVERITY, JaxbValidationMessages.XML_ELEMENT_REF__NO_ROOT_ELEMENT, - new String[] { attributeBaseType }, + new String[] { attributeValueType }, this, getTypeTextRange(astRoot))); } @@ -297,7 +299,7 @@ public class GenericJavaXmlElementRef } protected boolean isTypeJAXBElement() { - return JAXB.JAXB_ELEMENT.equals(GenericJavaXmlElementRef.this.getFullyQualifiedType()); + return GenericJavaXmlElementRef.this.isTypeJAXBElement(); } protected JaxbTypeMapping getReferencedTypeMapping() { 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 58a790be8e..9362158238 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 @@ -270,7 +270,7 @@ public class GenericJavaXmlElementRefMapping } - protected class XmlElementRefContext + public class XmlElementRefContext implements GenericJavaXmlElementRef.Context { public XmlElementRefAnnotation getAnnotation() { 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 63f7e7d26e..48bbf2022c 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 @@ -320,7 +320,7 @@ public class GenericJavaXmlElementRefsMapping protected XmlElementRefAnnotation annotation; - protected XmlElementRefContext(XmlElementRefAnnotation annotation) { + public XmlElementRefContext(XmlElementRefAnnotation annotation) { this.annotation = annotation; } |