mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
when lookup is shown, display documentation only for lookup items
it's strange when doc popup is aligned to selected lookup item but shows doc for something else even stranger if this happens automatically (IDEA-76223)
This commit is contained in:
+9
-6
@@ -4,6 +4,7 @@ package com.intellij.codeInsight.documentation;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightBundle;
|
||||
import com.intellij.codeInsight.TargetElementUtil;
|
||||
import com.intellij.codeInsight.completion.CompletionUtil;
|
||||
import com.intellij.codeInsight.documentation.actions.ShowQuickDocInfoAction;
|
||||
import com.intellij.codeInsight.hint.HintManagerImpl;
|
||||
import com.intellij.codeInsight.hint.ParameterInfoController;
|
||||
@@ -614,9 +615,13 @@ public class DocumentationManager extends DockablePopupManager<DocumentationComp
|
||||
*/
|
||||
@Nullable
|
||||
private PsiElement findTargetElementUnsafe(final Editor editor, int offset, @Nullable final PsiFile file, PsiElement contextElement) {
|
||||
if (LookupManager.getInstance(myProject).getActiveLookup() != null) {
|
||||
return assertSameProject(getElementFromLookup(editor, file));
|
||||
}
|
||||
|
||||
TargetElementUtil util = TargetElementUtil.getInstance();
|
||||
PsiElement element = assertSameProject(getElementFromLookup(editor, file));
|
||||
if (element == null && file != null) {
|
||||
PsiElement element = null;
|
||||
if (file != null) {
|
||||
final DocumentationProvider documentationProvider = getProviderFromElement(file);
|
||||
if (documentationProvider instanceof DocumentationProviderEx) {
|
||||
element = assertSameProject(((DocumentationProviderEx)documentationProvider).getCustomDocumentationElement(editor, file, contextElement));
|
||||
@@ -658,8 +663,6 @@ public class DocumentationManager extends DockablePopupManager<DocumentationComp
|
||||
if (activeLookup != null) {
|
||||
LookupElement item = activeLookup.getCurrentItem();
|
||||
if (item != null) {
|
||||
|
||||
|
||||
int offset = editor.getCaretModel().getOffset();
|
||||
if (offset > 0 && offset == editor.getDocument().getTextLength()) offset--;
|
||||
PsiReference ref = TargetElementUtil.findReference(editor, offset);
|
||||
@@ -670,9 +673,9 @@ public class DocumentationManager extends DockablePopupManager<DocumentationComp
|
||||
}
|
||||
|
||||
DocumentationProvider documentationProvider = getProviderFromElement(file);
|
||||
|
||||
PsiManager psiManager = PsiManager.getInstance(myProject);
|
||||
return documentationProvider.getDocumentationElementForLookupItem(psiManager, item.getObject(), targetElement);
|
||||
PsiElement fromProvider = documentationProvider.getDocumentationElementForLookupItem(psiManager, item.getObject(), targetElement);
|
||||
return fromProvider != null ? fromProvider : CompletionUtil.getTargetElement(item);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.intellij.ui.popup;
|
||||
|
||||
import com.intellij.codeInsight.completion.CompletionUtil;
|
||||
import com.intellij.codeInsight.documentation.DocumentationManager;
|
||||
import com.intellij.codeInsight.lookup.*;
|
||||
import com.intellij.ide.util.gotoByName.ChooseByNameBase;
|
||||
@@ -49,10 +48,8 @@ public abstract class PopupUpdateProcessor extends PopupUpdateProcessorBase {
|
||||
if (windowEvent.asPopup().isVisible()) { //was not canceled yet
|
||||
final LookupElement item = event.getItem();
|
||||
if (item != null) {
|
||||
PsiElement targetElement = CompletionUtil.getTargetElement(item);
|
||||
if (targetElement == null) {
|
||||
targetElement = DocumentationManager.getInstance(myProject).getElementFromLookup(activeLookup.getEditor(), activeLookup.getPsiFile());
|
||||
}
|
||||
PsiElement targetElement =
|
||||
DocumentationManager.getInstance(myProject).getElementFromLookup(activeLookup.getEditor(), activeLookup.getPsiFile());
|
||||
|
||||
updatePopup(targetElement); //open next
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user