mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 21:11:28 +07:00
fix double colon on completion
This commit is contained in:
@@ -838,11 +838,11 @@ public class JavaCompletionUtil {
|
||||
final char completionChar = context.getCompletionChar();
|
||||
final PsiFile file = context.getFile();
|
||||
|
||||
final TailType tailType = completionChar == '(' ? TailType.NONE : LookupItem.handleCompletionChar(context.getEditor(), item, completionChar);
|
||||
final TailType tailType = completionChar == '(' ? TailType.NONE : completionChar == ':' ? TailType.COND_EXPR_COLON : LookupItem.handleCompletionChar(context.getEditor(), item, completionChar);
|
||||
final boolean hasTail = tailType != TailType.NONE && tailType != TailType.UNKNOWN;
|
||||
final boolean smart = completionChar == Lookup.COMPLETE_STATEMENT_SELECT_CHAR;
|
||||
|
||||
if (completionChar == '(' || completionChar == '.' || completionChar == ',' || completionChar == ';') {
|
||||
if (completionChar == '(' || completionChar == '.' || completionChar == ',' || completionChar == ';' || completionChar == ':') {
|
||||
context.setAddCompletionChar(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,10 @@ public class VariableLookupItem extends LookupItem<PsiVariable> implements Typed
|
||||
context.setAddCompletionChar(false);
|
||||
TailType.COMMA.processTail(context.getEditor(), context.getTailOffset());
|
||||
}
|
||||
else if (completionChar == ':') {
|
||||
context.setAddCompletionChar(false);
|
||||
TailType.COND_EXPR_COLON.processTail(context.getEditor(), context.getTailOffset());
|
||||
}
|
||||
else if (completionChar == '.') {
|
||||
AutoPopupController.getInstance(context.getProject()).autoPopupMemberLookup(context.getEditor(), null);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
class Bar {
|
||||
int zoooa() {}
|
||||
int zooob() {}
|
||||
|
||||
int foo() {
|
||||
return true ? zoo<caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
class Bar {
|
||||
int zoooa() {}
|
||||
int zooob() {}
|
||||
|
||||
int foo() {
|
||||
return true ? zoooa() : <caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class Bar {
|
||||
int foo(int zoooa, int zooob) {
|
||||
return true ? zoo<caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class Bar {
|
||||
int foo(int zoooa, int zooob) {
|
||||
return true ? zoooa : <caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
class Bar {
|
||||
int zoooa() {}
|
||||
int zooob() {}
|
||||
|
||||
int foo() {
|
||||
return true ? zoooa() : <caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
class Bar {
|
||||
int zoooa() {}
|
||||
int zooob() {}
|
||||
|
||||
int foo() {
|
||||
return true ? zoo<caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class Bar {
|
||||
int foo(int zoooa, int zooob) {
|
||||
return true ? zoooa : <caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class Bar {
|
||||
int foo(int zoooa, int zooob) {
|
||||
return true ? zoo<caret>
|
||||
}
|
||||
}
|
||||
@@ -914,6 +914,9 @@ public class NormalCompletionTest extends LightFixtureCompletionTestCase {
|
||||
public void testNewClassAngleBracket() throws Exception { doTest('<') }
|
||||
public void testNewClassSquareBracket() throws Exception { doTest('[') }
|
||||
|
||||
public void testMethodColon() throws Exception { doTest(':') }
|
||||
public void testVariableColon() throws Exception { doTest(':') }
|
||||
|
||||
public void testNoMethodsInParameterType() {
|
||||
configure()
|
||||
assertOrderedEquals myFixture.lookupElementStrings, "final", "float"
|
||||
|
||||
@@ -691,6 +691,15 @@ public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase {
|
||||
|
||||
public void testDoubleTrueInOverloadedMethodCall() throws Throwable { doTest(Lookup.REPLACE_SELECT_CHAR); }
|
||||
|
||||
public void testMethodColon() throws Exception { doFirstItemTest(':'); }
|
||||
public void testVariableColon() throws Exception { doFirstItemTest(':'); }
|
||||
|
||||
private void doFirstItemTest(char c) throws Exception {
|
||||
configureByTestName();
|
||||
select(c);
|
||||
checkResultByTestName();
|
||||
}
|
||||
|
||||
public void testOneElementArray() throws Throwable { doTest(); }
|
||||
|
||||
public void testCastToArray() throws Throwable { doTest(); }
|
||||
@@ -706,9 +715,7 @@ public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase {
|
||||
public void testAutoCastWhenAlreadyCasted() throws Throwable { doTest(); }
|
||||
|
||||
public void testCommaDoublePenetration() throws Throwable {
|
||||
configureByTestName();
|
||||
select(',');
|
||||
checkResultByTestName();
|
||||
doFirstItemTest(',');
|
||||
}
|
||||
|
||||
public void testSuperMethodArguments() throws Throwable {
|
||||
@@ -867,9 +874,7 @@ public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase {
|
||||
}
|
||||
|
||||
public void testTabMethodCall() throws Exception {
|
||||
configureByTestName();
|
||||
select(Lookup.REPLACE_SELECT_CHAR);
|
||||
checkResultByTestName();
|
||||
doFirstItemTest(Lookup.REPLACE_SELECT_CHAR);
|
||||
}
|
||||
|
||||
public void testConstructorArgsSmartEnter() throws Exception { doTest(Lookup.COMPLETE_STATEMENT_SELECT_CHAR); }
|
||||
@@ -1013,9 +1018,7 @@ public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase {
|
||||
}
|
||||
|
||||
public void testTabAfterNew() throws Exception {
|
||||
configureByTestName();
|
||||
select('\t');
|
||||
checkResultByTestName();
|
||||
doFirstItemTest('\t');
|
||||
}
|
||||
|
||||
private void doTest(boolean performAction, boolean selectItem) throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user