when choosing a groovy method with a closure parameter with space, just insert this space, no braces

This commit is contained in:
peter
2011-11-10 20:47:24 +01:00
parent a49a827621
commit 9dc01cfb68
2 changed files with 4 additions and 8 deletions
@@ -86,7 +86,8 @@ public class GroovyInsertHandler implements InsertHandler<LookupElement> {
if (PsiTreeUtil.getParentOfType(elementAt, GrImportStatement.class) != null) return;
if (parameters.length == 1) {
if (context.getCompletionChar() != '(' && TypesUtil.isClassType(parameters[0].getType(), GroovyCommonClassNames.GROOVY_LANG_CLOSURE)) {
if ((context.getCompletionChar() != '(' && context.getCompletionChar() != ' ') &&
TypesUtil.isClassType(parameters[0].getType(), GroovyCommonClassNames.GROOVY_LANG_CLOSURE)) {
int afterBrace;
final int nonWs = CharArrayUtil.shiftForward(document.getCharsSequence(), offset, " \t");
if (nonWs < document.getTextLength() && document.getCharsSequence().charAt(nonWs) == '{') {
@@ -95,12 +96,7 @@ public class GroovyInsertHandler implements InsertHandler<LookupElement> {
document.insertString(offset, " {}");
afterBrace = offset + 2;
}
if (context.getCompletionChar() == ' ') {
context.setAddCompletionChar(false);
caretModel.moveToOffset(offset + 1);
} else {
caretModel.moveToOffset(afterBrace);
}
caretModel.moveToOffset(afterBrace);
return;
}
}
@@ -115,7 +115,7 @@ for (def ch: "abc".toCharArray()) {
}
public void testEachSpace() throws Exception {
checkCompletion '[].ea<caret>', ' ', '[].each <caret>{}'
checkCompletion '[].ea<caret>', ' ', '[].each <caret>'
}
public void testEachBrace() throws Exception {