void (@NotNull final List<CodeSmellInfo> smellList) { smellList.sort(Comparator.comparingInt(o -> o.getTextRange().getStartOffset())); ApplicationManager.getApplication().invokeLater(() -> { if (myProject.isDisposed()) return; if (smellList.isEmpty()) { return; } final VcsErrorViewPanel errorTreeView = new VcsErrorViewPanel(myProject); AbstractVcsHelperImpl helper = (AbstractVcsHelperImpl)AbstractVcsHelper.getInstance(myProject); helper.openMessagesView(errorTreeView, VcsBundle.message("code.smells.error.messages.tab.name")); FileDocumentManager fileManager = FileDocumentManager.getInstance(); for (CodeSmellInfo smellInfo : smellList) { final VirtualFile file = fileManager.getFile(smellInfo.getDocument()); if (file == null) continue; String presentableUrl = file.getPresentableUrl(); final OpenFileDescriptor navigatable = new OpenFileDescriptor(myProject, file, smellInfo.getStartLine(), smellInfo.getStartColumn()); final String exportPrefix = NewErrorTreeViewPanel.createExportPrefix(smellInfo.getStartLine() + 1); final String rendererPrefix = NewErrorTreeViewPanel.createRendererPrefix(smellInfo.getStartLine() + 1, smellInfo.getStartColumn() + 1); if (smellInfo.getSeverity() == HighlightSeverity.ERROR) { errorTreeView.addMessage(MessageCategory.ERROR, new String[]{smellInfo.getDescription()}, FileUtil.getLocationRelativeToUserHome(presentableUrl), navigatable, exportPrefix, rendererPrefix, null); } else {//if (smellInfo.getSeverity() == HighlightSeverity.WARNING) { errorTreeView.addMessage(MessageCategory.WARNING, new String[]{smellInfo.getDescription()}, FileUtil.getLocationRelativeToUserHome(presentableUrl), navigatable, exportPrefix, rendererPrefix, null); } } }); } @NotNull @Override public List<CodeSmellInfo> findCodeSmells(@NotNull final List<? extends VirtualFile> filesToCheck) throws ProcessCanceledException { MainPassesRunner runner = new MainPassesRunner(myProject, VcsBundle.message("checking.code.smells.progress.title"), getInspectionProfile()); Map<Document, List<HighlightInfo>> infos = runner.runMainPasses(filesToCheck, HighlightSeverity.WARNING); return convertErrorsAndWarnings(infos); } @Nullable private InspectionProfile getInspectionProfile() { InspectionProfile currentProfile; VcsConfiguration vcsConfiguration = VcsConfiguration.getInstance(myProject); String codeSmellProfile = vcsConfiguration.CODE_SMELLS_PROFILE; if (codeSmellProfile != null) { currentProfile = (vcsConfiguration.CODE_SMELLS_PROFILE_LOCAL ? InspectionProfileManager.getInstance() : InspectionProjectProfileManager.getInstance( myProject)).getProfile(codeSmellProfile); } else { currentProfile = null; } return currentProfile; } private @NotNull List<CodeSmellInfo> convertErrorsAndWarnings(@NotNull Map<Document, List<HighlightInfo>> highlights) { List<CodeSmellInfo> result = new ArrayList<>(); for (Map.Entry<Document, List<HighlightInfo>> e : highlights.entrySet()) { Document document = e.getKey(); List<HighlightInfo> infos = e.getValue(); for (HighlightInfo info : infos) { final HighlightSeverity severity = info.getSeverity(); if (SeverityRegistrar.getSeverityRegistrar(myProject).compare(severity, HighlightSeverity.WARNING) >= 0) { result.add(new CodeSmellInfo(document, getDescription(info), new TextRange(info.startOffset, info.endOffset), severity)); } } } return result; } private static String getDescription(@NotNull HighlightInfo highlightInfo) { final String description = highlightInfo.getDescription(); final HighlightInfoType type = highlightInfo.type; if (type instanceof HighlightInfoType.HighlightInfoTypeSeverityByKey) { final HighlightDisplayKey severityKey = ((HighlightInfoType.HighlightInfoTypeSeverityByKey)type).getSeverityKey(); final String id = severityKey.getID(); return "[" + id + "] " + description; } return description; } }