UsageViewPresentation (@NotNull UsageViewDescriptor descriptor, Usage @NotNull [] usages) { UsageViewPresentation presentation = new UsageViewPresentation(); presentation.setTabText(RefactoringBundle.message("usageView.tabText")); presentation.setTargetsNodeText(descriptor.getProcessedElementsHeader()); presentation.setShowReadOnlyStatusAsRed(true); presentation.setShowCancelButton(true); presentation.setUsagesString(RefactoringBundle.message("usageView.usagesText")); int codeUsageCount = 0; int nonCodeUsageCount = 0; int dynamicUsagesCount = 0; Set<PsiFile> codeFiles = new HashSet<>(); Set<PsiFile> nonCodeFiles = new HashSet<>(); Set<PsiFile> dynamicUsagesCodeFiles = new HashSet<>(); for (Usage usage : usages) { if (usage instanceof PsiElementUsage elementUsage) { final PsiElement element = elementUsage.getElement(); if (element == null) continue; final PsiFile containingFile = element.getContainingFile(); if (usage instanceof UsageInfo2UsageAdapter && ((UsageInfo2UsageAdapter)usage).getUsageInfo().isDynamicUsage()) { dynamicUsagesCount++; dynamicUsagesCodeFiles.add(containingFile); } else if (elementUsage.isNonCodeUsage()) { nonCodeUsageCount++; nonCodeFiles.add(containingFile); } else { codeUsageCount++; codeFiles.add(containingFile); } } } codeFiles.remove(null); nonCodeFiles.remove(null); dynamicUsagesCodeFiles.remove(null); presentation.setCodeUsagesString(UsageViewBundle.message( "usage.view.results.node.prefix", UsageViewBundle.message("usage.view.results.node.code"), descriptor.getCodeReferencesText(codeUsageCount, codeFiles.size()) )); presentation.setNonCodeUsagesString(UsageViewBundle.message( "usage.view.results.node.prefix", UsageViewBundle.message("usage.view.results.node.non.code"), descriptor.getCodeReferencesText(nonCodeUsageCount, nonCodeFiles.size()) )); presentation.setDynamicUsagesString(UsageViewBundle.message( "usage.view.results.node.prefix", UsageViewBundle.message("usage.view.results.node.dynamic"), descriptor.getCodeReferencesText(dynamicUsagesCount, dynamicUsagesCodeFiles.size()) )); return presentation; }