create field from usage: insert braces at selection end (IDEA-102716)

(cherry picked from commit 7eba27508d6e74cad0841013c313c05f6d96f17e)
This commit is contained in:
anna
2013-03-15 21:39:50 +01:00
parent 8ed5a8175f
commit 664fb24186
4 changed files with 28 additions and 1 deletions
@@ -108,7 +108,7 @@ public class PsiTypeLookupItem extends LookupItem {
context.getDocument().insertString(genericsStart, JavaCompletionUtil.escapeXmlIfNeeded(context, calcGenerics(position, context)));
JavaCompletionUtil.shortenReference(context.getFile(), genericsStart - 1);
int tail = context.getTailOffset();
int tail = context.getSelectionEndOffset();
String braces = StringUtil.repeat("[]", getBracketsCount());
Editor editor = context.getEditor();
if (!braces.isEmpty()) {
@@ -0,0 +1,12 @@
// "Create Field 'fooMoo'" "true"
class Barr {
private final String s;
private final Foo[] fooMoo;
enum Foo {}
Barr(String s, Foo... foos) {
this.s = s;
this.fooMoo = foos;
}
}
@@ -0,0 +1,11 @@
// "Create Field 'fooMoo'" "true"
class Barr {
private final String s;
enum Foo {}
Barr(String s, Foo... foos) {
this.s = s;
this.foo<caret>Moo = foos;
}
}
@@ -52,6 +52,10 @@ public class CreateFieldFromUsageTest extends LightQuickFixTestCase{
doSingleTest();
}
public void testArrayBraces() throws Exception {
doSingleTest();
}
protected void doSingleTest() {
doSingleTest(getTestName(false) + ".java");
}