Index: clangd/ClangdUnit.cpp =================================================================== --- clangd/ClangdUnit.cpp +++ clangd/ClangdUnit.cpp @@ -383,6 +383,9 @@ Items.reserve(NumResults); for (unsigned I = 0; I < NumResults; ++I) { auto &Result = Results[I]; + if (Result.Availability == CXAvailability_NotAvailable || + Result.Availability == CXAvailability_NotAccessible) + continue; const auto *CCS = Result.CreateCodeCompletionString( S, Context, *Allocator, CCTUInfo, CodeCompleteOpts.IncludeBriefComments); @@ -428,23 +431,8 @@ // Fill in the sortText of the CompletionItem. assert(Score <= 99999 && "Expecting code completion result " "priority to have at most 5-digits"); - - const int Penalty = 100000; - switch (static_cast(CCS.getAvailability())) { - case CXAvailability_Available: - // No penalty. - break; - case CXAvailability_Deprecated: - Score += Penalty; - break; - case CXAvailability_NotAccessible: - Score += 2 * Penalty; - break; - case CXAvailability_NotAvailable: - Score += 3 * Penalty; - break; - } - + if (CCS.getAvailability() == CXAvailability_Deprecated) + Score += 100000; return Score; } Index: test/clangd/completion-priorities.test =================================================================== --- test/clangd/completion-priorities.test +++ test/clangd/completion-priorities.test @@ -57,27 +57,10 @@ # CHECK-NEXT: "kind": 2, # CHECK-NEXT: "label": "pub()", # CHECK-NEXT: "sortText": "000034pub" -# CHECK-NEXT: }, -# priv() and prot() are at the end of the list -# CHECK-NEXT: { -# CHECK: "detail": "void", -# CHECK: "filterText": "priv", -# CHECK-NEXT: "insertText": "priv", -# CHECK-NEXT: "insertTextFormat": 1, -# CHECK-NEXT: "kind": 2, -# CHECK-NEXT: "label": "priv()", -# CHECK-NEXT: "sortText": "200034priv" -# CHECK-NEXT: }, -# CHECK-NEXT: { -# CHECK-NEXT: "detail": "void", -# CHECK-NEXT: "filterText": "prot", -# CHECK-NEXT: "insertText": "prot", -# CHECK-NEXT: "insertTextFormat": 1, -# CHECK-NEXT: "kind": 2, -# CHECK-NEXT: "label": "prot()", -# CHECK-NEXT: "sortText": "200034prot" # CHECK-NEXT: } -# CHECK-NEXT: ] +# CHECK-NOT: "label": "priv()", +# CHECK-NOT: "label": "prot()", +# CHECK: ] Content-Length: 58 {"jsonrpc":"2.0","id":4,"method":"shutdown","params":null} Index: test/clangd/completion-qualifiers.test =================================================================== --- test/clangd/completion-qualifiers.test +++ test/clangd/completion-qualifiers.test @@ -11,7 +11,7 @@ # CHECK: "id": 2, # CHECK-NEXT: "jsonrpc": "2.0", # CHECK-NEXT: "result": [ -# Eligible const functions are at the top of the list. +# Eligible functions are at the top of the list. # CHECK-NEXT: { # CHECK-NEXT: "detail": "int", # CHECK-NEXT: "filterText": "bar", @@ -30,17 +30,9 @@ # CHECK-NEXT: "label": "Foo::foo() const", # CHECK-NEXT: "sortText": "000037foo" # CHECK-NEXT: }, -# Ineligible non-const function is at the bottom of the list. -# CHECK-NEXT: { -# CHECK: "detail": "int", -# CHECK: "filterText": "foo", -# CHECK-NEXT: "insertText": "foo", -# CHECK-NEXT: "insertTextFormat": 1, -# CHECK-NEXT: "kind": 2, -# CHECK-NEXT: "label": "foo() const", -# CHECK-NEXT: "sortText": "200035foo" -# CHECK-NEXT: } -# CHECK-NEXT: ] +# Ineligible private functions are not present. +# CHECK-NOT: "label": "foo() const", +# CHECK: ] Content-Length: 44 {"jsonrpc":"2.0","id":4,"method":"shutdown"}