[PATCH] D42491: [clangd] Disable typo correction when doing code completion.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 25 01:45:40 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE323410: [clangd] Disable typo correction when doing code completion. (authored by hokein, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D42491?vs=131286&id=131400#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42491

Files:
  clangd/CodeComplete.cpp
  unittests/clangd/CodeCompleteTests.cpp


Index: clangd/CodeComplete.cpp
===================================================================
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -379,10 +379,6 @@
   // Qualified completion ("std::vec^"), we have two cases depending on whether
   // the qualifier can be resolved by Sema.
   if ((*SS)->isValid()) { // Resolved qualifier.
-    // FIXME: Disable Sema typo correction during code completion.
-    // The resolved qualifier might not perfectly match the written qualifier.
-    // e.g. "namespace clang { clangd::^ }", we will get "clang" declaration
-    // for completion "clangd::".
     return GetAllAccessibleScopes(CCContext).scopesForIndexQuery();
   }
 
@@ -678,6 +674,9 @@
   auto &DiagOpts = Clang->getDiagnosticOpts();
   DiagOpts.IgnoreWarnings = true;
 
+  // Disable typo correction in Sema.
+  Clang->getLangOpts().SpellChecking = false;
+
   auto &FrontendOpts = Clang->getFrontendOpts();
   FrontendOpts.SkipFunctionBodies = true;
   FrontendOpts.CodeCompleteOpts = Options;
Index: unittests/clangd/CodeCompleteTests.cpp
===================================================================
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -621,6 +621,14 @@
                                             Doc("Doooc"), Detail("void"))));
 }
 
+TEST(CodeCompleteTest, DisableTypoCorrection) {
+  auto Results = completions(R"cpp(
+     namespace clang { int v; }
+     void f() { clangd::^
+  )cpp");
+  EXPECT_TRUE(Results.items.empty());
+}
+
 SignatureHelp signatures(StringRef Text) {
   MockFSProvider FS;
   MockCompilationDatabase CDB;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42491.131400.patch
Type: text/x-patch
Size: 1622 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180125/e40e153e/attachment.bin>


More information about the cfe-commits mailing list