Author: akazakov
Date: 2010-03-17 08:57:46 -0400 (Wed, 17 Mar 2010)
New Revision: 20879
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBean.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AbstractBeanElement.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/QualifierDefinitionTest.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5808
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBean.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBean.java 2010-03-17
12:42:58 UTC (rev 20878)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBean.java 2010-03-17
12:57:46 UTC (rev 20879)
@@ -82,12 +82,22 @@
/**
* Obtains the qualifier declarations of the bean class or producer method or field.
+ * This method doesn't return inherited qualifiers and equals
getQualifierDeclarations(false);
*
* @return the qualifiers
*/
Set<IQualifierDeclaration> getQualifierDeclarations();
/**
+ * Obtains the qualifier declarations of the bean class or producer method
+ * or field.
+ *
+ * @param includeInherited if "true" then the result includes declarations of
inherited qualifiers.
+ * @return the qualifiers
+ */
+ Set<IQualifierDeclaration> getQualifierDeclarations(boolean includeInherited);
+
+ /**
* Obtains the qualifiers of the bean class or producer method or field.
* Note a Bean has @Any (except for the special @New) and @Default qualifiers even
* if there is not any Qualifier declarations.
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AbstractBeanElement.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AbstractBeanElement.java 2010-03-17
12:42:58 UTC (rev 20878)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AbstractBeanElement.java 2010-03-17
12:57:46 UTC (rev 20879)
@@ -90,6 +90,11 @@
}
public Set<IQualifierDeclaration> getQualifierDeclarations() {
+ return getQualifierDeclarations(false);
+ }
+
+ public Set<IQualifierDeclaration> getQualifierDeclarations(boolean
includeInherited) {
+ // TODO take into account includeInherited parameter.
Set<IQualifierDeclaration> result = new HashSet<IQualifierDeclaration>();
for(AnnotationDeclaration a: definition.getAnnotations()) {
int k = getCDIProject().getNature().getDefinitions().getAnnotationKind(a.getType());
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java 2010-03-17
12:42:58 UTC (rev 20878)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java 2010-03-17
12:57:46 UTC (rev 20879)
@@ -200,7 +200,7 @@
Set<IParametedType> types = b.getLegalTypes();
if(containsType(types, type)) {
try {
- Set<IQualifierDeclaration> qsb = b.getQualifierDeclarations();
+ Set<IQualifierDeclaration> qsb = b.getQualifierDeclarations(true);
if(areMatchingQualifiers(qsb, qs)) {
result.add(b);
}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/QualifierDefinitionTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/QualifierDefinitionTest.java 2010-03-17
12:42:58 UTC (rev 20878)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/QualifierDefinitionTest.java 2010-03-17
12:57:46 UTC (rev 20879)
@@ -169,4 +169,42 @@
assertContainsQualifierType(bean, "javax.enterprise.inject.Default");
assertContainsQualifierType(bean, "javax.enterprise.inject.Any");
}
+
+ /**
+ * section 4.1 aa)
+ * @throws JavaModelException
+ */
+ public void testQualifierDeclaredInheritedIsBlockedByIntermediateClass() throws
JavaModelException {
+ IAnnotationDeclaration hairy =
getAnnotationDeclarationFromBean("JavaSource/org/jboss/jsr299/tck/tests/definition/qualifier/ClippedBorderCollie.java",
"org.jboss.jsr299.tck.tests.definition.qualifier.Hairy");
+ IType type =
getType("org.jboss.jsr299.tck.tests.definition.qualifier.ClippedBorderCollie");
+ Set<IBean> beans = cdiProject.getBeans(true, type, hairy);
+ assertEquals("Wrong number of beans.", 1, beans.size());
+ IBean bean = beans.iterator().next();
+ Set<IQualifier> qualifiers = bean.getQualifiers();
+ assertEquals("Wrong number of qualifiers for
org.jboss.jsr299.tck.tests.definition.qualifier.ClippedBorderCollie type.", 2,
qualifiers.size());
+ assertContainsQualifierType(bean,
"org.jboss.jsr299.tck.tests.definition.qualifier.Hairy");
+ assertContainsQualifierType(bean, "javax.enterprise.inject.Any");
+ }
+
+ /**
+ * section 4.1 ag)
+ * @throws JavaModelException
+ */
+ public void testQualifierDeclaredInheritedIsIndirectlyInherited() throws
JavaModelException {
+ IAnnotationDeclaration hairy =
getAnnotationDeclarationFromBean("JavaSource/org/jboss/jsr299/tck/tests/definition/qualifier/LongHairedDog.java",
"org.jboss.jsr299.tck.tests.definition.qualifier.Hairy");
+ IType type =
getType("org.jboss.jsr299.tck.tests.definition.qualifier.EnglishBorderCollie");
+ Set<IBean> beans = cdiProject.getBeans(true, type, hairy);
+ assertEquals("Wrong number of beans.", 1, beans.size());
+ IBean bean = beans.iterator().next();
+ Set<IQualifier> qualifiers = bean.getQualifiers();
+ assertEquals("Wrong number of qualifiers for
org.jboss.jsr299.tck.tests.definition.qualifier.EnglishBorderCollie type.", 2,
qualifiers.size());
+ assertContainsQualifierType(bean,
"org.jboss.jsr299.tck.tests.definition.qualifier.Hairy");
+ assertContainsQualifierType(bean, "javax.enterprise.inject.Any");
+
+// Set<? extends Annotation> bindings = getBeans(
+// EnglishBorderCollie.class, new HairyQualifier(false))
+// .iterator().next().getQualifiers();
+// assert bindings.size() == 2;
+// assert bindings.contains(new HairyQualifier(false));
+ }
}
\ No newline at end of file
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java 2010-03-17
12:42:58 UTC (rev 20878)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java 2010-03-17
12:57:46 UTC (rev 20879)
@@ -195,7 +195,7 @@
fail(bean.getResource().getFullPath() + " bean " + allTypes.toString() +
" should have " + typeName + " type.");
}
- protected void assertContainsQualifierType(IBean bean, String typeName) {
+ public static void assertContainsQualifierType(IBean bean, String typeName) {
Set<IQualifier> qualifiers = bean.getQualifiers();
StringBuffer allTypes = new StringBuffer("[");
for (IQualifier qualifier : qualifiers) {