Author: dazarov
Date: 2011-07-20 20:35:44 -0400 (Wed, 20 Jul 2011)
New Revision: 33092
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/CDIProblemMarkerResolutionGenerator.java
Log:
https://issues.jboss.org/browse/JBIDE-7641
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/CDIProblemMarkerResolutionGenerator.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/CDIProblemMarkerResolutionGenerator.java 2011-07-20
23:48:22 UTC (rev 33091)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/CDIProblemMarkerResolutionGenerator.java 2011-07-21
00:35:44 UTC (rev 33092)
@@ -19,6 +19,7 @@
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.Flags;
+import org.eclipse.jdt.core.IAnnotatable;
import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IField;
@@ -262,10 +263,13 @@
messageId ==
CDIValidationErrorManager.MISSING_NONBINDING_FOR_ARRAY_VALUE_IN_INTERCEPTOR_BINDING_TYPE_MEMBER_ID
||
messageId ==
CDIValidationErrorManager.MISSING_NONBINDING_FOR_ARRAY_VALUE_IN_QUALIFIER_TYPE_MEMBER_ID){
IJavaElement element = findJavaElement(file, start);
- if(element instanceof IMember){
- return new IMarkerResolution[] {
- new AddNonbindingAnnotationMarkerResolution((IMember)element)
- };
+ if(element != null){
+ IAnnotation annotation = getAnnotation(element,
CDIConstants.NON_BINDING_ANNOTATION_TYPE_NAME);
+ if(element instanceof IMember && annotation == null){
+ return new IMarkerResolution[] {
+ new AddNonbindingAnnotationMarkerResolution((IMember)element)
+ };
+ }
}
}
}
@@ -386,13 +390,9 @@
if(javaElement != null && javaElement instanceof IType){
IType type = (IType)javaElement;
if(!type.isBinary()){
- String shortName = MarkerResolutionUtils.getShortName(annotationQualifiedName);
- IAnnotation[] annotations = type.getAnnotations();
- for(IAnnotation annotation : annotations){
- if(annotation.getElementName().equals(annotationQualifiedName) ||
- annotation.getElementName().equals(shortName))
- return new TypeAndAnnotation(type, annotation);
-
+ IAnnotation annotation = getAnnotation(type, annotationQualifiedName);
+ if(annotation != null){
+ return new TypeAndAnnotation(type, annotation);
}
return new TypeAndAnnotation(type);
}
@@ -483,4 +483,23 @@
return false;
}
+ private IAnnotation getAnnotation(IJavaElement element, String
annotationQualifiedName){
+ if(element instanceof IAnnotatable){
+ String shortName = MarkerResolutionUtils.getShortName(annotationQualifiedName);
+ IAnnotation[] annotations;
+ try {
+ annotations = ((IAnnotatable)element).getAnnotations();
+ for(IAnnotation annotation : annotations){
+ if(annotation.getElementName().equals(annotationQualifiedName) ||
+ annotation.getElementName().equals(shortName))
+ return annotation;
+
+ }
+ } catch (JavaModelException e) {
+ CDIUIPlugin.getDefault().logError(e);
+ }
+ }
+ return null;
+ }
+
}