IDEA-147313 Adding @NotNull in front of a method parameter and finishing lookup with Space inserts 2 spaces

This commit is contained in:
peter
2015-11-04 16:51:15 +01:00
parent 94e3eb2c04
commit 4cac3b6b78
4 changed files with 18 additions and 4 deletions
@@ -18,6 +18,7 @@ package com.intellij.codeInsight.completion;
import com.intellij.codeInsight.AutoPopupController;
import com.intellij.codeInsight.ExpectedTypeInfo;
import com.intellij.codeInsight.ExpectedTypesProvider;
import com.intellij.codeInsight.lookup.Lookup;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.PsiTypeLookupItem;
import com.intellij.openapi.editor.Editor;
@@ -112,10 +113,12 @@ class JavaClassNameInsertHandler implements InsertHandler<JavaPsiClassReferenceE
if (shouldHaveAnnotationParameters(psiClass)) {
JavaCompletionUtil.insertParentheses(context, item, false, true);
}
CharSequence text = context.getDocument().getCharsSequence();
int tail = context.getTailOffset();
if (text.length() > tail && Character.isLetter(text.charAt(tail))) {
context.getDocument().insertString(tail, " ");
if (context.getCompletionChar() == Lookup.NORMAL_SELECT_CHAR || context.getCompletionChar() == Lookup.COMPLETE_STATEMENT_SELECT_CHAR) {
CharSequence text = context.getDocument().getCharsSequence();
int tail = context.getTailOffset();
if (text.length() > tail && Character.isLetter(text.charAt(tail))) {
context.getDocument().insertString(tail, " ");
}
}
}
@@ -0,0 +1,5 @@
@interface AbcdAnno {}
class Foo {
void foo(@Abc<caret>Foo f) {}
}
@@ -0,0 +1,5 @@
@interface AbcdAnno {}
class Foo {
void foo(@AbcdAnno <caret>Foo f) {}
}
@@ -999,6 +999,7 @@ public class ListUtils {
public void testOnlyAnnotationsAfterAt() throws Throwable { doTest() }
public void testOnlyAnnotationsAfterAt2() throws Throwable { doTest('\n') }
public void testAnnotationBeforeIdentifier() { doTest('\n') }
public void testAnnotationBeforeIdentifierFinishWithSpace() { doTest(' ') }
public void testOnlyExceptionsInCatch1() throws Exception { doTest('\n') }
public void testOnlyExceptionsInCatch2() throws Exception { doTest('\n') }