don't insert semicolon in the document copy when completing in method return type (needed for IDEA-143839)

This commit is contained in:
peter
2015-08-13 18:22:53 +02:00
parent f00d6044ed
commit f2a6dfd51b
3 changed files with 6 additions and 10 deletions
@@ -688,10 +688,6 @@ public class JavaCompletionContributor extends CompletionContributor {
final PsiJavaCodeReferenceElement ref = PsiTreeUtil.findElementOfClassAtOffset(file, context.getStartOffset(), PsiJavaCodeReferenceElement.class, false);
if (ref != null && !(ref instanceof PsiReferenceExpression)) {
if (ref.getParent() instanceof PsiTypeElement) {
context.setDummyIdentifier(CompletionInitializationContext.DUMMY_IDENTIFIER.trim() + ";");
}
if (JavaSmartCompletionContributor.AFTER_NEW.accepts(ref)) {
final PsiReferenceParameterList paramList = ref.getParameterList();
if (paramList != null && paramList.getTextLength() > 0) {
@@ -755,7 +751,7 @@ public class JavaCompletionContributor extends CompletionContributor {
}
if (iterator.atEnd()) return false;
return iterator.getTokenType() == JavaTokenType.EQ || iterator.getTokenType() == JavaTokenType.LPARENTH;
return iterator.getTokenType() == JavaTokenType.EQ; // <caret> foo = something, we don't want the reference to be treated as a type
}
private static void autoImport(@NotNull final PsiFile file, int offset, @NotNull final Editor editor) {
@@ -73,12 +73,12 @@ public class JavaCompletionSorting {
}
List<LookupElementWeigher> afterPrefix = ContainerUtil.newArrayList();
afterPrefix.add(new PreferByKindWeigher(type, position));
if (!smart) {
ContainerUtil.addIfNotNull(afterPrefix, preferStatics(position, expectedTypes));
}
afterPrefix.add(new PreferByKindWeigher(type, position));
if (!smart && !afterNew) {
afterPrefix.add(new PreferExpected(false, expectedTypes));
if (!afterNew) {
afterPrefix.add(new PreferExpected(false, expectedTypes));
}
}
ContainerUtil.addIfNotNull(afterPrefix, recursion(parameters, expectedTypes));
Collections.addAll(afterPrefix, new PreferSimilarlyEnding(expectedTypes),
@@ -293,7 +293,7 @@ public class NormalCompletionOrderingTest extends CompletionSortingTestCase {
}
public void testPreferModifiers() {
checkPreferredItems(0, "private", "protected", "public", "paaa", "paab");
checkPreferredItems(0, "private", "protected", "public");
}
public void testPreferEnumConstants() {