fix Tab not working to move to next completion parameter, when current parameter is a field reference

This commit is contained in:
Dmitry Batrak
2018-07-26 16:45:11 +03:00
parent f3b8e76a13
commit 346766bce4
2 changed files with 32 additions and 1 deletions
@@ -43,7 +43,8 @@ public class JavaNextParameterHandler extends EditorActionHandler {
int next = CharArrayUtil.shiftForward(text, offset, " \t");
PsiExpressionList list = (PsiExpressionList)exprList;
int actualParameterCount = list.getExpressionCount();
int lastParamStart = actualParameterCount == 0 ? list.getTextOffset() + 1 : list.getExpressions()[actualParameterCount - 1].getTextOffset();
int lastParamStart = actualParameterCount == 0 ? list.getTextOffset() + 1
: list.getExpressions()[actualParameterCount - 1].getTextRange().getStartOffset();
if (next >= lastParamStart) {
int prev = CharArrayUtil.shiftBackward(text, lastParamStart - 1, " \t");
char prevChar = prev >= 0 && prev < editor.getDocument().getTextLength() ? text
@@ -1401,6 +1401,36 @@ public class CompletionHintsTest extends AbstractParameterInfoTestCase {
checkResultWithInlays("class C { void m() { System.getProperty(new String(<Hint text=\"bytes:\"/>null, <HINT text=\"charsetName:\"/><caret>)) } }");
}
public void testFieldAccessInsideMethodInvocation() throws Exception {
enableVirtualComma();
configureJava("class C {\n" +
" int x;\n" +
" void some(int a, int b) {}\n" +
" void other() { som<caret> }\n" +
"}");
complete();
checkResultWithInlays("class C {\n" +
" int x;\n" +
" void some(int a, int b) {}\n" +
" void other() { some(<HINT text=\"a:\"/><caret><Hint text=\",b:\"/>); }\n" +
"}");
type("this.");
complete("x");
checkResultWithInlays("class C {\n" +
" int x;\n" +
" void some(int a, int b) {}\n" +
" void other() { some(<HINT text=\"a:\"/>this.x<caret><Hint text=\",b:\"/>); }\n" +
"}");
next();
waitForAllAsyncStuff();
checkResultWithInlays("class C {\n" +
" int x;\n" +
" void some(int a, int b) {}\n" +
" void other() { some(<Hint text=\"a:\"/>this.x, <HINT text=\"b:\"/><caret>); }\n" +
"}");
}
private void checkResultWithInlays(String text) {
myFixture.checkResultWithInlays(text);
}