Author: akazakov
Date: 2011-09-16 13:38:47 -0400 (Fri, 16 Sep 2011)
New Revision: 34824
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBeanMember.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IInjectionPoint.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointField.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointParameter.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/testmodel/CDIInjectionPoint.java
Log:
https://issues.jboss.org/browse/JBIDE-9723 Injection points declared in producer methods
should be validated as injection points of the producer but not as injections of the class
bean
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBeanMember.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBeanMember.java 2011-09-16
16:38:21 UTC (rev 34823)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBeanMember.java 2011-09-16
17:38:47 UTC (rev 34824)
@@ -22,7 +22,7 @@
public interface IBeanMember extends IJavaSourceReference, IAnnotated, ICDIElement {
/**
- * Returns the class bean that declares this method.
+ * Returns the class bean that declares this member.
*
* @return
*/
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IInjectionPoint.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IInjectionPoint.java 2011-09-16
16:38:21 UTC (rev 34823)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IInjectionPoint.java 2011-09-16
17:38:47 UTC (rev 34824)
@@ -24,6 +24,13 @@
public interface IInjectionPoint extends ICDIElement, IBeanMember {
/**
+ * Returns the bean that declares this injection point.
+ *
+ * @return the bean that declares this injection point.
+ */
+ IBean getBean();
+
+ /**
* Returns the required type of this injection point.
*
* @return the required type of this injection point.
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointField.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointField.java 2011-09-16
16:38:21 UTC (rev 34823)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointField.java 2011-09-16
17:38:47 UTC (rev 34824)
@@ -12,6 +12,7 @@
import org.jboss.tools.cdi.core.CDIConstants;
import org.jboss.tools.cdi.core.CDIUtil;
+import org.jboss.tools.cdi.core.IBean;
import org.jboss.tools.cdi.core.IInjectionPointField;
import org.jboss.tools.common.java.IAnnotationDeclaration;
import org.jboss.tools.common.java.IParametedType;
@@ -25,6 +26,7 @@
public InjectionPointField() {}
+ @Override
public IParametedType getType() {
if(getDefinition().getOverridenType() != null) {
return getDefinition().getOverridenType();
@@ -53,6 +55,7 @@
* (non-Javadoc)
* @see org.jboss.tools.cdi.core.IInjectionPoint#getDelegateAnnotation()
*/
+ @Override
public IAnnotationDeclaration getDelegateAnnotation() {
return getDefinition().getDelegateAnnotation();
}
@@ -61,6 +64,7 @@
* (non-Javadoc)
* @see org.jboss.tools.cdi.core.IInjectionPoint#isDelegate()
*/
+ @Override
public boolean isDelegate() {
return getDelegateAnnotation() != null;
}
@@ -69,6 +73,7 @@
* (non-Javadoc)
* @see org.jboss.tools.cdi.core.IInjectionPoint#getInjectAnnotation()
*/
+ @Override
public IAnnotationDeclaration getInjectAnnotation() {
return definition.getAnnotation(CDIConstants.INJECT_ANNOTATION_TYPE_NAME);
}
@@ -77,7 +82,18 @@
* (non-Javadoc)
* @see org.jboss.tools.cdi.core.IInjectionPoint#containsDefaultQualifier()
*/
+ @Override
public boolean hasDefaultQualifier() {
return CDIUtil.containsDefaultQualifier(this);
}
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.cdi.core.IInjectionPoint#getBean()
+ */
+ @Override
+ public IBean getBean() {
+ // TODO we should return the actual bean that declares this injection point.
+ return getClassBean();
+ }
}
\ No newline at end of file
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointParameter.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointParameter.java 2011-09-16
16:38:21 UTC (rev 34823)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointParameter.java 2011-09-16
17:38:47 UTC (rev 34824)
@@ -14,6 +14,7 @@
import org.jboss.tools.cdi.core.CDIConstants;
import org.jboss.tools.cdi.core.CDIUtil;
+import org.jboss.tools.cdi.core.IBean;
import org.jboss.tools.cdi.core.IInjectionPointParameter;
import org.jboss.tools.cdi.core.IQualifierDeclaration;
import org.jboss.tools.common.java.IAnnotationDeclaration;
@@ -31,6 +32,7 @@
* (non-Javadoc)
* @see org.jboss.tools.cdi.core.IInjectionPoint#getDelegateAnnotation()
*/
+ @Override
public ITextSourceReference getDelegateAnnotation() {
return getAnnotationPosition(CDIConstants.DELEGATE_STEREOTYPE_TYPE_NAME);
}
@@ -39,6 +41,7 @@
* (non-Javadoc)
* @see org.jboss.tools.cdi.core.IInjectionPoint#getQualifierDeclarations()
*/
+ @Override
public Set<IQualifierDeclaration> getQualifierDeclarations() {
return super.getQualifierDeclarations();
}
@@ -47,6 +50,7 @@
* (non-Javadoc)
* @see org.jboss.tools.cdi.core.IInjectionPoint#isDelegate()
*/
+ @Override
public boolean isDelegate() {
return isAnnotationPresent(CDIConstants.DELEGATE_STEREOTYPE_TYPE_NAME);
}
@@ -55,6 +59,7 @@
* (non-Javadoc)
* @see org.jboss.tools.cdi.core.IInjectionPoint#getInjectAnnotation()
*/
+ @Override
public IAnnotationDeclaration getInjectAnnotation() {
return beanMethod.inject;
}
@@ -63,6 +68,7 @@
* (non-Javadoc)
* @see org.jboss.tools.cdi.core.IInjectionPoint#containsDefaultQualifier()
*/
+ @Override
public boolean hasDefaultQualifier() {
return CDIUtil.containsDefaultQualifier(this);
}
@@ -78,4 +84,14 @@
}
return null;
}
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.cdi.core.IInjectionPoint#getBean()
+ */
+ @Override
+ public IBean getBean() {
+ // TODO we should return the actual bean that declares this injection point.
+ return getClassBean();
+ }
}
\ 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 2011-09-16
16:38:21 UTC (rev 34823)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java 2011-09-16
17:38:47 UTC (rev 34824)
@@ -1661,7 +1661,7 @@
* - bean that declares any scope other than @Dependent has an injection point of
type InjectionPoint and qualifier @Default
*/
if(type!=null &&
CDIConstants.INJECTIONPOINT_TYPE_NAME.equals(type.getFullyQualifiedName())) {
- IScope beanScope = injection.getClassBean().getScope();
+ IScope beanScope = injection.getBean().getScope();
if(injection.hasDefaultQualifier() && beanScope!=null &&
!CDIConstants.DEPENDENT_ANNOTATION_TYPE_NAME.equals(beanScope.getSourceType().getFullyQualifiedName()))
{
addError(CDIValidationMessages.ILLEGAL_SCOPE_WHEN_TYPE_INJECTIONPOINT_IS_INJECTED,
CDIPreferences.ILLEGAL_SCOPE_WHEN_TYPE_INJECTIONPOINT_IS_INJECTED, reference,
injection.getResource());
}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/testmodel/CDIInjectionPoint.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/testmodel/CDIInjectionPoint.java 2011-09-16
16:38:21 UTC (rev 34823)
+++
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/testmodel/CDIInjectionPoint.java 2011-09-16
17:38:47 UTC (rev 34824)
@@ -6,6 +6,7 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.IMember;
+import org.jboss.tools.cdi.core.IBean;
import org.jboss.tools.cdi.core.ICDIProject;
import org.jboss.tools.cdi.core.IClassBean;
import org.jboss.tools.cdi.core.IInjectionPoint;
@@ -148,4 +149,9 @@
public String getElementName() {
return null;
}
+
+ @Override
+ public IBean getBean() {
+ return null;
+ }
}
\ No newline at end of file