use of org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotationMemberValue 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;
}
use of org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotationMemberValue in project intellij-community by JetBrains.
the class GrAnnotationArrayInitializerImpl method addInternal.
@Override
public ASTNode addInternal(ASTNode first, ASTNode last, ASTNode anchor, Boolean before) {
final GrAnnotationMemberValue[] initializers = getInitializers();
if (initializers.length == 0) {
return super.addInternal(first, last, getNode().getFirstChildNode(), false);
}
final ASTNode lastChild = getNode().getLastChildNode();
getNode().addLeaf(GroovyTokenTypes.mCOMMA, ",", lastChild);
return super.addInternal(first, last, lastChild.getTreePrev(), false);
}
use of org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotationMemberValue in project intellij-community by JetBrains.
the class MixinMemberContributor method processDynamicElements.
@Override
public void processDynamicElements(@NotNull final PsiType qualifierType, @NotNull PsiScopeProcessor processor, @NotNull final PsiElement place, @NotNull ResolveState state) {
if (isInAnnotation(place))
return;
final PsiClass aClass = PsiUtil.resolveClassInClassTypeOnly(qualifierType);
if (aClass == null)
return;
final PsiModifierList modifierList = aClass.getModifierList();
if (modifierList == null)
return;
List<PsiClass> mixins = new ArrayList<>();
for (PsiAnnotation annotation : getAllMixins(modifierList)) {
final PsiAnnotationMemberValue value = annotation.findAttributeValue("value");
if (value instanceof GrAnnotationArrayInitializer) {
final GrAnnotationMemberValue[] initializers = ((GrAnnotationArrayInitializer) value).getInitializers();
for (GrAnnotationMemberValue initializer : initializers) {
addMixin(initializer, mixins);
}
} else if (value instanceof GrExpression) {
addMixin((GrExpression) value, mixins);
}
}
final MixinProcessor delegate = new MixinProcessor(processor, qualifierType, place);
for (PsiClass mixin : mixins) {
if (!mixin.processDeclarations(delegate, state, null, place)) {
return;
}
}
}
Aggregations