void (@NotNull ActionContext context, @NotNull PsiAnnotation annotation, @NotNull ModPsiUpdater updater) { final PsiNameValuePair[] addedParameters = annotation.getParameterList().getAttributes(); final Object2IntMap<String> annotationsOrderMap = getAnnotationsOrderMap(); final SortedSet<Pair<String, PsiAnnotationMemberValue>> newParameters = new TreeSet<>(Comparator.comparingInt(o -> annotationsOrderMap.getInt(o.getFirst()))); final boolean order = isAlreadyAddedOrdered(annotationsOrderMap, addedParameters); if (order) { if (addedParameters.length != 0) { final PsiAnnotationParameterList parameterList = annotation.getParameterList(); parameterList.deleteChildRange(addedParameters[0], addedParameters[addedParameters.length - 1]); for (final PsiNameValuePair addedParameter : addedParameters) { String name = addedParameter.getName(); final PsiAnnotationMemberValue value = addedParameter.getValue(); if (name == null) { name = "value"; } if (value == null) { LOG.error(String.format("Invalid annotation parameter name = %s, value = %s", name, null)); continue; } newParameters.add(Pair.create(name, value)); } } } PsiElementFactory factory = JavaPsiFacade.getElementFactory(context.project()); for (PsiMethod method : myAnnotationMethods) { if (myMissedElements.contains(method.getName())) { PsiType type = method.getReturnType(); String defaultValue; if (TypeUtils.isJavaLangString(type)) { defaultValue = "\"\""; } else if (type instanceof PsiArrayType) { defaultValue = "{}"; } else { defaultValue = TypeUtils.getDefaultValue(type); } newParameters.add(Pair.create(method.getName(), factory.createExpressionFromText(defaultValue, null))); } } ModTemplateBuilder builder = updater.templateBuilder(); for (final Pair<String, PsiAnnotationMemberValue> newParameter : newParameters) { final PsiAnnotationMemberValue value = annotation.setDeclaredAttributeValue(newParameter.getFirst(), newParameter.getSecond()); if (myMissedElements.contains(newParameter.getFirst())) { builder.field(value, new TextExpression(newParameter.getSecond().getText())); } } }