void (@NotNull PsiNameValuePair annotationParameter, @NotNull String name) { final String text = buildReplacementText(annotationParameter, name); final PsiElementFactory factory = JavaPsiFacade.getElementFactory(annotationParameter.getProject()); final PsiAnnotation newAnnotation = factory.createAnnotationFromText("@A(" + text + " )", annotationParameter); annotationParameter.replace(newAnnotation.getParameterList().getAttributes()[0]); }