private void registerRedundantImport(@NotNull HighlightInfoHolder holder,
                                       @NotNull PsiImportStatementBase importStatement, @NotNull HighlightDisplayKey unusedImportKey) {
    VirtualFile virtualFile = PsiUtilCore.getVirtualFile(myFile);
    Set<String> imports = virtualFile != null ? virtualFile.getCopyableUserData(ImportsHighlightUtil.IMPORTS_FROM_TEMPLATE) : null;
    boolean predefinedImport = imports != null && imports.contains(importStatement.getText());
    String description = !predefinedImport ? JavaAnalysisBundle.message("unused.import.statement") :
                         JavaAnalysisBundle.message("text.unused.import.in.template");
    InspectionProfile profile = getCurrentProfile(myFile);
    TextAttributesKey key = ObjectUtils.notNull(profile.getEditorAttributes(unusedImportKey.toString(), myFile),
                                                JavaHighlightInfoTypes.UNUSED_IMPORT.getAttributesKey());
    HighlightInfoType.HighlightInfoTypeImpl configHighlightType =
      new HighlightInfoType.HighlightInfoTypeImpl(profile.getErrorLevel(unusedImportKey, myFile).getSeverity(), key);

    ProblemGroup problemGroup = new ExternalSourceProblemGroup() {
      @Override
      public String getExternalCheckName() {
        return UnusedImportInspection.SHORT_NAME;
      }

      @Override
      public @Nullable String getProblemName() {
        return null;
      }
    };

    HighlightInfo.Builder builder = HighlightInfo.newHighlightInfo(configHighlightType)
        .range(importStatement)
        .descriptionAndTooltip(description)
        .group(GeneralHighlightingPass.POST_UPDATE_ALL)
        .problemGroup(problemGroup);

    builder.registerFix(new RemoveAllUnusedImportsFix(), null, HighlightDisplayKey.getDisplayNameByKey(unusedImportKey), null, unusedImportKey);

    IntentionAction switchFix = QuickFixFactory.getInstance().createEnableOptimizeImportsOnTheFlyFix();
    builder.registerFix(switchFix, null, HighlightDisplayKey.getDisplayNameByKey(unusedImportKey), null, unusedImportKey);
    if (!predefinedImport && myOptimizeImportsFix == null) {
      myOptimizeImportsFix = QuickFixFactory.getInstance().createOptimizeImportsFix(true, myFile);
    }
    addInfo(holder, builder);
  }
private void registerRedundantImport(@NotNull HighlightInfoHolder holder,
                                       @NotNull PsiImportStatementBase importStatement, @NotNull HighlightDisplayKey unusedImportKey)