Author: akazakov
Date: 2010-05-27 13:25:55 -0400 (Thu, 27 May 2010)
New Revision: 22383
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/specialization/SpecializingDecoratorBroken.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/specialization/SpecializingInterceptorBroken.java
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferenceInitializer.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.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.ui/src/org/jboss/tools/cdi/ui/preferences/CDIConfigurationBlock.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ValidationTest.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2708 Added new CDI validation rule: interceptor
or decorator is annotated @Specializes (Non-Portable behavior)
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferenceInitializer.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferenceInitializer.java 2010-05-27
17:22:32 UTC (rev 22382)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferenceInitializer.java 2010-05-27
17:25:55 UTC (rev 22383)
@@ -36,5 +36,7 @@
defaultPreferences.put(CDIPreferences.ILLEGAL_SCOPE_FOR_INTERCEPTOR,
CDIPreferences.WARNING);
defaultPreferences.put(CDIPreferences.ILLEGAL_SCOPE_FOR_DECORATOR,
CDIPreferences.WARNING);
defaultPreferences.put(CDIPreferences.INTERCEPTOR_OR_DECORATOR_IS_ALTERNATIVE,
CDIPreferences.WARNING);
+ defaultPreferences.put(CDIPreferences.INTERCEPTOR_ANNOTATED_SPECIALIZES,
CDIPreferences.WARNING);
+ defaultPreferences.put(CDIPreferences.DECORATOR_ANNOTATED_SPECIALIZES,
CDIPreferences.WARNING);
}
}
\ No newline at end of file
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java 2010-05-27
17:22:32 UTC (rev 22382)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java 2010-05-27
17:25:55 UTC (rev 22383)
@@ -351,6 +351,19 @@
}
private void validateSpecializingBean(IBean bean) {
+ /*
+ * 4.3.1. Direct and indirect specialization
+ * - decorator or interceptor is annotated @Specializes (Non-Portable behavior)
+ */
+ IAnnotationDeclaration specializesDeclaration =
bean.getSpecializesAnnotationDeclaration();
+ if(specializesDeclaration!=null) {
+ if(bean instanceof IDecorator) {
+ addError(CDIValidationMessages.DECORATOR_ANNOTATED_SPECIALIZES,
CDIPreferences.DECORATOR_ANNOTATED_SPECIALIZES, specializesDeclaration,
bean.getResource());
+ } else if(bean instanceof IInterceptor) {
+ addError(CDIValidationMessages.INTERCEPTOR_ANNOTATED_SPECIALIZES,
CDIPreferences.INTERCEPTOR_ANNOTATED_SPECIALIZES, specializesDeclaration,
bean.getResource());
+ }
+ }
+
IBean specializingBean = bean.getSpecializedBean();
if(specializingBean==null) {
return;
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-05-27
17:22:32 UTC (rev 22382)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/errorList.txt 2010-05-27
17:25:55 UTC (rev 22383)
@@ -117,10 +117,6 @@
- injection point other than injected field declares a @Named annotation that
does not specify the value member
-
-
-
-
4.3.1. Direct and indirect specialization
- X specializes Y but does not have some bean type of Y
- X specializes Y and Y has a name and X declares a name explicitly, using @Named
@@ -129,9 +125,6 @@
-
-
-
5.2.2. Legal injection point types
- injection point type is a type variable
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIConfigurationBlock.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIConfigurationBlock.java 2010-05-27
17:22:32 UTC (rev 22382)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIConfigurationBlock.java 2010-05-27
17:25:55 UTC (rev 22383)
@@ -127,8 +127,8 @@
{CDIPreferences.ILLEGAL_SPECIALIZING_PRODUCER,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_illegalSpecializingProducer_label},
{CDIPreferences.MISSING_TYPE_IN_SPECIALIZING_BEAN,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_missingTypeInSpecializingBean_label},
{CDIPreferences.CONFLICTING_NAME_IN_SPECIALIZING_BEAN,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_conflictingNameInSpecializingBean_label},
-// {CDIPreferences.INTERCEPTOR_ANNOTATED_SPECIALIZES,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_interceptorAnnotatedSpecializes_label},
-// {CDIPreferences.DECORATOR_ANNOTATED_SPECIALIZES,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_decoratorAnnotatedSpecializes_label},
+ {CDIPreferences.INTERCEPTOR_ANNOTATED_SPECIALIZES,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_interceptorAnnotatedSpecializes_label},
+ {CDIPreferences.DECORATOR_ANNOTATED_SPECIALIZES,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_decoratorAnnotatedSpecializes_label},
},
CDICorePlugin.PLUGIN_ID
);
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/specialization/SpecializingDecoratorBroken.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/specialization/SpecializingDecoratorBroken.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/specialization/SpecializingDecoratorBroken.java 2010-05-27
17:25:55 UTC (rev 22383)
@@ -0,0 +1,14 @@
+package org.jboss.jsr299.tck.tests.jbt.validation.specialization;
+
+import javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.enterprise.inject.Any;
+import javax.enterprise.inject.Specializes;
+import javax.inject.Inject;
+
+@Decorator
+@Specializes
+public class SpecializingDecoratorBroken extends Farmer {
+
+ @Inject @Delegate @Any Object logger;
+}
\ No newline at end of file
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/specialization/SpecializingDecoratorBroken.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/specialization/SpecializingInterceptorBroken.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/specialization/SpecializingInterceptorBroken.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/specialization/SpecializingInterceptorBroken.java 2010-05-27
17:25:55 UTC (rev 22383)
@@ -0,0 +1,16 @@
+package org.jboss.jsr299.tck.tests.jbt.validation.specialization;
+
+import javax.enterprise.inject.Specializes;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+
+@Interceptor
+@Specializes
+public class SpecializingInterceptorBroken extends Farmer {
+
+ @AroundInvoke
+ public Object alwaysReturnThis(InvocationContext ctx) throws Exception {
+ return ctx.proceed();
+ }
+}
\ No newline at end of file
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/specialization/SpecializingInterceptorBroken.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ValidationTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ValidationTest.java 2010-05-27
17:22:32 UTC (rev 22382)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ValidationTest.java 2010-05-27
17:25:55 UTC (rev 22383)
@@ -864,6 +864,28 @@
}
/**
+ * 4.3.1. Direct and indirect specialization
+ * - interceptor is annotated @Specializes (Non-Portable behavior)
+ *
+ * @throws Exception
+ */
+ public void testSpecializingInterceptor() throws Exception {
+ IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/specialization/SpecializingInterceptorBroken.java");
+ AbstractResourceMarkerTest.assertMarkerIsCreated(file,
AbstractResourceMarkerTest.MARKER_TYPE,
CDIValidationMessages.INTERCEPTOR_ANNOTATED_SPECIALIZES, 9);
+ }
+
+ /**
+ * 4.3.1. Direct and indirect specialization
+ * - decorator is annotated @Specializes (Non-Portable behavior)
+ *
+ * @throws Exception
+ */
+ public void testSpecializingDecorator() throws Exception {
+ IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/specialization/SpecializingDecoratorBroken.java");
+ AbstractResourceMarkerTest.assertMarkerIsCreated(file,
AbstractResourceMarkerTest.MARKER_TYPE,
CDIValidationMessages.DECORATOR_ANNOTATED_SPECIALIZES, 10);
+ }
+
+ /**
* 10.4.2. Declaring an observer method
* - method has more than one parameter annotated @Observes
*