Author: akazakov
Date: 2010-05-20 16:46:39 -0400 (Thu, 20 May 2010)
New Revision: 22225
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/producers/NonStaticProducerOfSessionBeanBroken.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/producers/ProducerAnnotatedInjectBroken.java
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/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: Non-static
field of a session bean class is annotated @Produces
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-20
20:08:36 UTC (rev 22224)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java 2010-05-20
20:46:39 UTC (rev 22225)
@@ -582,8 +582,7 @@
if (nameDeclaration != null) {
declaration = nameDeclaration;
}
- addError(CDIValidationMessages.RESOURCE_PRODUCER_FIELD_SETS_EL_NAME,
CDIPreferences.RESOURCE_PRODUCER_FIELD_SETS_EL_NAME,
- declaration, producer.getResource());
+ addError(CDIValidationMessages.RESOURCE_PRODUCER_FIELD_SETS_EL_NAME,
CDIPreferences.RESOURCE_PRODUCER_FIELD_SETS_EL_NAME, declaration,
producer.getResource());
}
}
}
@@ -596,11 +595,17 @@
for (String variableSig : typeVariables) {
String variableName = Signature.getTypeVariable(variableSig);
if (typeString.equals(variableName)) {
- addError(CDIValidationMessages.PRODUCER_FIELD_TYPE_IS_VARIABLE,
CDIPreferences.PRODUCER_FIELD_TYPE_IS_VARIABLE,
- typeDeclaration != null ? typeDeclaration : producer, producer.getResource());
+ addError(CDIValidationMessages.PRODUCER_FIELD_TYPE_IS_VARIABLE,
CDIPreferences.PRODUCER_FIELD_TYPE_IS_VARIABLE, typeDeclaration != null ? typeDeclaration
: producer, producer.getResource());
}
}
}
+ /*
+ * 3.4.2. Declaring a producer field
+ * - non-static field of a session bean class is annotated @Produces
+ */
+ if(producer.getClassBean() instanceof ISessionBean &&
!Flags.isStatic(producerField.getField().getFlags())) {
+ addError(CDIValidationMessages.ILLEGAL_PRODUCER_FIELD_IN_SESSION_BEAN,
CDIPreferences.ILLEGAL_PRODUCER_FIELD_IN_SESSION_BEAN, producer.getProducesAnnotation(),
producer.getResource());
+ }
} else {
IProducerMethod producerMethod = (IProducerMethod) producer;
List<IParameter> params = producerMethod.getParameters();
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-20
20:08:36 UTC (rev 22224)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/errorList.txt 2010-05-20
20:46:39 UTC (rev 22225)
@@ -65,9 +65,6 @@
is not a business method of the session bean
- interceptor or decorator has a method annotated @Produces
-
-
-
3.3.3. Specializing a producer method
- method annotated @Specializes is static or does not directly override another producer
method
@@ -94,6 +91,9 @@
- non-static field of a session bean class is annotated @Produces
- interceptor or decorator has a field annotated @Produces
+
+
+
3.5.1. Declaring a resource
- producer field declaration specifies an EL name (together with one of
@Resource, @PersistenceContext, @PersistenceUnit, @EJB, @WebServiceRef)
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-20
20:08:36 UTC (rev 22224)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIConfigurationBlock.java 2010-05-20
20:46:39 UTC (rev 22225)
@@ -86,7 +86,7 @@
{CDIPreferences.ILLEGAL_DISPOSER_IN_SESSION_BEAN,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_illegalDisposerInSessionBean_label},
{CDIPreferences.NO_PRODUCER_MATCHING_DISPOSER,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_noProducerMatchingDisposer_label},
{CDIPreferences.MULTIPLE_DISPOSERS_FOR_PRODUCER,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_multipleDisposersForProducer_label},
-// {CDIPreferences.ILLEGAL_PRODUCER_FIELD_IN_SESSION_BEAN,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_illegalProducerFieldInSessionBean_label},
+ {CDIPreferences.ILLEGAL_PRODUCER_FIELD_IN_SESSION_BEAN,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_illegalProducerFieldInSessionBean_label},
// {CDIPreferences.MULTIPLE_INJECTION_CONSTRUCTORS,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_multipleInjectionConstructors_label},
// {CDIPreferences.CONSTRUCTOR_PARAMETER_ILLEGALLY_ANNOTATED,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_constructorParameterIllegallyAnnotated_label},
// {CDIPreferences.GENERIC_METHOD_ANNOTATED_INJECT,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_genericMethodAnnotatedInject_label},
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/producers/NonStaticProducerOfSessionBeanBroken.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/producers/NonStaticProducerOfSessionBeanBroken.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/producers/NonStaticProducerOfSessionBeanBroken.java 2010-05-20
20:46:39 UTC (rev 22225)
@@ -0,0 +1,10 @@
+package org.jboss.jsr299.tck.tests.jbt.validation.producers;
+
+import javax.ejb.Stateless;
+import javax.enterprise.inject.Produces;
+
+@Stateless
+public class NonStaticProducerOfSessionBeanBroken {
+
+ @Produces public FunnelWeaver<String> anotherFunnelWeaver;
+}
\ No newline at end of file
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/producers/NonStaticProducerOfSessionBeanBroken.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/producers/ProducerAnnotatedInjectBroken.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/producers/ProducerAnnotatedInjectBroken.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/producers/ProducerAnnotatedInjectBroken.java 2010-05-20
20:46:39 UTC (rev 22225)
@@ -0,0 +1,9 @@
+package org.jboss.jsr299.tck.tests.jbt.validation.producers;
+
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+
+public class ProducerAnnotatedInjectBroken {
+
+ @Produces @Inject public FunnelWeaver<String> anotherFunnelWeaver;
+}
\ No newline at end of file
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/producers/ProducerAnnotatedInjectBroken.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-20
20:08:36 UTC (rev 22224)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ValidationTest.java 2010-05-20
20:46:39 UTC (rev 22225)
@@ -549,28 +549,6 @@
}
/**
- * 3.5.1. Declaring a resource
- * - producer field declaration specifies an EL name (together with one of @Resource,
@PersistenceContext, @PersistenceUnit, @EJB, @WebServiceRef)
- *
- * @throws Exception
- */
- public void testResourceWithELName() throws Exception {
- IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/resources/ProducerFieldsBroken.java");
- AbstractResourceMarkerTest.assertMarkerIsCreated(file,
AbstractResourceMarkerTest.MARKER_TYPE,
CDIValidationMessages.RESOURCE_PRODUCER_FIELD_SETS_EL_NAME, 15, 19, 24, 27, 31);
- }
-
- /**
- * 3.11. The qualifier @Named at injection points
- * - injection point other than injected field declares a @Named annotation that does
not specify the value member
- *
- * @throws Exception
- */
- public void testNamedInjectPoint() throws Exception {
- IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/inject/NamedInjectionBroken.java");
- AbstractResourceMarkerTest.assertMarkerIsCreated(file,
AbstractResourceMarkerTest.MARKER_TYPE,
CDIValidationMessages.PARAM_INJECTION_DECLARES_EMPTY_NAME, 10, 16);
- }
-
- /**
* 3.3.6. Declaring a disposer method
* - method has more than one parameter annotated @Disposes
*
@@ -711,6 +689,28 @@
/**
* 3.4.2. Declaring a producer field
+ * - producer field is annotated @Inject
+ *
+ * @throws Exception
+ */
+ public void testProducerAnnotatedInject() throws Exception {
+ IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/producers/ProducerAnnotatedInjectBroken.java");
+ AbstractResourceMarkerTest.assertMarkerIsCreated(file,
AbstractResourceMarkerTest.MARKER_TYPE, CDIValidationMessages.PRODUCER_ANNOTATED_INJECT,
8);
+ }
+
+ /**
+ * 3.4.2. Declaring a producer field
+ * - non-static field of a session bean class is annotated @Produces
+ *
+ * @throws Exception
+ */
+ public void testNonStaticProducerOfSessionBean() throws Exception {
+ IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/producers/NonStaticProducerOfSessionBeanBroken.java");
+ AbstractResourceMarkerTest.assertMarkerIsCreated(file,
AbstractResourceMarkerTest.MARKER_TYPE,
CDIValidationMessages.ILLEGAL_PRODUCER_FIELD_IN_SESSION_BEAN, 9);
+ }
+
+ /**
+ * 3.4.2. Declaring a producer field
* - decorator has a field annotated @Produces
*
* @throws Exception
@@ -732,6 +732,17 @@
}
/**
+ * 3.5.1. Declaring a resource
+ * - producer field declaration specifies an EL name (together with one of @Resource,
@PersistenceContext, @PersistenceUnit, @EJB, @WebServiceRef)
+ *
+ * @throws Exception
+ */
+ public void testResourceWithELName() throws Exception {
+ IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/resources/ProducerFieldsBroken.java");
+ AbstractResourceMarkerTest.assertMarkerIsCreated(file,
AbstractResourceMarkerTest.MARKER_TYPE,
CDIValidationMessages.RESOURCE_PRODUCER_FIELD_SETS_EL_NAME, 15, 19, 24, 27, 31);
+ }
+
+ /**
* 3.9.1. Declaring an initializer method
* - an initializer method has a parameter annotated @Disposes
*
@@ -744,6 +755,17 @@
}
/**
+ * 3.11. The qualifier @Named at injection points
+ * - injection point other than injected field declares a @Named annotation that does
not specify the value member
+ *
+ * @throws Exception
+ */
+ public void testNamedInjectPoint() throws Exception {
+ IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/inject/NamedInjectionBroken.java");
+ AbstractResourceMarkerTest.assertMarkerIsCreated(file,
AbstractResourceMarkerTest.MARKER_TYPE,
CDIValidationMessages.PARAM_INJECTION_DECLARES_EMPTY_NAME, 10, 16);
+ }
+
+ /**
* 10.4.2. Declaring an observer method
* - an observer method is annotated @Produces
*