boolean (@NotNull List<? extends HighlightInfo.IntentionActionDescriptor> newDescriptors, @NotNull Set<? super IntentionActionWithTextCaching> cachedActions, boolean shouldCallIsAvailable) { if (cachedActions.isEmpty() && newDescriptors.isEmpty()) return false; boolean changed = false; if (myEditor == null) { LOG.assertTrue(!shouldCallIsAvailable); for (HighlightInfo.IntentionActionDescriptor descriptor : newDescriptors) { changed |= cachedActions.add(wrapAction(descriptor, myFile, myFile, null)); } return changed; } int caretOffset = myOffset >= 0 ? myOffset : myEditor.getCaretModel().getOffset(); int fileOffset = caretOffset > 0 && caretOffset == myFile.getTextLength() ? caretOffset - 1 : caretOffset; PsiElement element; PsiElement hostElement; if (myFile instanceof PsiCompiledElement || myFile.getTextLength() == 0) { hostElement = element = myFile; } else if (PsiDocumentManager.getInstance(myProject).isUncommited(myEditor.getDocument())) { //??? FileViewProvider viewProvider = myFile.getViewProvider(); hostElement = element = viewProvider.findElementAt(fileOffset, viewProvider.getBaseLanguage()); } else { hostElement = myFile.getViewProvider().findElementAt(fileOffset, myFile.getLanguage()); element = InjectedLanguageUtilBase.findElementAtNoCommit(myFile, fileOffset); } PsiFile injectedFile; Editor injectedEditor; int injectedOffset; if (element == null || element == hostElement) { injectedFile = myFile; injectedEditor = myEditor; injectedOffset = caretOffset; } else { injectedFile = element.getContainingFile(); injectedEditor = InjectedLanguageUtil.getInjectedEditorForInjectedFile(myEditor, injectedFile); if (injectedEditor instanceof EditorWindow editorWindow) { injectedOffset = editorWindow.logicalPositionToOffset(editorWindow.hostToInjected(myEditor.offsetToLogicalPosition(fileOffset))); } else { injectedOffset = fileOffset; } } Set<IntentionActionWithTextCaching> wrappedNew = new LinkedHashSet<>(newDescriptors.size()); for (HighlightInfo.IntentionActionDescriptor descriptor : newDescriptors) { IntentionAction action = descriptor.getAction(); if (element != null && element != hostElement && (!shouldCallIsAvailable || ShowIntentionActionsHandler.availableFor(injectedFile, injectedEditor, injectedOffset, action))) { IntentionActionWithTextCaching cachedAction = wrapAction(descriptor, element, injectedFile, injectedEditor); wrappedNew.add(cachedAction); } else if (hostElement != null && (!shouldCallIsAvailable || ShowIntentionActionsHandler.availableFor(myFile, myEditor, fileOffset, action))) { IntentionActionWithTextCaching cachedAction = wrapAction(descriptor, hostElement, myFile, myEditor); wrappedNew.add(cachedAction); } } if (cachedActions.equals(wrappedNew)) { return false; } cachedActions.addAll(wrappedNew); return true; }