mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-195668 Do not show completion hints in improper context
This commit is contained in:
@@ -310,11 +310,18 @@ public class JavaMethodCallElement extends LookupItem<PsiMethod> implements Type
|
||||
|
||||
CaretModel caretModel = editor.getCaretModel();
|
||||
int offset = caretModel.getOffset();
|
||||
|
||||
int afterParenOffset = offset + 1;
|
||||
if (afterParenOffset < document.getTextLength() &&
|
||||
Character.isJavaIdentifierPart(document.getImmutableCharSequence().charAt(afterParenOffset))) {
|
||||
return;
|
||||
}
|
||||
|
||||
int braceOffset = offset - 1;
|
||||
int numberOfParametersToDisplay = parametersCount > 1 && PsiImplUtil.isVarArgs(method) ? parametersCount - 1 : parametersCount;
|
||||
int numberOfCommas = Math.min(numberOfParametersToDisplay, limit) - 1;
|
||||
String commas = Registry.is("editor.completion.hints.virtual.comma") ? "" : StringUtil.repeat(", ", numberOfCommas);
|
||||
editor.getDocument().insertString(offset, commas);
|
||||
document.insertString(offset, commas);
|
||||
|
||||
PsiDocumentManager.getInstance(project).commitDocument(document);
|
||||
MethodParameterInfoHandler handler = new MethodParameterInfoHandler();
|
||||
|
||||
+7
-1
@@ -1369,7 +1369,7 @@ public class CompletionHintsTest extends AbstractParameterInfoTestCase {
|
||||
"}");
|
||||
}
|
||||
|
||||
public void testCaretMovementOverVirtualComma() throws Exception {
|
||||
public void testCaretMovementOverVirtualComma() {
|
||||
enableVirtualComma();
|
||||
|
||||
configureJava("class C { void m() { System.getPro<caret> } }");
|
||||
@@ -1380,6 +1380,12 @@ public class CompletionHintsTest extends AbstractParameterInfoTestCase {
|
||||
checkResultWithInlays("class C { void m() { System.getProperty(<Hint text=\"key:\"/>, <HINT text=\"def:\"/><caret>) } }");
|
||||
}
|
||||
|
||||
public void testHintsAreNotShownInImproperContext() {
|
||||
configureJava("class C { void m() { int a = Math.ma<caret>5; } }");
|
||||
complete("max(int a, int b)");
|
||||
checkResult("class C { void m() { int a = Math.max(<caret>)5; } }");
|
||||
}
|
||||
|
||||
private void checkResultWithInlays(String text) {
|
||||
myFixture.checkResultWithInlays(text);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user