private static void addSuppressAnnotation( final Project project, final GrModifierList modifierList, final String id) throws IncorrectOperationException { PsiAnnotation annotation = modifierList.findAnnotation(BatchSuppressManager.SUPPRESS_INSPECTIONS_ANNOTATION_NAME); final GrExpression toAdd = GroovyPsiElementFactory.getInstance(project).createExpressionFromText("\"" + id + "\""); if (annotation != null) { final PsiAnnotationMemberValue value = annotation.findDeclaredAttributeValue(null); if (value instanceof GrAnnotationArrayInitializer) { value.add(toAdd); } else if (value != null) { GrAnnotation anno = GroovyPsiElementFactory.getInstance(project).createAnnotationFromText("@A([])"); final GrAnnotationArrayInitializer list = (GrAnnotationArrayInitializer) anno.findDeclaredAttributeValue(null); list.add(value); list.add(toAdd); annotation.setDeclaredAttributeValue(null, list); } } else { modifierList .addAnnotation(BatchSuppressManager.SUPPRESS_INSPECTIONS_ANNOTATION_NAME) .setDeclaredAttributeValue(null, toAdd); } }
private static boolean shouldProcessInstanceMembers( @NotNull GrTypeDefinition grType, @Nullable PsiElement lastParent) { if (lastParent != null) { final GrModifierList modifierList = grType.getModifierList(); if (modifierList != null && modifierList.findAnnotation(GroovyCommonClassNames.GROOVY_LANG_CATEGORY) != null) { return false; } } return true; }
private static PsiClassType doGetSuperClassType(GroovyScriptClass scriptClass) { GrVariableDeclaration declaration = findDeclaration(scriptClass.getContainingFile()); if (declaration != null) { GrModifierList modifierList = declaration.getModifierList(); if (modifierList.findAnnotation(GroovyCommonClassNames.GROOVY_TRANSFORM_BASE_SCRIPT) != null) { GrTypeElement typeElement = declaration.getTypeElementGroovy(); if (typeElement != null) { PsiType type = typeElement.getType(); if (type instanceof PsiClassType) { return (PsiClassType) type; } } } } return null; }