From f2a6dfd51ba007340fc248df9d2dcf0440148ef1 Mon Sep 17 00:00:00 2001 From: peter Date: Thu, 13 Aug 2015 15:53:06 +0200 Subject: [PATCH] don't insert semicolon in the document copy when completing in method return type (needed for IDEA-143839) --- .../codeInsight/completion/JavaCompletionContributor.java | 6 +----- .../codeInsight/completion/JavaCompletionSorting.java | 8 ++++---- .../completion/NormalCompletionOrderingTest.groovy | 2 +- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionContributor.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionContributor.java index 7ccf7c65e5a0..0bdf7d5dafef 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionContributor.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionContributor.java @@ -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; // 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) { diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java index 05d574bd2495..ca6a491d5d82 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java @@ -73,12 +73,12 @@ public class JavaCompletionSorting { } List 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), diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionOrderingTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionOrderingTest.groovy index caee6158e7fc..5e3ab78fbf67 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionOrderingTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionOrderingTest.groovy @@ -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() {