mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
allow for javadoc to autopopup together with completion (IDEA-76223)
This commit is contained in:
@@ -56,7 +56,7 @@
|
||||
<text resource-bundle="messages/ApplicationBundle" key="editbox.auto.complete"/>
|
||||
</properties>
|
||||
</component>
|
||||
<grid id="f8961" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="0">
|
||||
<grid id="f8961" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="0">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="8" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
@@ -64,16 +64,6 @@
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="b0975" class="com.intellij.ui.components.JBLabel" binding="myDocComment">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="9" fill="0" indent="2" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<componentStyle value="SMALL"/>
|
||||
<enabled value="true"/>
|
||||
<text value="Only for explicitly invoked completion"/>
|
||||
</properties>
|
||||
</component>
|
||||
<grid id="52549" layout-manager="GridBagLayout">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
|
||||
@@ -62,7 +62,6 @@ public class CodeCompletionPanel {
|
||||
private JBRadioButton myAllLetters;
|
||||
private JBLabel myBasicShortcut;
|
||||
private JBLabel mySmartShortcut;
|
||||
private JBLabel myDocComment;
|
||||
|
||||
public CodeCompletionPanel() {
|
||||
ChangeListener updateCaseCheckboxes = __ -> {
|
||||
@@ -78,7 +77,6 @@ public class CodeCompletionPanel {
|
||||
|
||||
myBasicShortcut.setForeground(JBColor.GRAY);
|
||||
mySmartShortcut.setForeground(JBColor.GRAY);
|
||||
myDocComment.setForeground(JBColor.GRAY);
|
||||
|
||||
myCbAutocompletion.addActionListener(
|
||||
new ActionListener() {
|
||||
|
||||
+25
-26
@@ -35,8 +35,6 @@ import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.IndexNotReadyException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.ui.LightweightHint;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.BitUtil;
|
||||
@@ -129,31 +127,9 @@ public class LookupManagerImpl extends LookupManager {
|
||||
@NotNull final LookupArranger arranger) {
|
||||
hideActiveLookup();
|
||||
|
||||
final CodeInsightSettings settings = CodeInsightSettings.getInstance();
|
||||
|
||||
final PsiFile psiFile = PsiDocumentManager.getInstance(myProject).getPsiFile(editor.getDocument());
|
||||
|
||||
final LookupImpl lookup = createLookup(editor, arranger, myProject);
|
||||
|
||||
final Alarm alarm = new Alarm();
|
||||
final Runnable request = () -> {
|
||||
if (myActiveLookup != lookup) return;
|
||||
|
||||
LookupElement currentItem = lookup.getCurrentItem();
|
||||
if (currentItem != null && currentItem.isValid() && isAutoPopupJavadocSupportedBy(currentItem)) {
|
||||
final CompletionProcess completion = CompletionService.getCompletionService().getCurrentCompletion();
|
||||
if (completion != null && !completion.isAutopopupCompletion()) {
|
||||
try {
|
||||
DocumentationManager.getInstance(myProject).showJavaDocInfo(editor, psiFile, false);
|
||||
}
|
||||
catch (IndexNotReadyException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
if (settings.AUTO_POPUP_JAVADOC_INFO) {
|
||||
alarm.addRequest(request, settings.JAVADOC_INFO_DELAY);
|
||||
}
|
||||
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
|
||||
@@ -173,8 +149,9 @@ public class LookupManagerImpl extends LookupManager {
|
||||
@Override
|
||||
public void currentItemChanged(LookupEvent event) {
|
||||
alarm.cancelAllRequests();
|
||||
CodeInsightSettings settings = CodeInsightSettings.getInstance();
|
||||
if (settings.AUTO_POPUP_JAVADOC_INFO && DocumentationManager.getInstance(myProject).getDocInfoHint() == null) {
|
||||
alarm.addRequest(request, settings.JAVADOC_INFO_DELAY);
|
||||
alarm.addRequest(() -> showJavadoc(lookup), settings.JAVADOC_INFO_DELAY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,7 +185,29 @@ public class LookupManagerImpl extends LookupManager {
|
||||
return lookup;
|
||||
}
|
||||
|
||||
protected boolean isAutoPopupJavadocSupportedBy(LookupElement lookupItem) {
|
||||
private void showJavadoc(LookupImpl lookup) {
|
||||
if (myActiveLookup != lookup) return;
|
||||
|
||||
DocumentationManager docManager = DocumentationManager.getInstance(myProject);
|
||||
if (docManager.getDocInfoHint() != null) return; // will auto-update
|
||||
|
||||
LookupElement currentItem = lookup.getCurrentItem();
|
||||
CompletionProcess completion = CompletionService.getCompletionService().getCurrentCompletion();
|
||||
if (currentItem != null && currentItem.isValid() && isAutoPopupJavadocSupportedBy(currentItem) && completion != null) {
|
||||
try {
|
||||
boolean hideLookupWithDoc = completion.isAutopopupCompletion() || CodeInsightSettings.getInstance().JAVADOC_INFO_DELAY == 0;
|
||||
docManager.showJavaDocInfo(lookup.getEditor(), lookup.getPsiFile(), false, () -> {
|
||||
if (hideLookupWithDoc && completion == CompletionService.getCompletionService().getCurrentCompletion()) {
|
||||
hideActiveLookup();
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (IndexNotReadyException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isAutoPopupJavadocSupportedBy(@SuppressWarnings("unused") LookupElement lookupItem) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -19,6 +19,7 @@ package com.intellij.codeInsight.lookup.impl.actions;
|
||||
import com.intellij.codeInsight.completion.CodeCompletionFeatures;
|
||||
import com.intellij.codeInsight.completion.CompletionProcess;
|
||||
import com.intellij.codeInsight.completion.CompletionService;
|
||||
import com.intellij.codeInsight.hint.HintManagerImpl;
|
||||
import com.intellij.codeInsight.lookup.Lookup;
|
||||
import com.intellij.codeInsight.lookup.LookupManager;
|
||||
import com.intellij.codeInsight.lookup.impl.LookupImpl;
|
||||
@@ -36,7 +37,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class ChooseItemAction extends EditorAction {
|
||||
public abstract class ChooseItemAction extends EditorAction implements HintManagerImpl.ActionToIgnore {
|
||||
public ChooseItemAction(Handler handler) {
|
||||
super(handler);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user