Author: akazakov
Date: 2010-02-10 09:54:17 -0500 (Wed, 10 Feb 2010)
New Revision: 20218
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.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
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-02-10
14:46:31 UTC (rev 20217)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java 2010-02-10
14:54:17 UTC (rev 20218)
@@ -37,6 +37,7 @@
import org.jboss.tools.cdi.core.ICDIProject;
import org.jboss.tools.cdi.core.IParametedType;
import org.jboss.tools.cdi.core.IQualifierDeclaration;
+import org.jboss.tools.cdi.core.IScopeDeclaration;
import org.jboss.tools.cdi.core.IStereotype;
import org.jboss.tools.cdi.core.ITypeDeclaration;
import org.jboss.tools.cdi.core.preferences.CDIPreferences;
@@ -239,11 +240,19 @@
validationContext.addVariableNameForELValidation(name);
}
- // 2.2.2. Restricting the bean types of a bean
- // - bean class or producer method or field specifies a @Typed annotation,
- // and the value member specifies a class which does not correspond to a type
- // in the unrestricted set of bean types of a bean
- int i = 0;
+ validateTyped(bean);
+ validateBeanScope(bean);
+
+ // TODO
+ }
+
+ /*
+ * 2.2.2. Restricting the bean types of a bean
+ * - bean class or producer method or field specifies a @Typed annotation,
+ * and the value member specifies a class which does not correspond to a type
+ * in the unrestricted set of bean types of a bean
+ */
+ private void validateTyped(IBean bean) {
Set<ITypeDeclaration> typedDeclarations = bean.getRestrictedTypeDeclaratios();
if(!typedDeclarations.isEmpty()) {
Set<IParametedType> allTypes = bean.getAllTypes();
@@ -263,9 +272,21 @@
}
}
}
- // TODO
}
+ /*
+ * 2.4.3. Declaring the bean scope
+ * - bean class or producer method or field specifies multiple scope type
annotations
+ */
+ private void validateBeanScope(IBean bean) {
+ Set<IScopeDeclaration> scopes = bean.getScopeDeclarations();
+ if(scopes.size()>1) {
+ for (IScopeDeclaration scope : scopes) {
+ addError(CDIValidationMessages.MULTIPLE_SCOPE_TYPE_ANNOTATIONS,
CDIPreferences.MULTIPLE_SCOPE_TYPE_ANNOTATIONS, scope, bean.getResource());
+ }
+ }
+ }
+
/**
* Validates a stereotype.
* 2.7.1.3. Declaring a @Named stereotype
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-02-10
14:46:31 UTC (rev 20217)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIConfigurationBlock.java 2010-02-10
14:54:17 UTC (rev 20218)
@@ -55,10 +55,10 @@
CDICorePlugin.PLUGIN_ID
);
-// private static SectionDescription SECTION_SCOPE = new SectionDescription(
-// CDIPreferencesMessages.CDIValidatorConfigurationBlock_section_scope,
-// new String[][]{
-// {CDIPreferences.MULTIPLE_SCOPE_TYPE_ANNOTATIONS,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_multipleScopeTypeAnnotations_label},
+ private static SectionDescription SECTION_SCOPE = new SectionDescription(
+ CDIPreferencesMessages.CDIValidatorConfigurationBlock_section_scope,
+ new String[][]{
+ {CDIPreferences.MULTIPLE_SCOPE_TYPE_ANNOTATIONS,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_multipleScopeTypeAnnotations_label},
// {CDIPreferences.MISSING_SCOPE_WHEN_THERE_IS_NO_DEFAULT_SCOPE,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_missingScopeWhenThereIsNoDefaultScope_label},
// {CDIPreferences.STEREOTYPE_DECLARES_MORE_THAN_ONE_SCOPE,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_stereotypeDeclaresMoreThanOneScope_label},
// {CDIPreferences.ILLEGAL_SCOPE_FOR_MANAGED_BEAN,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_illegalScopeForManagedBean_label},
@@ -68,9 +68,9 @@
// {CDIPreferences.ILLEGAL_SCOPE_WHEN_TYPE_INJECTIONPOINT_IS_INJECTED,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_illegalScopeWhenTypeInjectionPointIsInjected_label},
// {CDIPreferences.ILLEGAL_SCOPE_FOR_INTERCEPTOR,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_illegalScopeForInterceptor_label},
// {CDIPreferences.ILLEGAL_SCOPE_FOR_DECORATOR,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_illegalScopeForDecorator_label},
-// },
-// CDICorePlugin.PLUGIN_ID
-// );
+ },
+ CDICorePlugin.PLUGIN_ID
+ );
// private static SectionDescription SECTION_MEMBER = new SectionDescription(
// CDIPreferencesMessages.CDIValidatorConfigurationBlock_section_member,
@@ -145,7 +145,7 @@
private static SectionDescription[] ALL_SECTIONS = new SectionDescription[]{
SECTION_NAME,
SECTION_TYPE,
-// SECTION_SCOPE,
+ SECTION_SCOPE,
// SECTION_MEMBER,
// SECTION_INTERCEPTOR,
// SECTION_SPECIALIZATION,
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-02-10
14:46:31 UTC (rev 20217)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ValidationTest.java 2010-02-10
14:54:17 UTC (rev 20218)
@@ -65,6 +65,19 @@
cleanProject("/definition/stereotype");
}
+ /*
+ * 2.4.3. Declaring the bean scope
+ * - bean class or producer method or field specifies multiple scope type
annotations
+ */
+ public void testBeanScope() throws Exception {
+ IProject p = importPreparedProject("/definition/scope");
+ IFile file =
p.getFile("JavaSource/org/jboss/jsr299/tck/tests/definition/scope/broken/tooManyScopes/BeanWithTooManyScopeTypes_Broken.java");
+ AbstractResourceMarkerTest.assertMarkerIsCreated(file,
AbstractResourceMarkerTest.MARKER_TYPE, "Bean class or producer method or field
specifies multiple scope type annotations", 6, 7);
+ int markerNumbers = getMarkersNumber(file);
+ assertEquals("StereotypeWithTyped_Broken.java should has two error markers.",
markerNumbers, 2);
+ cleanProject("/definition/scope");
+ }
+
public static int getMarkersNumber(IResource resource) {
return AbstractResourceMarkerTest.getMarkersNumberByGroupName(resource, null);
}