IDEA-173473 Class type argument brackets are still inserted despite that being disabled

This commit is contained in:
peter
2017-05-30 18:09:59 +02:00
parent 4ac53a4d01
commit d9accfb4d4
4 changed files with 29 additions and 29 deletions

View File

@@ -885,7 +885,9 @@ public class JavaCompletionUtil {
String open = escapeXmlIfNeeded(context, "<");
context.getDocument().insertString(offset, open);
context.getEditor().getCaretModel().moveToOffset(offset + open.length());
context.getDocument().insertString(offset + open.length(), escapeXmlIfNeeded(context, ">"));
if (CodeInsightSettings.getInstance().AUTOINSERT_PAIR_BRACKET) {
context.getDocument().insertString(offset + open.length(), escapeXmlIfNeeded(context, ">"));
}
if (context.getCompletionChar() != Lookup.COMPLETE_STATEMENT_SELECT_CHAR) {
context.setAddCompletionChar(false);
}

View File

@@ -0,0 +1,6 @@
public class SomeClass {
private void b() {
List<caret>
}
}

View File

@@ -0,0 +1,8 @@
import java.util.List;
public class SomeClass {
private void b() {
List<<caret>
}
}

View File

@@ -222,6 +222,7 @@ class NormalCompletionTest extends LightFixtureCompletionTestCase {
protected void tearDown() throws Exception {
CodeInsightSettings.instance.AUTOCOMPLETE_ON_CODE_COMPLETION = true
CodeInsightSettings.instance.COMPLETION_CASE_SENSITIVE = CodeInsightSettings.FIRST_LETTER
CodeInsightSettings.getInstance().AUTOINSERT_PAIR_BRACKET = true
super.tearDown()
}
@@ -361,44 +362,22 @@ class NormalCompletionTest extends LightFixtureCompletionTestCase {
}
void testMethodWithLeftParTailTypeNoPairBrace() throws Exception {
final boolean old = CodeInsightSettings.getInstance().AUTOINSERT_PAIR_BRACKET
CodeInsightSettings.getInstance().AUTOINSERT_PAIR_BRACKET = false
try {
configureByFile(getTestName(false) + ".java")
type('(')
checkResult()
}
finally {
CodeInsightSettings.getInstance().AUTOINSERT_PAIR_BRACKET = old
}
doTest('(')
}
void testMethodWithLeftParTailTypeNoPairBrace2() throws Exception {
final boolean old = CodeInsightSettings.getInstance().AUTOINSERT_PAIR_BRACKET
CodeInsightSettings.getInstance().AUTOINSERT_PAIR_BRACKET = false
try {
//no tail type should work the normal way
configureByFile("MethodWithLeftParTailTypeNoPairBrace.java")
selectItem(myItems[0])
checkResultByFile("MethodWithLeftParTailTypeNoPairBrace_after2.java")
}
finally {
CodeInsightSettings.getInstance().AUTOINSERT_PAIR_BRACKET = old
}
//no tail type should work the normal way
configureByFile("MethodWithLeftParTailTypeNoPairBrace.java")
selectItem(myItems[0])
checkResultByFile("MethodWithLeftParTailTypeNoPairBrace_after2.java")
}
void testMethodNoPairBrace() throws Exception {
final boolean old = CodeInsightSettings.getInstance().AUTOINSERT_PAIR_BRACKET
CodeInsightSettings.getInstance().AUTOINSERT_PAIR_BRACKET = false
try {
doTest '\n'
}
finally {
CodeInsightSettings.getInstance().AUTOINSERT_PAIR_BRACKET = old
}
doTest '\n'
}
void testExcessSpaceInTypeCast() throws Throwable {
@@ -1784,5 +1763,10 @@ class Bar {
myFixture.addClass("package pkg; public class PathUtil { public static String toSystemDependentName() {} }")
doTest('\n')
}
void testPairAngleBracketDisabled() {
CodeInsightSettings.instance.AUTOINSERT_PAIR_BRACKET = false
doTest('<')
}
}