IDEA-53346 Extra pair of parentheses when completing a constructor call

This commit is contained in:
peter
2010-04-06 15:31:21 +04:00
parent c0a1c3e661
commit d2086dc7f3
4 changed files with 15 additions and 0 deletions

View File

@@ -96,6 +96,9 @@ public class DefaultInsertHandler extends TemplateInsertHandler implements Clone
if (completionChar == Lookup.COMPLETE_STATEMENT_SELECT_CHAR) {
tailType = TailType.SMART_COMPLETION;
}
if (myLookupItem.getAttribute(LookupItem.NEW_OBJECT_ATTR) != null && completionChar == '(') {
tailType = TailType.NONE;
}
myState = new InsertHandlerState(myContext.getSelectionEndOffset(), myContext.getSelectionEndOffset());

View File

@@ -0,0 +1,3 @@
public class Foo {
String s = new Strin<caret>
}

View File

@@ -0,0 +1,3 @@
public class Foo {
String s = new String(<caret>)
}

View File

@@ -494,6 +494,12 @@ public class NormalCompletionTest extends LightCompletionTestCase {
checkResultByFile("/codeInsight/completion/normal/" + getTestName(false) + "_after.java");
}
public void testFinishClassNameWithLParen() throws Throwable {
configureByFile("/codeInsight/completion/normal/" + getTestName(false) + ".java");
type('(');
checkResultByFile("/codeInsight/completion/normal/" + getTestName(false) + "_after.java");
}
public void testSelectNoParameterSignature() throws Throwable {
configureByFile("/codeInsight/completion/normal/" + getTestName(false) + ".java");
final int parametersCount = ((PsiMethod)getLookup().getCurrentItem().getObject()).getParameterList().getParametersCount();