fix double colon on completion

This commit is contained in:
peter
2011-03-14 19:03:32 +01:00
parent 5008dab45e
commit 0fdefe3ca3
12 changed files with 73 additions and 11 deletions

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -0,0 +1,8 @@
class Bar {
int zoooa() {}
int zooob() {}
int foo() {
return true ? zoo<caret>
}
}

View File

@@ -0,0 +1,8 @@
class Bar {
int zoooa() {}
int zooob() {}
int foo() {
return true ? zoooa() : <caret>
}
}

View File

@@ -0,0 +1,5 @@
class Bar {
int foo(int zoooa, int zooob) {
return true ? zoo<caret>
}
}

View File

@@ -0,0 +1,5 @@
class Bar {
int foo(int zoooa, int zooob) {
return true ? zoooa : <caret>
}
}

View File

@@ -0,0 +1,8 @@
class Bar {
int zoooa() {}
int zooob() {}
int foo() {
return true ? zoooa() : <caret>
}
}

View File

@@ -0,0 +1,8 @@
class Bar {
int zoooa() {}
int zooob() {}
int foo() {
return true ? zoo<caret>
}
}

View File

@@ -0,0 +1,5 @@
class Bar {
int foo(int zoooa, int zooob) {
return true ? zoooa : <caret>
}
}

View File

@@ -0,0 +1,5 @@
class Bar {
int foo(int zoooa, int zooob) {
return true ? zoo<caret>
}
}

View File

@@ -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"

View File

@@ -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 {