Author: akazakov
Date: 2010-12-15 14:26:48 -0500 (Wed, 15 Dec 2010)
New Revision: 27522
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/AnnotationValidationDelegate.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/errorList.txt
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/AnnotationsValidationTest.java
Log:
https://issues.jboss.org/browse/JBIDE-7894
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/AnnotationValidationDelegate.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/AnnotationValidationDelegate.java 2010-12-15
18:28:01 UTC (rev 27521)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/AnnotationValidationDelegate.java 2010-12-15
19:26:48 UTC (rev 27522)
@@ -22,6 +22,7 @@
import org.jboss.tools.cdi.core.CDIUtil;
import org.jboss.tools.cdi.core.IAnnotationDeclaration;
import org.jboss.tools.cdi.core.ICDIAnnotation;
+import org.jboss.tools.cdi.core.IInterceptorBindingDeclaration;
import org.jboss.tools.cdi.core.IQualifier;
import org.jboss.tools.cdi.core.IScope;
import org.jboss.tools.cdi.core.IStereotype;
@@ -70,19 +71,19 @@
*/
validateRetentionAnnotation(stereotype,
CDIValidationMessages.MISSING_RETENTION_ANNOTATION_IN_STEREOTYPE_TYPE, resource);
- /*
- * 2.7.1.5. Stereotypes with additional stereotypes
- * - Stereotypes declared @Target(TYPE) may not be applied to stereotypes declared
@Target({TYPE, METHOD, FIELD}),
- * @Target(METHOD), @Target(FIELD) or @Target({METHOD, FIELD}).
- */
- Set<IStereotypeDeclaration> stereotypes =
stereotype.getStereotypeDeclarations();
- for (IStereotypeDeclaration stereotypeDeclaration : stereotypes) {
- IStereotype superStereotype = stereotypeDeclaration.getStereotype();
- if(superStereotype!=null) {
- Boolean result = CDIUtil.checkTargetAnnotation(superStereotype, TYPE_VARIANTS);
- if(result!=null && result) {
- IAnnotationDeclaration target =
stereotype.getAnnotationDeclaration(CDIConstants.TARGET_ANNOTATION_TYPE_NAME);
- if(target!=null) {
+ IAnnotationDeclaration target =
stereotype.getAnnotationDeclaration(CDIConstants.TARGET_ANNOTATION_TYPE_NAME);
+ if(target!=null) {
+ /*
+ * 2.7.1.5. Stereotypes with additional stereotypes
+ * - Stereotypes declared @Target(TYPE) may not be applied to stereotypes declared
@Target({TYPE, METHOD, FIELD}),
+ * @Target(METHOD), @Target(FIELD) or @Target({METHOD, FIELD}).
+ */
+ Set<IStereotypeDeclaration> stereotypes =
stereotype.getStereotypeDeclarations();
+ for (IStereotypeDeclaration stereotypeDeclaration : stereotypes) {
+ IStereotype superStereotype = stereotypeDeclaration.getStereotype();
+ if(superStereotype!=null) {
+ Boolean result = CDIUtil.checkTargetAnnotation(superStereotype, TYPE_VARIANTS);
+ if(result!=null && result) {
result = CDIUtil.checkTargetAnnotation(target, STEREOTYPE_TMF_VARIANTS);
String stName = stereotype.getSourceType().getElementName();
String superStName = superStereotype.getSourceType().getElementName();
@@ -107,6 +108,24 @@
}
}
}
+ /*
+ * 9.1.2. Interceptor bindings for stereotypes
+ * - If a stereotype declares interceptor bindings, it must be defined as
@Target(TYPE).
+ */
+ Set<IInterceptorBindingDeclaration> interceptorBindingDeclarations =
stereotype.getInterceptorBindingDeclarations(false);
+ if(!interceptorBindingDeclarations.isEmpty() &&
!CDIUtil.checkTargetAnnotation(target, TYPE_VARIANTS)) {
+ StringBuffer bindings = new StringBuffer();
+ boolean first = true;
+ for (IInterceptorBindingDeclaration binding : interceptorBindingDeclarations) {
+ if(!first) {
+ bindings.append(", ");
+ }
+ bindings.append(binding.getType().getElementName());
+ first = false;
+ }
+ String stName = stereotype.getSourceType().getElementName();
+ validator.addError(CDIValidationMessages.ILLEGAL_TARGET_IN_INTERCEPTOR_BINDING_TYPE_FOR_STEREOTYPE,
CDIPreferences.MISSING_OR_INCORRECT_TARGET_OR_RETENTION_IN_ANNOTATION_TYPE, new
String[]{stName, bindings.toString()}, target, resource);
+ }
}
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/errorList.txt
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/errorList.txt 2010-12-15
18:28:01 UTC (rev 27521)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/errorList.txt 2010-12-15
19:26:48 UTC (rev 27522)
@@ -257,5 +257,5 @@
- Interceptor binding types declared @Target(TYPE) may not be applied to interceptor
binding types declared
@Target({TYPE, METHOD}).
-9.1.2. Interceptor bindings for stereotypes
+9.1.2. Interceptor bindings for stereotypes
- If a stereotype declares interceptor bindings, it must be defined as @Target(TYPE).
\ No newline at end of file
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties 2010-12-15
18:28:01 UTC (rev 27521)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties 2010-12-15
19:26:48 UTC (rev 27522)
@@ -38,11 +38,11 @@
MISSING_RETENTION_ANNOTATION_IN_STEREOTYPE_TYPE=Stereotype annotation type must be
annotated with @Retention(RUNTIME) [JSR-299 �2.7.1]
MISSING_TARGET_ANNOTATION_IN_SCOPE_TYPE=Scope annotation type must be annotated with
@Target('{'TYPE, METHOD, FIELD'}') [JSR-299 �2.4.2]
MISSING_RETENTION_ANNOTATION_IN_SCOPE_TYPE=Scope annotation type must be annotated with
@Retention(RUNTIME) [JSR-299 �2.4.2]
-ILLEGAL_TARGET_IN_STEREOTYPE_TYPE_TMF=Stereotype {0} is declared @Target(TYPE) and may
not be applied to stereotype {1} which is declared @Target('{TYPE, METHOD,
FIELD}') [JSR-299 �2.7.1.5]
-ILLEGAL_TARGET_IN_STEREOTYPE_TYPE_M=Stereotype {0} is declared @Target(TYPE) may not be
applied to stereotype {1} which is declared @Target(METHOD) [JSR-299 �2.7.1.5]
-ILLEGAL_TARGET_IN_STEREOTYPE_TYPE_F=Stereotype {0} is declared @Target(TYPE) may not be
applied to stereotype {1} which is declared @Target(FIELD) [JSR-299 �2.7.1.5]
-ILLEGAL_TARGET_IN_STEREOTYPE_TYPE_MF=Stereotype {0} is declared @Target(TYPE) may not be
applied to stereotype {1} which is declared @Target('{METHOD, FIELD}') [JSR-299
�2.7.1.5]
-ILLEGAL_TARGET_IN_INTERCEPTOR_BINDING_TYPE=Interceptor binding type {0} is declared
@Target(TYPE) and may not be applied to interceptor binding type {1} which is declared
@Target('{TYPE, METHOD}') [JSR-299 �9.1.1]
+ILLEGAL_TARGET_IN_STEREOTYPE_TYPE_TMF=Stereotype {0} is defined as @Target(TYPE) and may
not be applied to stereotype {1} which is defined as @Target('{TYPE, METHOD,
FIELD}') [JSR-299 �2.7.1.5]
+ILLEGAL_TARGET_IN_STEREOTYPE_TYPE_M=Stereotype {0} is defined as @Target(TYPE) and may
not be applied to stereotype {1} which is defined as @Target(METHOD) [JSR-299 �2.7.1.5]
+ILLEGAL_TARGET_IN_STEREOTYPE_TYPE_F=Stereotype {0} is defined as @Target(TYPE) and may
not be applied to stereotype {1} which is defined as @Target(FIELD) [JSR-299 �2.7.1.5]
+ILLEGAL_TARGET_IN_STEREOTYPE_TYPE_MF=Stereotype {0} is defined as @Target(TYPE) and may
not be applied to stereotype {1} which is defined as @Target('{METHOD, FIELD}')
[JSR-299 �2.7.1.5]
+ILLEGAL_TARGET_IN_INTERCEPTOR_BINDING_TYPE=Interceptor binding type {0} is defined as
@Target(TYPE) and may not be applied to interceptor binding type {1} which is defined as
@Target('{TYPE, METHOD}') [JSR-299 �9.1.1]
ILLEGAL_TARGET_IN_INTERCEPTOR_BINDING_TYPE_FOR_STEREOTYPE=Stereotype {0} must be defined
as @Target(TYPE) since it declares interceptor bindings ({1}) [JSR-299 �9.1.2]
MULTIPLE_SCOPE_TYPE_ANNOTATIONS=Bean class or producer method or field specifies multiple
scope type annotations [JSR-299 �2.4.3]
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/AnnotationsValidationTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/AnnotationsValidationTest.java 2010-12-15
18:28:01 UTC (rev 27521)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/AnnotationsValidationTest.java 2010-12-15
19:26:48 UTC (rev 27522)
@@ -113,11 +113,11 @@
public void testInterceptorBindingsForStereotypes() throws Exception {
IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/target/StereotypeWithInterceptorBindingBroken.java");
- assertMarkerIsCreated(file,
MessageFormat.format(CDIValidationMessages.ILLEGAL_TARGET_IN_INTERCEPTOR_BINDING_TYPE_FOR_STEREOTYPE,
"StereotypeWithInterceptorBindingBroken",
"InterceptorBindingWTypeTarget"), 15);
+ assertMarkerIsCreated(file,
MessageFormat.format(CDIValidationMessages.ILLEGAL_TARGET_IN_INTERCEPTOR_BINDING_TYPE_FOR_STEREOTYPE,
"StereotypeWithInterceptorBindingBroken",
"InterceptorBindingWTypeTarget"), 16);
}
public void testInterceptorBindingsForStereotypesOk() throws Exception {
IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/target/StereotypeOk.java");
- assertMarkerIsNotCreated(file,
MessageFormat.format(CDIValidationMessages.ILLEGAL_TARGET_IN_INTERCEPTOR_BINDING_TYPE_FOR_STEREOTYPE,
"StereotypeOk", "InterceptorBindingWTypeTarget"), 14);
+ assertMarkerIsNotCreated(file,
MessageFormat.format(CDIValidationMessages.ILLEGAL_TARGET_IN_INTERCEPTOR_BINDING_TYPE_FOR_STEREOTYPE,
"StereotypeOk", "InterceptorBindingWTypeTarget"), 15);
}
}
\ No newline at end of file