Author: Utkarsh Saxena Date: 2021-03-02T15:04:23+01:00 New Revision: 7f086d74c347750c1da619058eb5b3e79c2fae14
URL: https://github.com/llvm/llvm-project/commit/7f086d74c347750c1da619058eb5b3e79c2fae14 DIFF: https://github.com/llvm/llvm-project/commit/7f086d74c347750c1da619058eb5b3e79c2fae14.diff LOG: Revert "[clangd] Use ML Code completion ranking as default." CodeCompletionContext::Kind has 36 Kinds. The completion model currently only handles categorical features of 32 cardinality. Changing the datatype to uint64_t will solve the problem. This reverts commit 438b5bb05a429d697674088d400e4800c1108658. Added: Modified: clang-tools-extra/clangd/CodeComplete.h clang-tools-extra/clangd/Quality.cpp clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/clangd/CodeComplete.h b/clang-tools-extra/clangd/CodeComplete.h index 40a528caa939..debf71d4117c 100644 --- a/clang-tools-extra/clangd/CodeComplete.h +++ b/clang-tools-extra/clangd/CodeComplete.h @@ -133,7 +133,7 @@ struct CodeCompleteOptions { enum CodeCompletionRankingModel { Heuristics, DecisionForest, - } RankingModel = DecisionForest; + } RankingModel = Heuristics; /// Callback used to score a CompletionCandidate if DecisionForest ranking /// model is enabled. diff --git a/clang-tools-extra/clangd/Quality.cpp b/clang-tools-extra/clangd/Quality.cpp index 99421009c71c..b49392bc7d04 100644 --- a/clang-tools-extra/clangd/Quality.cpp +++ b/clang-tools-extra/clangd/Quality.cpp @@ -580,16 +580,12 @@ evaluateDecisionForest(const SymbolQualitySignals &Quality, // multiplciative boost (like NameMatch). This allows us to weigh the // prediciton score and NameMatch appropriately. Scores.ExcludingName = pow(Base, Evaluate(E)); - // Following cases are not part of the generated training dataset: - // - Symbols with `NeedsFixIts`. - // - Forbidden symbols. - // - Keywords: Dataset contains only macros and decls. + // NeedsFixIts is not part of the DecisionForest as generating training + // data that needs fixits is not-feasible. if (Relevance.NeedsFixIts) Scores.ExcludingName *= 0.5; if (Relevance.Forbidden) Scores.ExcludingName *= 0; - if (Quality.Category == SymbolQualitySignals::Keyword) - Scores.ExcludingName *= 4; // NameMatch should be a multiplier on total score to support rescoring. Scores.Total = Relevance.NameMatch * Scores.ExcludingName; diff --git a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp index 0ff1e83b7613..b7a40179aa98 100644 --- a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp +++ b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp @@ -647,13 +647,13 @@ TEST(CompletionTest, ScopedWithFilter) { } TEST(CompletionTest, ReferencesAffectRanking) { - EXPECT_THAT(completions("int main() { abs^ }", {func("absA"), func("absB")}) - .Completions, - HasSubsequence(Named("absA"), Named("absB"))); - EXPECT_THAT(completions("int main() { abs^ }", - {func("absA"), withReferences(1000, func("absB"))}) - .Completions, - HasSubsequence(Named("absB"), Named("absA"))); + auto Results = completions("int main() { abs^ }", {ns("absl"), func("absb")}); + EXPECT_THAT(Results.Completions, + HasSubsequence(Named("absb"), Named("absl"))); + Results = completions("int main() { abs^ }", + {withReferences(10000, ns("absl")), func("absb")}); + EXPECT_THAT(Results.Completions, + HasSubsequence(Named("absl"), Named("absb"))); } TEST(CompletionTest, ContextWords) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits