Author: akazakov
Date: 2010-12-15 15:02:53 -0500 (Wed, 15 Dec 2010)
New Revision: 27523
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/AnnotationValidationDelegate.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java
Log:
https://issues.jboss.org/browse/JBIDE-7895
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/AnnotationValidationDelegate.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/AnnotationValidationDelegate.java 2010-12-15
19:26:48 UTC (rev 27522)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/AnnotationValidationDelegate.java 2010-12-15
20:02:53 UTC (rev 27523)
@@ -22,6 +22,7 @@
import org.jboss.tools.cdi.core.CDIUtil;
import org.jboss.tools.cdi.core.IAnnotationDeclaration;
import org.jboss.tools.cdi.core.ICDIAnnotation;
+import org.jboss.tools.cdi.core.IInterceptorBinding;
import org.jboss.tools.cdi.core.IInterceptorBindingDeclaration;
import org.jboss.tools.cdi.core.IQualifier;
import org.jboss.tools.cdi.core.IScope;
@@ -54,6 +55,7 @@
static final String[][] STEREOTYPE_F_VARIANTS = {{TARGET_FIELD}};
static final String[][] TYPE_VARIANTS = {{TARGET_TYPE}};
+ static final String[][] TYPE__METHOD_VARIANTS = {{TARGET_TYPE, TARGET_METHOD}};
public AnnotationValidationDelegate(CDICoreValidator validator) {
super(validator);
@@ -129,6 +131,29 @@
}
}
+ public void validateInterceptorBindingAnnotationTypeAnnotations(IInterceptorBinding
binding) throws JavaModelException {
+ /*
+ * 9.1.1. Interceptor binding types with additional interceptor bindings
+ * - Interceptor binding types declared @Target(TYPE) may not be applied to interceptor
binding types declared
+ * @Target({TYPE, METHOD}).
+ */
+ Set<IInterceptorBindingDeclaration> declarations =
binding.getInterceptorBindingDeclarations(false);
+ if(!declarations.isEmpty()) {
+ IAnnotationDeclaration target =
binding.getAnnotationDeclaration(CDIConstants.TARGET_ANNOTATION_TYPE_NAME);
+ if(target!=null) {
+ if(CDIUtil.checkTargetAnnotation(target, TYPE__METHOD_VARIANTS)) {
+ for (IInterceptorBindingDeclaration declaration : declarations) {
+ ICDIAnnotation superBinding = declaration.getAnnotation();
+ Boolean result = CDIUtil.checkTargetAnnotation(superBinding, TYPE_VARIANTS);
+ if(result!=null && result) {
+ validator.addError(CDIValidationMessages.ILLEGAL_TARGET_IN_INTERCEPTOR_BINDING_TYPE,
CDIPreferences.MISSING_OR_INCORRECT_TARGET_OR_RETENTION_IN_ANNOTATION_TYPE, new
String[]{superBinding.getSourceType().getElementName(),
binding.getSourceType().getElementName()}, declaration, binding.getResource());
+ }
+ }
+ }
+ }
+ }
+ }
+
/**
* Validates a scope type.
*
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-12-15
19:26:48 UTC (rev 27522)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java 2010-12-15
20:02:53 UTC (rev 27523)
@@ -2110,19 +2110,23 @@
}
private void validateInterceptorBinding(IInterceptorBinding binding) {
- if(binding==null) {
+ if(binding==null || (binding.getSourceType() == null &&
binding.getSourceType().isReadOnly())) {
return;
}
- IResource resource = binding.getResource();
- if (resource == null || !resource.getName().toLowerCase().endsWith(".java"))
{
- // validate sources only
- return;
- }
+
+ addLinkedInterceptorBindings(binding.getSourcePath().toOSString(), binding);
+
/*
* 9.5.2. Interceptor binding types with members
* array-valued or annotation-valued member of an interceptor binding type is not
annotated @Nonbinding (Non-Portable behavior)
*/
validateAnnotationMembers(binding,
CDIValidationMessages.MISSING_NONBINDING_FOR_ARRAY_VALUE_IN_INTERCEPTOR_BINDING_TYPE_MEMBER,
CDIValidationMessages.MISSING_NONBINDING_FOR_ANNOTATION_VALUE_IN_INTERCEPTOR_BINDING_TYPE_MEMBER,
CDIPreferences.MISSING_NONBINDING_IN_INTERCEPTOR_BINDING_TYPE_MEMBER);
+
+ try {
+ annotationValidator.validateInterceptorBindingAnnotationTypeAnnotations(binding);
+ } catch (JavaModelException e) {
+ CDICorePlugin.getDefault().logError(e);
+ }
}
/**