[clang-tools-extra] r323410 - [clangd] Disable typo correction when doing code completion.
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 25 01:44:06 PST 2018
Author: hokein
Date: Thu Jan 25 01:44:06 2018
New Revision: 323410
URL: http://llvm.org/viewvc/llvm-project?rev=323410&view=rev
Log:
[clangd] Disable typo correction when doing code completion.
Reviewers: ilya-biryukov
Reviewed By: ilya-biryukov
Subscribers: klimek, jkorous-apple, cfe-commits, ioeric
Differential Revision: https://reviews.llvm.org/D42491
Modified:
clang-tools-extra/trunk/clangd/CodeComplete.cpp
clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=323410&r1=323409&r2=323410&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original)
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Thu Jan 25 01:44:06 2018
@@ -379,10 +379,6 @@ std::vector<std::string> getQueryScopes(
// 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 @@ bool semaCodeComplete(const Context &Ctx
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;
Modified: clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp?rev=323410&r1=323409&r2=323410&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp Thu Jan 25 01:44:06 2018
@@ -621,6 +621,14 @@ TEST(CompletionTest, DynamicIndexMultiFi
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;
More information about the cfe-commits
mailing list