void (@NotNull final PsiLiteralExpression originalExpression, @NotNull ProblemsHolder holder, final boolean isOnTheFly) { PsiExpression[] foundExpr = getDuplicateLiterals(holder.getProject(), originalExpression, isOnTheFly); if (foundExpr.length == 0) return; Set<PsiClass> classes = new HashSet<>(); for (PsiElement aClass : foundExpr) { if (aClass == originalExpression) continue; ProgressManager.checkCanceled(); do { aClass = PsiTreeUtil.getParentOfType(aClass, PsiClass.class); } while (aClass != null && ((PsiClass)aClass).getQualifiedName() == null); if (aClass != null) { classes.add((PsiClass)aClass); } } if (classes.isEmpty()) return; List<PsiClass> tenClassesMost = ContainerUtil.getFirstItems(Arrays.asList(classes.toArray(PsiClass.EMPTY_ARRAY)), MAX_FILES_TO_ON_THE_FLY_SEARCH); String classList; if (isOnTheFly) { classList = StringUtil.join(tenClassesMost, aClass -> { final boolean thisFile = aClass.getContainingFile() == originalExpression.getContainingFile(); return "&nbsp;&nbsp;&nbsp;'<b>" + aClass.getQualifiedName() + "</b>'" + (thisFile ? " " + JavaI18nBundle.message("inspection.duplicates.message.in.this.file") : ""); }, ", " + BR); } else { classList = StringUtil.join(tenClassesMost, aClass -> "'" + aClass.getQualifiedName() + "'", ", "); } if (classes.size() > tenClassesMost.size()) { classList += BR + JavaI18nBundle.message("inspection.duplicates.message.more", classes.size() - 10); } String msg = JavaI18nBundle.message("inspection.duplicates.message", classList); Collection<LocalQuickFix> fixes = new SmartList<>(); if (isOnTheFly) { fixes.add(new IntroduceLiteralConstantFix()); fixes.add(new NavigateToOccurrencesFix(originalExpression)); } createReplaceFixes(foundExpr, originalExpression, fixes); LocalQuickFix[] array = fixes.toArray(LocalQuickFix.EMPTY_ARRAY); holder.registerProblem(originalExpression, msg, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, array); }