void (@NotNull Project project, @NotNull PsiFile hostFile, @NotNull PsiElement psiElement, int offset, @NotNull ShowIntentionsPass.IntentionsInfo outIntentions) { if (!psiElement.isPhysical() && !PlatformUtils.isFleetBackend()) { VirtualFile virtualFile = hostFile.getVirtualFile(); String text = hostFile.getText(); LOG.error("not physical: '" + psiElement.getText() + "' @" + offset + " " +psiElement.getTextRange() + " elem:" + psiElement + " (" + psiElement.getClass().getName() + ")" + " in:" + psiElement.getContainingFile() + " host:" + hostFile + "(" + hostFile.getClass().getName() + ")", new Attachment(virtualFile != null ? virtualFile.getPresentableUrl() : "null", text != null ? text : "null")); } if (DumbService.isDumb(project) || LightEdit.owns(project)) { return; } Set<String> projectTypes = ProjectTypeService.getProjectTypeIds(project); boolean isTests = ApplicationManager.getApplication().isUnitTestMode(); List<LocalInspectionToolWrapper> intentionTools = new ArrayList<>(); InspectionProfile profile = InspectionProjectProfileManager.getInstance(project).getInspectionProfile(); for (InspectionToolWrapper<?,?> toolWrapper : profile.getInspectionTools(hostFile)) { if (!isTests && !toolWrapper.isApplicable(projectTypes)) continue; if (toolWrapper instanceof GlobalInspectionToolWrapper global) { toolWrapper = global.getSharedLocalInspectionToolWrapper(); } if (toolWrapper instanceof LocalInspectionToolWrapper local && !local.isUnfair()) { HighlightDisplayKey key = HighlightDisplayKey.find(toolWrapper.getShortName()); if (profile.isToolEnabled(key, hostFile) && HighlightDisplayLevel.DO_NOT_SHOW.equals(profile.getErrorLevel(key, hostFile))) { intentionTools.add((LocalInspectionToolWrapper)toolWrapper); } } } if (intentionTools.isEmpty()) { return; } List<PsiElement> elements = PsiTreeUtil.collectParents(psiElement, PsiElement.class, true, e -> e instanceof PsiDirectory); PsiElement elementToTheLeft = psiElement.getContainingFile().findElementAt(offset - 1); @Unmodifiable List<PsiElement> toInspect; if (elementToTheLeft != psiElement && elementToTheLeft != null) { List<PsiElement> parentsOnTheLeft = PsiTreeUtil.collectParents(elementToTheLeft, PsiElement.class, true, e -> e instanceof PsiDirectory || elements.contains(e)); toInspect = ContainerUtil.concat(elements, parentsOnTheLeft); } else { toInspect = elements; } Map<@NonNls String, @Nls(capitalization = Nls.Capitalization.Sentence) String> displayNames = ContainerUtil.map2Map(intentionTools, wrapper -> Pair.create(wrapper.getShortName(), wrapper.getDisplayName())); // indicator can be null when run from EDT ProgressIndicator progress = ObjectUtils.notNull(ProgressIndicatorProvider.getGlobalProgressIndicator(), new DaemonProgressIndicator()); Map<LocalInspectionToolWrapper, List<ProblemDescriptor>> map = InspectionEngine.inspectElements(intentionTools, hostFile, hostFile.getTextRange(), true, true, progress, toInspect, PairProcessor.alwaysTrue()); for (Map.Entry<LocalInspectionToolWrapper, List<ProblemDescriptor>> entry : map.entrySet()) { List<ProblemDescriptor> descriptors = entry.getValue(); String shortName = entry.getKey().getShortName(); for (ProblemDescriptor problemDescriptor : descriptors) { if (problemDescriptor instanceof ProblemDescriptorBase base) { TextRange range = base.getTextRange(); if (range != null && range.containsOffset(offset)) { QuickFix[] fixes = problemDescriptor.getFixes(); for (int k = 0; k < fixes.length; k++) { IntentionAction intentionAction = QuickFixWrapper.wrap(problemDescriptor, k); HighlightDisplayKey key = HighlightDisplayKey.find(shortName); String displayName = displayNames.get(shortName); HighlightInfo.IntentionActionDescriptor actionDescriptor = new HighlightInfo.IntentionActionDescriptor(intentionAction, null, displayName, null, key, null, HighlightSeverity.INFORMATION); (problemDescriptor.getHighlightType() == ProblemHighlightType.ERROR ? outIntentions.errorFixesToShow : outIntentions.intentionsToShow).add(actionDescriptor); } } } } } }