mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
when choosing a groovy method with a closure parameter with space, just insert this space, no braces
This commit is contained in:
+3
-7
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user