private static PsiAnnotation createNewAnnotation(
      final Project project,
      final Editor editor,
      final PsiElement container,
      @Nullable final PsiAnnotation annotation,
      final String id) {

    if (annotation != null) {
      final String currentSuppressedId = "\"" + id + "\"";
      if (!annotation.getText().contains("{")) {
        final PsiNameValuePair[] attributes = annotation.getParameterList().getAttributes();
        if (attributes.length == 1) {
          final String suppressedWarnings = attributes[0].getText();
          if (suppressedWarnings.contains(currentSuppressedId)) return null;
          return JavaPsiFacade.getInstance(project)
              .getElementFactory()
              .createAnnotationFromText(
                  "@"
                      + SuppressManager.SUPPRESS_INSPECTIONS_ANNOTATION_NAME
                      + "({"
                      + suppressedWarnings
                      + ", "
                      + currentSuppressedId
                      + "})",
                  container);
        }
      } else {
        final int curlyBraceIndex = annotation.getText().lastIndexOf("}");
        if (curlyBraceIndex > 0) {
          final String oldSuppressWarning = annotation.getText().substring(0, curlyBraceIndex);
          if (oldSuppressWarning.contains(currentSuppressedId)) return null;
          return JavaPsiFacade.getInstance(project)
              .getElementFactory()
              .createAnnotationFromText(
                  oldSuppressWarning + ", " + currentSuppressedId + "})", container);
        } else if (!ApplicationManager.getApplication().isUnitTestMode() && editor != null) {
          Messages.showErrorDialog(
              editor.getComponent(),
              InspectionsBundle.message(
                  "suppress.inspection.annotation.syntax.error", annotation.getText()));
        }
      }
    } else {
      return JavaPsiFacade.getInstance(project)
          .getElementFactory()
          .createAnnotationFromText(
              "@" + SuppressManager.SUPPRESS_INSPECTIONS_ANNOTATION_NAME + "(\"" + id + "\")",
              container);
    }
    return null;
  }
  public static void fillCompletionVariants(
      CompletionParameters parameters, CompletionResultSet result) {
    if (parameters.getCompletionType() != CompletionType.BASIC
        && parameters.getCompletionType() != CompletionType.SMART) {
      return;
    }

    PsiElement position = parameters.getPosition();
    if (psiElement(PsiIdentifier.class)
        .withParents(PsiJavaCodeReferenceElement.class, PsiTypeElement.class, PsiClass.class)
        .andNot(JavaCompletionData.AFTER_DOT)
        .andNot(psiElement().afterLeaf(psiElement().inside(PsiModifierList.class)))
        .accepts(position)) {
      suggestGeneratedMethods(result, position);
    } else if (psiElement(PsiIdentifier.class)
        .withParents(
            PsiJavaCodeReferenceElement.class,
            PsiAnnotation.class,
            PsiModifierList.class,
            PsiClass.class)
        .accepts(position)) {
      PsiAnnotation annotation =
          ObjectUtils.assertNotNull(PsiTreeUtil.getParentOfType(position, PsiAnnotation.class));
      int annoStart = annotation.getTextRange().getStartOffset();
      suggestGeneratedMethods(
          result.withPrefixMatcher(
              annotation.getText().substring(0, parameters.getOffset() - annoStart)),
          position);
    }
  }