Author: dazarov
Date: 2011-07-19 16:45:55 -0400 (Tue, 19 Jul 2011)
New Revision: 33050
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddRetentionAnnotationMarkerResolution.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/ChangeRetentionAnnotationMarkerResolution.java
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIConstants.java
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/CDIValidationErrorManager.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.properties
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/MarkerResolutionUtils.java
Log:
https://issues.jboss.org/browse/JBIDE-7631
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIConstants.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIConstants.java 2011-07-19
18:55:40 UTC (rev 33049)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIConstants.java 2011-07-19
20:45:55 UTC (rev 33050)
@@ -15,6 +15,8 @@
public String TARGET_ANNOTATION_TYPE_NAME = "java.lang.annotation.Target";
public String RETENTION_ANNOTATION_TYPE_NAME =
"java.lang.annotation.Retention";
+ public String RETENTION_POLICY_RUNTIME_TYPE_NAME =
"java.lang.annotation.RetentionPolicy.RUNTIME";
+
public String QUALIFIER_ANNOTATION_TYPE_NAME = "javax.inject.Qualifier";
public String NAMED_QUALIFIER_TYPE_NAME = "javax.inject.Named";
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 2011-07-19
18:55:40 UTC (rev 33049)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/AnnotationValidationDelegate.java 2011-07-19
20:45:55 UTC (rev 33050)
@@ -70,7 +70,7 @@
/*
* Stereotype annotation type should be annotated with @Retention(RUNTIME)
*/
- validateRetentionAnnotation(stereotype,
CDIValidationMessages.MISSING_RETENTION_ANNOTATION_IN_STEREOTYPE_TYPE, resource);
+ validateRetentionAnnotation(stereotype,
CDIValidationMessages.MISSING_RETENTION_ANNOTATION_IN_STEREOTYPE_TYPE, resource,
CDIValidationErrorManager.MISSING_RETENTION_ANNOTATION_IN_STEREOTYPE_TYPE_ID);
IAnnotationDeclaration target =
stereotype.getAnnotationDeclaration(CDIConstants.TARGET_ANNOTATION_TYPE_NAME);
if(target!=null) {
@@ -182,13 +182,13 @@
/*
* Scope annotation type should be annotated with @Retention(RUNTIME)
*/
- validateRetentionAnnotation(scope,
CDIValidationMessages.MISSING_RETENTION_ANNOTATION_IN_SCOPE_TYPE, resource);
+ validateRetentionAnnotation(scope,
CDIValidationMessages.MISSING_RETENTION_ANNOTATION_IN_SCOPE_TYPE, resource,
CDIValidationErrorManager.MISSING_RETENTION_ANNOTATION_IN_SCOPE_TYPE_ID);
}
- void validateRetentionAnnotation(ICDIAnnotation type, String message, IResource
resource) throws JavaModelException {
+ void validateRetentionAnnotation(ICDIAnnotation type, String message, IResource
resource, int message_id) throws JavaModelException {
IAnnotationDeclaration retention =
type.getAnnotationDeclaration(CDIConstants.RETENTION_ANNOTATION_TYPE_NAME);
if(retention == null) {
- validator.addError(message,
CDIPreferences.MISSING_OR_INCORRECT_TARGET_OR_RETENTION_IN_ANNOTATION_TYPE,
CDIUtil.convertToSourceReference(type.getSourceType().getNameRange(), resource),
resource);
+ validator.addError(message,
CDIPreferences.MISSING_OR_INCORRECT_TARGET_OR_RETENTION_IN_ANNOTATION_TYPE,
CDIUtil.convertToSourceReference(type.getSourceType().getNameRange(), resource), resource,
message_id);
} else {
boolean ok = false;
Object o = retention.getMemberValue(null);
@@ -200,7 +200,7 @@
if(!"RUNTIME".equals(s)) ok = false;
}
if(!ok) {
- validator.addError(message,
CDIPreferences.MISSING_OR_INCORRECT_TARGET_OR_RETENTION_IN_ANNOTATION_TYPE, retention,
resource);
+ validator.addError(message,
CDIPreferences.MISSING_OR_INCORRECT_TARGET_OR_RETENTION_IN_ANNOTATION_TYPE, retention,
resource, message_id);
}
}
}
@@ -215,7 +215,7 @@
/*
* Qualifier annotation type should be annotated with @Retention(RUNTIME)
*/
- validateRetentionAnnotation(qualifier,
CDIValidationMessages.MISSING_RETENTION_ANNOTATION_IN_QUALIFIER_TYPE, resource);
+ validateRetentionAnnotation(qualifier,
CDIValidationMessages.MISSING_RETENTION_ANNOTATION_IN_QUALIFIER_TYPE, resource,
CDIValidationErrorManager.MISSING_RETENTION_ANNOTATION_IN_QUALIFIER_TYPE_ID);
}
private void validateTargetAnnotation(ICDIAnnotation annotationType, String[][]
variants, String message, IResource resource) throws JavaModelException {
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDIValidationErrorManager.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDIValidationErrorManager.java 2011-07-19
18:55:40 UTC (rev 33049)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDIValidationErrorManager.java 2011-07-19
20:45:55 UTC (rev 33050)
@@ -29,6 +29,9 @@
public static final int AMBIGUOUS_INJECTION_POINTS_ID = 8;
public static final int NOT_PASSIVATION_CAPABLE_BEAN_ID = 9;
public static final int ILLEGAL_SCOPE_FOR_MANAGED_BEAN_WITH_PUBLIC_FIELD_ID = 10;
+ public static final int MISSING_RETENTION_ANNOTATION_IN_QUALIFIER_TYPE_ID = 11;
+ public static final int MISSING_RETENTION_ANNOTATION_IN_STEREOTYPE_TYPE_ID = 12;
+ public static final int MISSING_RETENTION_ANNOTATION_IN_SCOPE_TYPE_ID = 13;
/*
* (non-Javadoc)
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.java 2011-07-19
18:55:40 UTC (rev 33049)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.java 2011-07-19
20:45:55 UTC (rev 33050)
@@ -103,6 +103,8 @@
public static String ADD_SERIALIZABLE_INTERFACE_MARKER_RESOLUTION_TITLE;
public static String MAKE_BEAN_SCOPED_DEPENDENT_MARKER_RESOLUTION_TITLE;
public static String MAKE_FIELD_PROTECTED_MARKER_RESOLUTION_TITLE;
+ public static String ADD_RETENTION_MARKER_RESOLUTION_TITLE;
+ public static String CHANGE_RETENTION_MARKER_RESOLUTION_TITLE;
public static String QUESTION;
public static String DECREASING_FIELD_VISIBILITY_MAY_CAUSE_COMPILATION_PROBLEMS;
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.properties
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.properties 2011-07-19
18:55:40 UTC (rev 33049)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.properties 2011-07-19
20:45:55 UTC (rev 33050)
@@ -87,6 +87,8 @@
ADD_SERIALIZABLE_INTERFACE_MARKER_RESOLUTION_TITLE=Add java.io.Serializable interface to
''{0}'' class
MAKE_BEAN_SCOPED_DEPENDENT_MARKER_RESOLUTION_TITLE=Make ''{0}'' bean
scoped @Dependent
MAKE_FIELD_PROTECTED_MARKER_RESOLUTION_TITLE=Make ''{0}'' field
protected
+ADD_RETENTION_MARKER_RESOLUTION_TITLE=Add @Retention(RUNTIME) annotation to
''{0}'' class
+CHANGE_RETENTION_MARKER_RESOLUTION_TITLE=Change ''{0}'' annotation to
@Retention(RUNTIME)
QUESTION=Question
DECREASING_FIELD_VISIBILITY_MAY_CAUSE_COMPILATION_PROBLEMS=Decreasing field visibility
may cause compilation problems. Do you want to continue?
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddRetentionAnnotationMarkerResolution.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddRetentionAnnotationMarkerResolution.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddRetentionAnnotationMarkerResolution.java 2011-07-19
20:45:55 UTC (rev 33050)
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.cdi.ui.marker;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.IMarkerResolution2;
+import org.jboss.tools.cdi.core.CDIConstants;
+import org.jboss.tools.cdi.ui.CDIUIMessages;
+import org.jboss.tools.cdi.ui.CDIUIPlugin;
+
+public class AddRetentionAnnotationMarkerResolution implements
+ IMarkerResolution2 {
+ private IType type;
+ private String label;
+
+ public AddRetentionAnnotationMarkerResolution(IType type){
+ this.type = type;
+ label = NLS.bind(CDIUIMessages.ADD_RETENTION_MARKER_RESOLUTION_TITLE,
type.getElementName());
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void run(IMarker marker) {
+ try{
+ ICompilationUnit original = type.getCompilationUnit();
+ ICompilationUnit compilationUnit = original.getWorkingCopy(new
NullProgressMonitor());
+
+ MarkerResolutionUtils.addImport(CDIConstants.RETENTION_POLICY_RUNTIME_TYPE_NAME,
compilationUnit, true);
+
+ IType workingCopyType = MarkerResolutionUtils.findWorkingCopyType(compilationUnit,
type);
+
+ MarkerResolutionUtils.addAnnotation(CDIConstants.RETENTION_ANNOTATION_TYPE_NAME,
compilationUnit, workingCopyType, "(RUNTIME)");
+
+ compilationUnit.commitWorkingCopy(false, new NullProgressMonitor());
+ compilationUnit.discardWorkingCopy();
+ }catch(CoreException ex){
+ CDIUIPlugin.getDefault().logError(ex);
+ }
+ }
+
+ public String getDescription() {
+ return label;
+ }
+
+ public Image getImage() {
+ return null;
+ }
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddRetentionAnnotationMarkerResolution.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
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-19
18:55:40 UTC (rev 33049)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/CDIProblemMarkerResolutionGenerator.java 2011-07-19
20:45:55 UTC (rev 33050)
@@ -187,6 +187,23 @@
}
}
}
+ }else if(messageId ==
CDIValidationErrorManager.MISSING_RETENTION_ANNOTATION_IN_QUALIFIER_TYPE_ID ||
+ messageId == CDIValidationErrorManager.MISSING_RETENTION_ANNOTATION_IN_SCOPE_TYPE_ID
||
+ messageId ==
CDIValidationErrorManager.MISSING_RETENTION_ANNOTATION_IN_STEREOTYPE_TYPE_ID){
+
+ TypeAndAnnotation ta = findTypeOrRetentionAnnotation(file, start);
+ if(ta != null){
+ if(ta.annotation == null){
+ return new IMarkerResolution[] {
+ new AddRetentionAnnotationMarkerResolution(ta.type)
+ };
+ }else{
+ return new IMarkerResolution[] {
+ new ChangeRetentionAnnotationMarkerResolution(ta.type, ta.annotation)
+ };
+
+ }
+ }
}
}
return new IMarkerResolution[] {};
@@ -287,6 +304,39 @@
return null;
}
+ class TypeAndAnnotation{
+ IType type;
+ IAnnotation annotation;
+
+ public TypeAndAnnotation(IType type){
+ this.type = type;
+ }
+
+ public TypeAndAnnotation(IType type, IAnnotation annotation){
+ this(type);
+ this.annotation = annotation;
+ }
+ }
+
+ private TypeAndAnnotation findTypeOrRetentionAnnotation(IFile file, int start) throws
JavaModelException{
+ IJavaElement javaElement = findJavaElement(file, start);
+ if(javaElement != null && javaElement instanceof IType){
+ IType type = (IType)javaElement;
+ if(!type.isBinary()){
+ String shortName =
MarkerResolutionUtils.getShortName(CDIConstants.RETENTION_ANNOTATION_TYPE_NAME);
+ IAnnotation[] annotations = type.getAnnotations();
+ for(IAnnotation annotation : annotations){
+ if(annotation.getElementName().equals(CDIConstants.RETENTION_ANNOTATION_TYPE_NAME)
||
+ annotation.getElementName().equals(shortName))
+ return new TypeAndAnnotation(type, annotation);
+
+ }
+ return new TypeAndAnnotation(type);
+ }
+ }
+ return null;
+ }
+
private IJavaElement findJavaElement(IFile file, int start){
try{
ICompilationUnit compilationUnit = EclipseUtil.getCompilationUnit(file);
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/ChangeRetentionAnnotationMarkerResolution.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/ChangeRetentionAnnotationMarkerResolution.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/ChangeRetentionAnnotationMarkerResolution.java 2011-07-19
20:45:55 UTC (rev 33050)
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.cdi.ui.marker;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jdt.core.IBuffer;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.IMarkerResolution2;
+import org.jboss.tools.cdi.core.CDIConstants;
+import org.jboss.tools.cdi.ui.CDIUIMessages;
+import org.jboss.tools.cdi.ui.CDIUIPlugin;
+
+public class ChangeRetentionAnnotationMarkerResolution implements
+ IMarkerResolution2 {
+ private String label=null;
+ private IType type;
+ private IAnnotation annotation;
+
+ public ChangeRetentionAnnotationMarkerResolution(IType type, IAnnotation annotation){
+ this.type = type;
+ this.annotation = annotation;
+ try {
+ label = NLS.bind(CDIUIMessages.CHANGE_RETENTION_MARKER_RESOLUTION_TITLE,
annotation.getSource());
+ } catch (JavaModelException e) {
+ CDIUIPlugin.getDefault().logError(e);
+ }
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void run(IMarker marker) {
+ try{
+ ICompilationUnit original = type.getCompilationUnit();
+ ICompilationUnit compilationUnit = original.getWorkingCopy(new
NullProgressMonitor());
+
+ MarkerResolutionUtils.addImport(CDIConstants.RETENTION_POLICY_RUNTIME_TYPE_NAME,
compilationUnit, true);
+
+ IAnnotation workingCopyAnnotation =
MarkerResolutionUtils.findWorkingCopyAnnotation(compilationUnit, type, annotation);
+
+ IBuffer buffer = compilationUnit.getBuffer();
+ String shortName =
MarkerResolutionUtils.getShortName(CDIConstants.RETENTION_ANNOTATION_TYPE_NAME);
+
+
+ buffer.replace(workingCopyAnnotation.getSourceRange().getOffset(),
workingCopyAnnotation.getSourceRange().getLength(),
MarkerResolutionUtils.AT+shortName+"(RUNTIME)");
+
+ compilationUnit.commitWorkingCopy(false, new NullProgressMonitor());
+ compilationUnit.discardWorkingCopy();
+ }catch(CoreException ex){
+ CDIUIPlugin.getDefault().logError(ex);
+ }
+ }
+
+ public String getDescription() {
+ return label;
+ }
+
+ public Image getImage() {
+ return null;
+ }
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/ChangeRetentionAnnotationMarkerResolution.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MarkerResolutionUtils.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MarkerResolutionUtils.java 2011-07-19
18:55:40 UTC (rev 33049)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MarkerResolutionUtils.java 2011-07-19
20:45:55 UTC (rev 33050)
@@ -19,6 +19,7 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.Flags;
import org.eclipse.jdt.core.IAnnotatable;
import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jdt.core.IBuffer;
@@ -91,6 +92,18 @@
* @throws JavaModelException
*/
public static boolean addImport(String qualifiedName, ICompilationUnit compilationUnit)
throws JavaModelException{
+ return addImport(qualifiedName, compilationUnit, false);
+ }
+
+ /**
+ *
+ * @param qualifiedName
+ * @param compilationUnit
+ * @param staticFlag
+ * @return true if there is import in compilation unit with the same short name
+ * @throws JavaModelException
+ */
+ public static boolean addImport(String qualifiedName, ICompilationUnit compilationUnit,
boolean staticFlag) throws JavaModelException{
if(primitives.contains(qualifiedName))
return false;
@@ -136,12 +149,19 @@
return true;
}
- compilationUnit.createImport(qualifiedName, null, new NullProgressMonitor());
+ if(staticFlag)
+ compilationUnit.createImport(qualifiedName, null, Flags.AccStatic, new
NullProgressMonitor());
+ else
+ compilationUnit.createImport(qualifiedName, null, new NullProgressMonitor());
}
return false;
}
public static void addAnnotation(String qualifiedName, ICompilationUnit compilationUnit,
IType element) throws JavaModelException{
+ addAnnotation(qualifiedName, compilationUnit, element, "");
+ }
+
+ public static void addAnnotation(String qualifiedName, ICompilationUnit compilationUnit,
IType element, String params) throws JavaModelException{
IAnnotation annotation = getAnnotation(element, qualifiedName);
if(annotation != null && annotation.exists())
return;
@@ -156,7 +176,7 @@
if(duplicateShortName)
shortName = qualifiedName;
- buffer.replace(element.getSourceRange().getOffset(), 0, AT+shortName+lineDelim);
+ buffer.replace(element.getSourceRange().getOffset(), 0,
AT+shortName+params+lineDelim);
synchronized(compilationUnit) {
compilationUnit.reconcile(ICompilationUnit.NO_AST, true, null, null);
@@ -449,4 +469,21 @@
}
return null;
}
+
+ public static IType findWorkingCopyType(ICompilationUnit compilationUnit, IType type)
throws JavaModelException{
+ for(IType t : compilationUnit.getAllTypes()){
+ if(t.getFullyQualifiedName().equals(type.getFullyQualifiedName()))
+ return t;
+ }
+ return null;
+ }
+
+ public static IAnnotation findWorkingCopyAnnotation(ICompilationUnit compilationUnit,
IType type, IAnnotation annotation) throws JavaModelException{
+ IType workingCopyType = findWorkingCopyType(compilationUnit, type);
+ for(IAnnotation a : workingCopyType.getAnnotations()){
+ if(a.getElementName().equals(annotation.getElementName()))
+ return a;
+ }
+ return null;
+ }
}