[PATCH] D137104: [clangd] Add scoped enum constants to all-scopes-completion
This revision was automatically updated to reflect the committed changes. Closed by commit rG990c18937967: [clangd] Add scoped enum constants to all-scopes-completion (authored by tom-anders). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D137104/new/ https://reviews.llvm.org/D137104 Files: clang-tools-extra/clangd/CodeComplete.cpp clang-tools-extra/clangd/CodeComplete.h clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp === --- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp +++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp @@ -1329,7 +1329,7 @@ AllOf(qName("Color"), forCodeCompletion(true)), AllOf(qName("Green"), forCodeCompletion(true)), AllOf(qName("Color2"), forCodeCompletion(true)), - AllOf(qName("Color2::Yellow"), forCodeCompletion(false)), + AllOf(qName("Color2::Yellow"), forCodeCompletion(true)), AllOf(qName("ns"), forCodeCompletion(true)), AllOf(qName("ns::Black"), forCodeCompletion(true)), AllOf(qName("Color3"), forCodeCompletion(true)), Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp === --- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp +++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp @@ -3382,11 +3382,13 @@ Opts.Index = Index.get(); Opts.AllScopes = true; auto R = completions(Source, {}, Opts); - EXPECT_THAT(R.Completions, - ElementsAre(AllOf(scope("ns::"), named("Clangd1"), -kind(CompletionItemKind::EnumMember)), - AllOf(scope("ns::C::"), named("Clangd2"), -kind(CompletionItemKind::EnumMember; + EXPECT_THAT(R.Completions, UnorderedElementsAre( + AllOf(scope("ns::"), named("Clangd1"), + kind(CompletionItemKind::EnumMember)), + AllOf(scope("ns::C::"), named("Clangd2"), + kind(CompletionItemKind::EnumMember)), + AllOf(scope("ns::Scoped::"), named("Clangd3"), + kind(CompletionItemKind::EnumMember; } TEST(CompletionTest, ScopeIsUnresolved) { Index: clang-tools-extra/clangd/CodeComplete.h === --- clang-tools-extra/clangd/CodeComplete.h +++ clang-tools-extra/clangd/CodeComplete.h @@ -291,7 +291,7 @@ // For index-based completion, we only consider: // * symbols in namespaces or translation unit scopes (e.g. no class // members, no locals) -// * enum constants in unscoped enum decl (e.g. "red" in "enum {red};") +// * enum constants (both scoped and unscoped) // * primary templates (no specializations) // For the other cases, we let Clang do the completion because it does not // need any non-local information and it will be much better at following Index: clang-tools-extra/clangd/CodeComplete.cpp === --- clang-tools-extra/clangd/CodeComplete.cpp +++ clang-tools-extra/clangd/CodeComplete.cpp @@ -2145,7 +2145,7 @@ // when // --all-scopes-completion is set, we'll want to complete those as well. if (const auto *EnumDecl = dyn_cast(ND.getDeclContext())) -return (InTopLevelScope(*EnumDecl) || InClassScope(*EnumDecl)) && !EnumDecl->isScoped(); +return (InTopLevelScope(*EnumDecl) || InClassScope(*EnumDecl)); return false; } Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp === --- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp +++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp @@ -1329,7 +1329,7 @@ AllOf(qName("Color"), forCodeCompletion(true)), AllOf(qName("Green"), forCodeCompletion(true)), AllOf(qName("Color2"), forCodeCompletion(true)), - AllOf(qName("Color2::Yellow"), forCodeCompletion(false)), + AllOf(qName("Color2::Yellow"), forCodeCompletion(true)), AllOf(qName("ns"), forCodeCompletion(true)), AllOf(qName("ns::Black"), forCodeCompletion(true)), AllOf(qName("Color3"), forCodeCompletion(true)), Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp === --- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp +++
[PATCH] D137104: [clangd] Add scoped enum constants to all-scopes-completion
nridge accepted this revision. nridge added a comment. This revision is now accepted and ready to land. Looks good, thanks Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D137104/new/ https://reviews.llvm.org/D137104 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D137104: [clangd] Add scoped enum constants to all-scopes-completion
tom-anders updated this revision to Diff 472578. tom-anders marked an inline comment as done. tom-anders added a comment. Actually fix test... Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D137104/new/ https://reviews.llvm.org/D137104 Files: clang-tools-extra/clangd/CodeComplete.cpp clang-tools-extra/clangd/CodeComplete.h clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp === --- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp +++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp @@ -1329,7 +1329,7 @@ AllOf(qName("Color"), forCodeCompletion(true)), AllOf(qName("Green"), forCodeCompletion(true)), AllOf(qName("Color2"), forCodeCompletion(true)), - AllOf(qName("Color2::Yellow"), forCodeCompletion(false)), + AllOf(qName("Color2::Yellow"), forCodeCompletion(true)), AllOf(qName("ns"), forCodeCompletion(true)), AllOf(qName("ns::Black"), forCodeCompletion(true)), AllOf(qName("Color3"), forCodeCompletion(true)), Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp === --- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp +++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp @@ -3382,11 +3382,13 @@ Opts.Index = Index.get(); Opts.AllScopes = true; auto R = completions(Source, {}, Opts); - EXPECT_THAT(R.Completions, - ElementsAre(AllOf(scope("ns::"), named("Clangd1"), -kind(CompletionItemKind::EnumMember)), - AllOf(scope("ns::C::"), named("Clangd2"), -kind(CompletionItemKind::EnumMember; + EXPECT_THAT(R.Completions, UnorderedElementsAre( + AllOf(scope("ns::"), named("Clangd1"), + kind(CompletionItemKind::EnumMember)), + AllOf(scope("ns::C::"), named("Clangd2"), + kind(CompletionItemKind::EnumMember)), + AllOf(scope("ns::Scoped::"), named("Clangd3"), + kind(CompletionItemKind::EnumMember; } TEST(CompletionTest, ScopeIsUnresolved) { Index: clang-tools-extra/clangd/CodeComplete.h === --- clang-tools-extra/clangd/CodeComplete.h +++ clang-tools-extra/clangd/CodeComplete.h @@ -291,7 +291,7 @@ // For index-based completion, we only consider: // * symbols in namespaces or translation unit scopes (e.g. no class // members, no locals) -// * enum constants in unscoped enum decl (e.g. "red" in "enum {red};") +// * enum constants (both scoped and unscoped) // * primary templates (no specializations) // For the other cases, we let Clang do the completion because it does not // need any non-local information and it will be much better at following Index: clang-tools-extra/clangd/CodeComplete.cpp === --- clang-tools-extra/clangd/CodeComplete.cpp +++ clang-tools-extra/clangd/CodeComplete.cpp @@ -2145,7 +2145,7 @@ // when // --all-scopes-completion is set, we'll want to complete those as well. if (const auto *EnumDecl = dyn_cast(ND.getDeclContext())) -return (InTopLevelScope(*EnumDecl) || InClassScope(*EnumDecl)) && !EnumDecl->isScoped(); +return (InTopLevelScope(*EnumDecl) || InClassScope(*EnumDecl)); return false; } Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp === --- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp +++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp @@ -1329,7 +1329,7 @@ AllOf(qName("Color"), forCodeCompletion(true)), AllOf(qName("Green"), forCodeCompletion(true)), AllOf(qName("Color2"), forCodeCompletion(true)), - AllOf(qName("Color2::Yellow"), forCodeCompletion(false)), + AllOf(qName("Color2::Yellow"), forCodeCompletion(true)), AllOf(qName("ns"), forCodeCompletion(true)), AllOf(qName("ns::Black"), forCodeCompletion(true)), AllOf(qName("Color3"), forCodeCompletion(true)), Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp === --- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp +++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp @@ -3382,11 +3382,13 @@ Opts.Index
[PATCH] D137104: [clangd] Add scoped enum constants to all-scopes-completion
tom-anders marked an inline comment as done. tom-anders added inline comments. Comment at: clang-tools-extra/clangd/CodeComplete.cpp:2136 + if (llvm::isa(ND.getDeclContext())) +return true; nridge wrote: > Why remove the `(InTopLevelScope(*EnumDecl) || InClassScope(*EnumDecl))` part? Huh, because I thought this covered all the scopes where you could declare enums anyway, but of course that's wrong - You can e.g. declare a function-local enum, which we of course don't want to index. Comment at: clang-tools-extra/clangd/CodeComplete.cpp:2136 + if (llvm::isa(ND.getDeclContext())) +return true; tom-anders wrote: > nridge wrote: > > Why remove the `(InTopLevelScope(*EnumDecl) || InClassScope(*EnumDecl))` > > part? > Huh, because I thought this covered all the scopes where you could declare > enums anyway, but of course that's wrong - You can e.g. declare a > function-local enum, which we of course don't want to index. d Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D137104/new/ https://reviews.llvm.org/D137104 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D137104: [clangd] Add scoped enum constants to all-scopes-completion
tom-anders updated this revision to Diff 472568. tom-anders added a comment. Update `CompletionTest.Enums`, keep scope condition in isIndexedForCodeCompletion Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D137104/new/ https://reviews.llvm.org/D137104 Files: clang-tools-extra/clangd/CodeComplete.cpp clang-tools-extra/clangd/CodeComplete.h clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp === --- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp +++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp @@ -1329,7 +1329,7 @@ AllOf(qName("Color"), forCodeCompletion(true)), AllOf(qName("Green"), forCodeCompletion(true)), AllOf(qName("Color2"), forCodeCompletion(true)), - AllOf(qName("Color2::Yellow"), forCodeCompletion(false)), + AllOf(qName("Color2::Yellow"), forCodeCompletion(true)), AllOf(qName("ns"), forCodeCompletion(true)), AllOf(qName("ns::Black"), forCodeCompletion(true)), AllOf(qName("Color3"), forCodeCompletion(true)), Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp === --- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp +++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp @@ -3386,6 +3386,8 @@ ElementsAre(AllOf(scope("ns::"), named("Clangd1"), kind(CompletionItemKind::EnumMember)), AllOf(scope("ns::C::"), named("Clangd2"), +kind(CompletionItemKind::EnumMember)), + AllOf(scope("ns::C::Scoped"), named("Clangd3"), kind(CompletionItemKind::EnumMember; } Index: clang-tools-extra/clangd/CodeComplete.h === --- clang-tools-extra/clangd/CodeComplete.h +++ clang-tools-extra/clangd/CodeComplete.h @@ -291,7 +291,7 @@ // For index-based completion, we only consider: // * symbols in namespaces or translation unit scopes (e.g. no class // members, no locals) -// * enum constants in unscoped enum decl (e.g. "red" in "enum {red};") +// * enum constants (both scoped and unscoped) // * primary templates (no specializations) // For the other cases, we let Clang do the completion because it does not // need any non-local information and it will be much better at following Index: clang-tools-extra/clangd/CodeComplete.cpp === --- clang-tools-extra/clangd/CodeComplete.cpp +++ clang-tools-extra/clangd/CodeComplete.cpp @@ -2145,7 +2145,7 @@ // when // --all-scopes-completion is set, we'll want to complete those as well. if (const auto *EnumDecl = dyn_cast(ND.getDeclContext())) -return (InTopLevelScope(*EnumDecl) || InClassScope(*EnumDecl)) && !EnumDecl->isScoped(); +return (InTopLevelScope(*EnumDecl) || InClassScope(*EnumDecl)); return false; } Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp === --- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp +++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp @@ -1329,7 +1329,7 @@ AllOf(qName("Color"), forCodeCompletion(true)), AllOf(qName("Green"), forCodeCompletion(true)), AllOf(qName("Color2"), forCodeCompletion(true)), - AllOf(qName("Color2::Yellow"), forCodeCompletion(false)), + AllOf(qName("Color2::Yellow"), forCodeCompletion(true)), AllOf(qName("ns"), forCodeCompletion(true)), AllOf(qName("ns::Black"), forCodeCompletion(true)), AllOf(qName("Color3"), forCodeCompletion(true)), Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp === --- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp +++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp @@ -3386,6 +3386,8 @@ ElementsAre(AllOf(scope("ns::"), named("Clangd1"), kind(CompletionItemKind::EnumMember)), AllOf(scope("ns::C::"), named("Clangd2"), +kind(CompletionItemKind::EnumMember)), + AllOf(scope("ns::C::Scoped"), named("Clangd3"), kind(CompletionItemKind::EnumMember; } Index: clang-tools-extra/clangd/CodeComplete.h
[PATCH] D137104: [clangd] Add scoped enum constants to all-scopes-completion
nridge added a comment. The test added in the previous patch, `CompletionTest.Enums`, needs to be updated to reflect this change (`Scoped::Clangd3` now appears as a completion). Comment at: clang-tools-extra/clangd/CodeComplete.cpp:2136 + if (llvm::isa(ND.getDeclContext())) +return true; Why remove the `(InTopLevelScope(*EnumDecl) || InClassScope(*EnumDecl))` part? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D137104/new/ https://reviews.llvm.org/D137104 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D137104: [clangd] Add scoped enum constants to all-scopes-completion
tom-anders updated this revision to Diff 472426. tom-anders added a comment. Rebase onto previous commit Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D137104/new/ https://reviews.llvm.org/D137104 Files: clang-tools-extra/clangd/CodeComplete.cpp clang-tools-extra/clangd/CodeComplete.h clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp === --- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp +++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp @@ -1329,7 +1329,7 @@ AllOf(qName("Color"), forCodeCompletion(true)), AllOf(qName("Green"), forCodeCompletion(true)), AllOf(qName("Color2"), forCodeCompletion(true)), - AllOf(qName("Color2::Yellow"), forCodeCompletion(false)), + AllOf(qName("Color2::Yellow"), forCodeCompletion(true)), AllOf(qName("ns"), forCodeCompletion(true)), AllOf(qName("ns::Black"), forCodeCompletion(true)), AllOf(qName("Color3"), forCodeCompletion(true)), Index: clang-tools-extra/clangd/CodeComplete.h === --- clang-tools-extra/clangd/CodeComplete.h +++ clang-tools-extra/clangd/CodeComplete.h @@ -291,7 +291,7 @@ // For index-based completion, we only consider: // * symbols in namespaces or translation unit scopes (e.g. no class // members, no locals) -// * enum constants in unscoped enum decl (e.g. "red" in "enum {red};") +// * enum constants (both scoped and unscoped) // * primary templates (no specializations) // For the other cases, we let Clang do the completion because it does not // need any non-local information and it will be much better at following Index: clang-tools-extra/clangd/CodeComplete.cpp === --- clang-tools-extra/clangd/CodeComplete.cpp +++ clang-tools-extra/clangd/CodeComplete.cpp @@ -2114,9 +2114,6 @@ }; return false; }; - auto InClassScope = [](const NamedDecl ) { -return ND.getDeclContext()->getDeclKind() == Decl::CXXRecord; - }; // We only complete symbol's name, which is the same as the name of the // *primary* template in case of template specializations. if (isExplicitTemplateSpecialization()) @@ -2135,8 +2132,8 @@ // Always index enum constants, even if they're not in the top level scope: // when // --all-scopes-completion is set, we'll want to complete those as well. - if (const auto *EnumDecl = dyn_cast(ND.getDeclContext())) -return (InTopLevelScope(*EnumDecl) || InClassScope(*EnumDecl)) && !EnumDecl->isScoped(); + if (llvm::isa(ND.getDeclContext())) +return true; return false; } Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp === --- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp +++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp @@ -1329,7 +1329,7 @@ AllOf(qName("Color"), forCodeCompletion(true)), AllOf(qName("Green"), forCodeCompletion(true)), AllOf(qName("Color2"), forCodeCompletion(true)), - AllOf(qName("Color2::Yellow"), forCodeCompletion(false)), + AllOf(qName("Color2::Yellow"), forCodeCompletion(true)), AllOf(qName("ns"), forCodeCompletion(true)), AllOf(qName("ns::Black"), forCodeCompletion(true)), AllOf(qName("Color3"), forCodeCompletion(true)), Index: clang-tools-extra/clangd/CodeComplete.h === --- clang-tools-extra/clangd/CodeComplete.h +++ clang-tools-extra/clangd/CodeComplete.h @@ -291,7 +291,7 @@ // For index-based completion, we only consider: // * symbols in namespaces or translation unit scopes (e.g. no class // members, no locals) -// * enum constants in unscoped enum decl (e.g. "red" in "enum {red};") +// * enum constants (both scoped and unscoped) // * primary templates (no specializations) // For the other cases, we let Clang do the completion because it does not // need any non-local information and it will be much better at following Index: clang-tools-extra/clangd/CodeComplete.cpp === --- clang-tools-extra/clangd/CodeComplete.cpp +++ clang-tools-extra/clangd/CodeComplete.cpp @@ -2114,9 +2114,6 @@ }; return false; }; - auto InClassScope = [](const NamedDecl ) { -return ND.getDeclContext()->getDeclKind() == Decl::CXXRecord; - }; // We only complete symbol's name, which is the same as the name of the // *primary* template in case of template specializations. if
[PATCH] D137104: [clangd] Add scoped enum constants to all-scopes-completion
tom-anders updated this revision to Diff 472103. tom-anders added a comment. Added missing hunk in CodeComplete.cpp Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D137104/new/ https://reviews.llvm.org/D137104 Files: clang-tools-extra/clangd/CodeComplete.cpp clang-tools-extra/clangd/CodeComplete.h clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp === --- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp +++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp @@ -1329,7 +1329,7 @@ AllOf(qName("Color"), forCodeCompletion(true)), AllOf(qName("Green"), forCodeCompletion(true)), AllOf(qName("Color2"), forCodeCompletion(true)), - AllOf(qName("Color2::Yellow"), forCodeCompletion(false)), + AllOf(qName("Color2::Yellow"), forCodeCompletion(true)), AllOf(qName("Color3"), forCodeCompletion(true)), AllOf(qName("Color3::Blue"), forCodeCompletion(true)), AllOf(qName("ns"), forCodeCompletion(true)), Index: clang-tools-extra/clangd/CodeComplete.h === --- clang-tools-extra/clangd/CodeComplete.h +++ clang-tools-extra/clangd/CodeComplete.h @@ -291,7 +291,7 @@ // For index-based completion, we only consider: // * symbols in namespaces or translation unit scopes (e.g. no class // members, no locals) -// * enum constants in unscoped enum decl (e.g. "red" in "enum {red};") +// * enum constants (both scoped and unscoped) // * primary templates (no specializations) // For the other cases, we let Clang do the completion because it does not // need any non-local information and it will be much better at following Index: clang-tools-extra/clangd/CodeComplete.cpp === --- clang-tools-extra/clangd/CodeComplete.cpp +++ clang-tools-extra/clangd/CodeComplete.cpp @@ -2114,9 +2114,6 @@ }; return false; }; - auto InClassScope = [](const NamedDecl ) { -return ND.getDeclContext()->getDeclKind() == Decl::CXXRecord; - }; // We only complete symbol's name, which is the same as the name of the // *primary* template in case of template specializations. if (isExplicitTemplateSpecialization()) @@ -2135,8 +2132,8 @@ // Always index enum constants, even if they're not in the top level scope: // when // --all-scopes-completion is set, we'll want to complete those as well. - if (const auto *EnumDecl = dyn_cast(ND.getDeclContext())) -return (InTopLevelScope(*EnumDecl) || InClassScope(*EnumDecl)) && !EnumDecl->isScoped(); + if (llvm::isa(ND.getDeclContext())) +return true; return false; } Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp === --- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp +++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp @@ -1329,7 +1329,7 @@ AllOf(qName("Color"), forCodeCompletion(true)), AllOf(qName("Green"), forCodeCompletion(true)), AllOf(qName("Color2"), forCodeCompletion(true)), - AllOf(qName("Color2::Yellow"), forCodeCompletion(false)), + AllOf(qName("Color2::Yellow"), forCodeCompletion(true)), AllOf(qName("Color3"), forCodeCompletion(true)), AllOf(qName("Color3::Blue"), forCodeCompletion(true)), AllOf(qName("ns"), forCodeCompletion(true)), Index: clang-tools-extra/clangd/CodeComplete.h === --- clang-tools-extra/clangd/CodeComplete.h +++ clang-tools-extra/clangd/CodeComplete.h @@ -291,7 +291,7 @@ // For index-based completion, we only consider: // * symbols in namespaces or translation unit scopes (e.g. no class // members, no locals) -// * enum constants in unscoped enum decl (e.g. "red" in "enum {red};") +// * enum constants (both scoped and unscoped) // * primary templates (no specializations) // For the other cases, we let Clang do the completion because it does not // need any non-local information and it will be much better at following Index: clang-tools-extra/clangd/CodeComplete.cpp === --- clang-tools-extra/clangd/CodeComplete.cpp +++ clang-tools-extra/clangd/CodeComplete.cpp @@ -2114,9 +2114,6 @@ }; return false; }; - auto InClassScope = [](const NamedDecl ) { -return ND.getDeclContext()->getDeclKind() == Decl::CXXRecord; - }; // We only complete symbol's name, which is the same as the name of the // *primary* template in case of template
[PATCH] D137104: [clangd] Add scoped enum constants to all-scopes-completion
tom-anders created this revision. tom-anders added a reviewer: nridge. Herald added subscribers: kadircet, arphaman. Herald added a project: All. tom-anders requested review of this revision. Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov. Herald added a project: clang-tools-extra. This was originally part of https://reviews.llvm.org/D136925, but we decided to move it to a separate patch. In case it turns out to be controversial, it can be reverted more easily. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D137104 Files: clang-tools-extra/clangd/CodeComplete.h clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp === --- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp +++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp @@ -1329,7 +1329,7 @@ AllOf(qName("Color"), forCodeCompletion(true)), AllOf(qName("Green"), forCodeCompletion(true)), AllOf(qName("Color2"), forCodeCompletion(true)), - AllOf(qName("Color2::Yellow"), forCodeCompletion(false)), + AllOf(qName("Color2::Yellow"), forCodeCompletion(true)), AllOf(qName("Color3"), forCodeCompletion(true)), AllOf(qName("Color3::Blue"), forCodeCompletion(true)), AllOf(qName("ns"), forCodeCompletion(true)), Index: clang-tools-extra/clangd/CodeComplete.h === --- clang-tools-extra/clangd/CodeComplete.h +++ clang-tools-extra/clangd/CodeComplete.h @@ -291,7 +291,7 @@ // For index-based completion, we only consider: // * symbols in namespaces or translation unit scopes (e.g. no class // members, no locals) -// * enum constants in unscoped enum decl (e.g. "red" in "enum {red};") +// * enum constants (both scoped and unscoped) // * primary templates (no specializations) // For the other cases, we let Clang do the completion because it does not // need any non-local information and it will be much better at following Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp === --- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp +++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp @@ -1329,7 +1329,7 @@ AllOf(qName("Color"), forCodeCompletion(true)), AllOf(qName("Green"), forCodeCompletion(true)), AllOf(qName("Color2"), forCodeCompletion(true)), - AllOf(qName("Color2::Yellow"), forCodeCompletion(false)), + AllOf(qName("Color2::Yellow"), forCodeCompletion(true)), AllOf(qName("Color3"), forCodeCompletion(true)), AllOf(qName("Color3::Blue"), forCodeCompletion(true)), AllOf(qName("ns"), forCodeCompletion(true)), Index: clang-tools-extra/clangd/CodeComplete.h === --- clang-tools-extra/clangd/CodeComplete.h +++ clang-tools-extra/clangd/CodeComplete.h @@ -291,7 +291,7 @@ // For index-based completion, we only consider: // * symbols in namespaces or translation unit scopes (e.g. no class // members, no locals) -// * enum constants in unscoped enum decl (e.g. "red" in "enum {red};") +// * enum constants (both scoped and unscoped) // * primary templates (no specializations) // For the other cases, we let Clang do the completion because it does not // need any non-local information and it will be much better at following ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits