[PATCH] D42491: [clangd] Disable typo correction when doing code completion.
Haojian Wu via Phabricator via llvm-commits
llvm-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 rL323410: [clangd] Disable typo correction when doing code completion. (authored by hokein, committed by ).
Herald added a subscriber: llvm-commits.
Repository:
rL LLVM
https://reviews.llvm.org/D42491
Files:
clang-tools-extra/trunk/clangd/CodeComplete.cpp
clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
Index: clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
===================================================================
--- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
+++ clang-tools-extra/trunk/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;
Index: clang-tools-extra/trunk/clangd/CodeComplete.cpp
===================================================================
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp
+++ clang-tools-extra/trunk/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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42491.131399.patch
Type: text/x-patch
Size: 1766 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180125/17d23af3/attachment.bin>
More information about the llvm-commits
mailing list