use of com.intellij.psi.PsiAnnotationOwner in project intellij-community by JetBrains.
the class FieldAnnotationChecker method checkScriptField.
private static void checkScriptField(AnnotationHolder holder, GrAnnotation annotation) {
final PsiAnnotationOwner owner = annotation.getOwner();
final GrMember container = PsiTreeUtil.getParentOfType(((PsiElement) owner), GrMember.class);
if (container != null) {
if (container.getContainingClass() instanceof GroovyScriptClass) {
holder.createErrorAnnotation(annotation, GroovyBundle.message("annotation.field.can.only.be.used.within.a.script.body"));
} else {
holder.createErrorAnnotation(annotation, GroovyBundle.message("annotation.field.can.only.be.used.within.a.script"));
}
}
}
use of com.intellij.psi.PsiAnnotationOwner in project intellij-community by JetBrains.
the class GriffonPropertyListenerAnnotationChecker method checkArgumentList.
@Override
public boolean checkArgumentList(@NotNull AnnotationHolder holder, @NotNull GrAnnotation annotation) {
if (!"griffon.transform.PropertyListener".equals(annotation.getQualifiedName()))
return false;
final GrAnnotationNameValuePair[] attributes = annotation.getParameterList().getAttributes();
if (attributes.length != 1)
return false;
final GrAnnotationNameValuePair attribute = attributes[0];
final GrAnnotationMemberValue value = attribute.getValue();
final PsiAnnotationOwner owner = annotation.getOwner();
if (owner instanceof GrField) {
if (value instanceof GrClosableBlock) {
return true;
}
} else if (owner instanceof GrTypeDefinition) {
if (value instanceof GrReferenceExpression) {
final PsiElement resolved = ((GrReferenceExpression) value).resolve();
if (resolved instanceof GrField) {
final PsiClass containingClass = ((GrField) resolved).getContainingClass();
if (annotation.getManager().areElementsEquivalent((PsiElement) owner, containingClass)) {
return true;
}
}
}
}
return false;
}
Aggregations