diff --git a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/contentassist/CompletionProposalDescriptionProvider.java b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/contentassist/CompletionProposalDescriptionProvider.java index ef13714b5c..495fe2a6da 100644 --- a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/contentassist/CompletionProposalDescriptionProvider.java +++ b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/contentassist/CompletionProposalDescriptionProvider.java @@ -82,6 +82,7 @@ public static StringBuilder createMethodProposalDescription(CompletionProposal p case CompletionProposal.METHOD_NAME_REFERENCE: case CompletionProposal.POTENTIAL_METHOD_DECLARATION: case CompletionProposal.CONSTRUCTOR_INVOCATION: + case CompletionProposal.METHOD_DECLARATION: // method name description.append(proposal.getName()); diff --git a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/contentassist/CompletionProposalRequestor.java b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/contentassist/CompletionProposalRequestor.java index cbe09244df..6ea6bb1053 100644 --- a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/contentassist/CompletionProposalRequestor.java +++ b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/contentassist/CompletionProposalRequestor.java @@ -104,8 +104,8 @@ public int compare(CompletionProposal p1, CompletionProposal p2) { res = p1.getKind() - p2.getKind(); } if (res == 0) { - char[] completion1 = getCompletion(p1); - char[] completion2 = getCompletion(p2); + char[] completion1 = p1.getKind() == CompletionProposal.METHOD_DECLARATION ? p1.getName() : getCompletion(p1); + char[] completion2 = p2.getKind() == CompletionProposal.METHOD_DECLARATION ? p2.getName() : getCompletion(p2); int p1Length = completion1.length; int p2Length = completion2.length; @@ -122,7 +122,7 @@ public int compare(CompletionProposal p1, CompletionProposal p2) { } CompletionItemKind p1Kind = mapKind(p1); CompletionItemKind p2Kind = mapKind(p2); - if (res == 0 && (p1Kind == CompletionItemKind.Method || p1Kind == CompletionItemKind.Constructor) + if (res == 0 && (p1Kind == CompletionItemKind.Method || p1Kind == CompletionItemKind.Constructor) && (p2Kind == CompletionItemKind.Method || p2Kind == CompletionItemKind.Constructor)) { int paramCount1 = Signature.getParameterCount(p1.getSignature()); int paramCount2 = Signature.getParameterCount(p2.getSignature()); diff --git a/org.eclipse.jdt.ls.tests/src/org/eclipse/jdt/ls/core/internal/handlers/CompletionHandlerTest.java b/org.eclipse.jdt.ls.tests/src/org/eclipse/jdt/ls/core/internal/handlers/CompletionHandlerTest.java index 24b51c033b..e2042614e2 100644 --- a/org.eclipse.jdt.ls.tests/src/org/eclipse/jdt/ls/core/internal/handlers/CompletionHandlerTest.java +++ b/org.eclipse.jdt.ls.tests/src/org/eclipse/jdt/ls/core/internal/handlers/CompletionHandlerTest.java @@ -3744,7 +3744,8 @@ public void testCompletion_MatchCaseFirstLetterForMethodOverride() throws Except //@formatter:off "package org.sample", "public class Test {", - " public void testMethod(){}", + " public void testMethod(int a, int b){}", + " public void testMethod(int b){}", "}", "class TestOverride extends Test{", " t", @@ -3752,7 +3753,8 @@ public void testCompletion_MatchCaseFirstLetterForMethodOverride() throws Except //@formatter:on CompletionList list = requestCompletions(unit, "t"); assertFalse(list.getItems().isEmpty()); - assertTrue(list.getItems().get(1).getLabel().startsWith("testMethod")); + assertTrue(list.getItems().get(0).getLabel().startsWith("testMethod(int b")); + assertTrue(list.getItems().get(1).getLabel().startsWith("testMethod(int a")); } // https://github.com/eclipse/eclipse.jdt.ls/issues/2376