use of com.redhat.ceylon.compiler.typechecker.tree.Tree.Annotation in project ceylon-compiler by ceylon.
the class ForcedCaptureVisitor method isForcedCapture.
private boolean isForcedCapture(Tree.TypedDeclaration that) {
if (that.getAnnotationList() == null)
return false;
for (Annotation anno : that.getAnnotationList().getAnnotations()) {
Type type = anno.getTypeModel();
if (type == null || !type.isClassOrInterface())
continue;
TypeDeclaration decl = type.getDeclaration();
if (decl == null)
continue;
Module module = Decl.getModule(decl);
if (module == null)
continue;
if (module.getLanguageModule() == module)
continue;
// does not come from the language module
return true;
}
return false;
}
use of com.redhat.ceylon.compiler.typechecker.tree.Tree.Annotation in project ceylon-compiler by ceylon.
the class UnsupportedVisitor method interopAnnotationTargeting.
private void interopAnnotationTargeting(EnumSet<OutputElement> outputs, Tree.AnnotationList annotationList) {
List<Annotation> annotations = annotationList.getAnnotations();
for (Tree.Annotation annotation : annotations) {
AnnotationUtil.interopAnnotationTargeting(outputs, annotation, true);
}
AnnotationUtil.duplicateInteropAnnotation(outputs, annotations);
}
use of com.redhat.ceylon.compiler.typechecker.tree.Tree.Annotation in project ceylon-compiler by ceylon.
the class AnnotationUtil method duplicateInteropAnnotation.
public static void duplicateInteropAnnotation(EnumSet<OutputElement> outputs, List<Annotation> annotations) {
for (int i = 0; i < annotations.size(); i++) {
Tree.Annotation ann = annotations.get(i);
Type t = ann.getTypeModel();
EnumSet<OutputElement> mainTargets = interopAnnotationTargeting(outputs, ann, false);
if (t != null && mainTargets != null) {
TypeDeclaration td = t.getDeclaration();
if (!ModelUtil.isCeylonDeclaration(td)) {
for (int j = 0; j < i; j++) {
Tree.Annotation other = annotations.get(j);
Type ot = other.getTypeModel();
if (ot != null) {
TypeDeclaration otd = ot.getDeclaration();
if (otd.equals(td)) {
// check if they have the same targets (if not that's fine)
EnumSet<OutputElement> dupeTargets = interopAnnotationTargeting(outputs, other, false);
if (dupeTargets != null) {
EnumSet<OutputElement> sameTargets = intersection(mainTargets, dupeTargets);
if (!sameTargets.isEmpty()) {
ann.addError("duplicate annotation: there are multiple annotations of type '" + td.getName() + "' for targets: '" + sameTargets + "'");
break;
}
}
}
}
}
}
}
}
}
Aggregations