fix empty info popup shown for completion hints

This commit is contained in:
Dmitry Batrak
2017-09-18 12:19:05 +03:00
parent 1ae144a306
commit c9325f9573
3 changed files with 24 additions and 1 deletions
@@ -236,7 +236,10 @@ public class MethodParameterInfoHandler implements ParameterInfoHandlerWithTabAc
return;
}
int index = ParameterInfoUtils.getCurrentParameterIndex(o.getNode(), context.getOffset(), JavaTokenType.COMMA);
int offset = context.getOffset();
TextRange elRange = o.getTextRange();
int index = offset <= elRange.getStartOffset() || offset >= elRange.getEndOffset()
? -1 : ParameterInfoUtils.getCurrentParameterIndex(o.getNode(), offset, JavaTokenType.COMMA);
context.setCurrentParameter(index);
Object[] candidates = context.getObjectsToView();
@@ -610,6 +610,18 @@ public class CompletionHintsTest extends LightFixtureCompletionTestCase {
checkHintContents(null);
}
public void testPopupAfterCaretMovesOutsideOfParenthesis() throws Exception {
configureJava("class C { void m() { System.getPro<caret> } }");
complete("getProperty(String key, String def)");
waitForAllAsyncStuff();
checkHintContents("<html>@NotNull String</html>");
left();
left();
left();
waitForAllAsyncStuff();
checkHintContents(null);
}
private void checkResult(String text) {
myFixture.checkResult(text);
}
@@ -309,6 +309,14 @@ public class ParameterInfoController implements Disposable {
if (elementForUpdating != null) {
myHandler.updateParameterInfo(elementForUpdating, context);
if (mySingleParameterInfo) {
if (myComponent.getCurrentParameterIndex() == -1 && myHint.isVisible()) {
myHint.hide();
}
else if (myComponent.getCurrentParameterIndex() != -1 && !myHint.isVisible()) {
AutoPopupController.getInstance(myProject).autoPopupParameterInfo(myEditor, null);
}
}
if (!myDisposed && myHint.isVisible() && !myEditor.isDisposed() &&
(myEditor.getComponent().getRootPane() != null || ApplicationManager.getApplication().isUnitTestMode())) {
myComponent.update(mySingleParameterInfo);