[PATCH] D88745: [clangd][WIP] Add new code completion signals to improve MRR by 3%.

Utkarsh Saxena via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 2 10:13:55 PDT 2020


usaxena95 created this revision.
Herald added subscribers: cfe-commits, kadircet, arphaman.
Herald added a project: clang.
usaxena95 requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

Adds two more signals.

- NumNameInContext: Strength of match of name with context.
- SemaPriority: Priority of a sema completion as given by sema.

This will potentially increase the MRR further by 3%.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88745

Files:
  clang-tools-extra/clangd/Quality.cpp
  clang-tools-extra/clangd/Quality.h
  clang-tools-extra/clangd/quality/model/features.json
  clang-tools-extra/clangd/quality/model/forest.json


Index: clang-tools-extra/clangd/quality/model/features.json
===================================================================
--- clang-tools-extra/clangd/quality/model/features.json
+++ clang-tools-extra/clangd/quality/model/features.json
@@ -23,6 +23,10 @@
         "name": "IsNameInContext",
         "kind": "NUMBER"
     },
+    {
+        "name": "NumNameInContext",
+        "kind": "NUMBER"
+    },
     {
         "name": "IsForbidden",
         "kind": "NUMBER"
@@ -63,6 +67,10 @@
         "name": "TypeMatchesPreferred",
         "kind": "NUMBER"
     },
+    {
+        "name": "SemaPriority",
+        "kind": "NUMBER"
+    },
     {
         "name": "SymbolCategory",
         "kind": "ENUM",
Index: clang-tools-extra/clangd/Quality.h
===================================================================
--- clang-tools-extra/clangd/Quality.h
+++ clang-tools-extra/clangd/Quality.h
@@ -140,6 +140,9 @@
   /// CompletionPrefix.
   unsigned FilterLength = 0;
 
+  /// Priority of the completion item as computed by Sema.
+  unsigned SemaPriority = 0;
+
   /// Set of derived signals computed by calculateDerivedSignals(). Must not be
   /// set explicitly.
   struct DerivedSignals {
Index: clang-tools-extra/clangd/Quality.cpp
===================================================================
--- clang-tools-extra/clangd/Quality.cpp
+++ clang-tools-extra/clangd/Quality.cpp
@@ -300,6 +300,8 @@
       SemaCCResult.Availability == CXAvailability_NotAccessible)
     Forbidden = true;
 
+  SemaPriority = SemaCCResult.Priority;
+
   if (SemaCCResult.Declaration) {
     SemaSaysInScope = true;
     // We boost things that have decls in the main file. We give a fixed score
@@ -499,6 +501,8 @@
   SymbolRelevanceSignals::DerivedSignals Derived =
       Relevance.calculateDerivedSignals();
   E.setIsNameInContext(Derived.NameMatchesContext);
+  // FIXME: Use number of matches of name in context here.
+  E.setNumNameInContext(Derived.NameMatchesContext);
   E.setIsForbidden(Relevance.Forbidden);
   E.setIsInBaseClass(Relevance.InBaseClass);
   E.setFileProximityDistance(Derived.FileProximityDistance);
@@ -512,6 +516,7 @@
   E.setHadSymbolType(Relevance.HadSymbolType);
   E.setTypeMatchesPreferred(Relevance.TypeMatchesPreferred);
   E.setFilterLength(Relevance.FilterLength);
+  E.setSemaPriority(Relevance.SemaPriority);
   return Evaluate(E);
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88745.295861.patch
Type: text/x-patch
Size: 2372 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201002/d09bb0d3/attachment.bin>


More information about the cfe-commits mailing list