void (@NotNull Project project, @NotNull PsiFile file, @NotNull PsiElement startElement, @NotNull PsiElement endElement) { PsiExpression[] literalExpressions = getDuplicateLiteralsUnderProgress(startElement); if (literalExpressions == null) return; Usage[] usages = Stream.of(literalExpressions) .map(UsageInfo::new) .map(UsageInfo2UsageAdapter::new) .toArray(Usage[]::new); UsageViewPresentation presentation = new UsageViewPresentation(); String title = JavaI18nBundle.message("inspection.duplicates.occurrences.view.title", ((PsiLiteralExpression)startElement).getValue()); presentation.setUsagesString(title); presentation.setTabName(title); presentation.setTabText(title); presentation.setShowCancelButton(true); UsageView view = UsageViewManager.getInstance(project).showUsages(new UsageTarget[]{new PsiElement2UsageTargetAdapter(startElement) { @Override public String getPresentableText() { return "String literal: '" + ((PsiLiteralExpression)startElement).getValue() + "'"; } }}, usages, presentation); view.addButtonToLowerPane(() -> { introduceConstant(literalExpressions, project); view.close(); }, JavaI18nBundle.message("introduce.constant.across.the.project")); }