theTargetType.addAnnotation(new AnnotationX(new FakeAnnotation(name,sig,(abits & TagBits.AnnotationRuntimeRetention)!=0),factory.getWorld()));
CompilationAndWeavingContext.leavingPhase(tok);
return true;
}
Annotation currentAnnotations[] = sourceType.scope.referenceContext.annotations;
if (currentAnnotations!=null)
for (int i = 0; i < currentAnnotations.length; i++) {
Annotation annotation = currentAnnotations[i];
String a = CharOperation.toString(annotation.type.getTypeName());
String b = CharOperation.toString(toAdd[0].type.getTypeName());
// FIXME asc we have a lint for attempting to add an annotation twice to a method,
// we could put it out here *if* we can resolve the problem of errors coming out
// multiple times if we have cause to loop through here
if (a.equals(b)) {
CompilationAndWeavingContext.leavingPhase(tok);
return false;
}
}
if (((abits & TagBits.AnnotationTargetMASK)!=0)) {
if ( (abits & (TagBits.AnnotationForAnnotationType | TagBits.AnnotationForType))==0) {
// this means it specifies something other than annotation or normal type - error will have been already reported, just resolution process above
CompilationAndWeavingContext.leavingPhase(tok);
return false;
}
if ( (sourceType.isAnnotationType() && (abits & TagBits.AnnotationForAnnotationType)==0) ||
(!sourceType.isAnnotationType() && (abits & TagBits.AnnotationForType)==0) ) {
if (reportProblems) {
if (decA.isExactPattern()) {
factory.showMessage(IMessage.ERROR,
WeaverMessages.format(WeaverMessages.INCORRECT_TARGET_FOR_DECLARE_ANNOTATION,rtx.getName(),toAdd[0].type,stringifyTargets(abits)),
decA.getSourceLocation(), null);
}
// dont put out the lint - the weaving process will do that
// else {
// if (factory.getWorld().getLint().invalidTargetForAnnotation.isEnabled()) {
// factory.getWorld().getLint().invalidTargetForAnnotation.signal(new String[]{rtx.getName(),toAdd[0].type.toString(),stringifyTargets(abits)},decA.getSourceLocation(),null);
// }
// }
}
CompilationAndWeavingContext.leavingPhase(tok);
return false;
}
}
// Build a new array of annotations
// remember the current set (rememberAnnotations only does something the first time it is called for a type)
sourceType.scope.referenceContext.rememberAnnotations();
AsmRelationshipProvider.getDefault().addDeclareAnnotationRelationship(decA.getSourceLocation(),rtx.getSourceLocation());
Annotation abefore[] = sourceType.scope.referenceContext.annotations;
Annotation[] newset = new Annotation[toAdd.length+(abefore==null?0:abefore.length)];
System.arraycopy(toAdd,0,newset,0,toAdd.length);
if (abefore!=null) {
System.arraycopy(abefore,0,newset,toAdd.length,abefore.length);
}