Skip to content

Commit f2e4b19

Browse files
committed
Address review comments
1 parent 3c86fd8 commit f2e4b19

File tree

4 files changed

+13
-15
lines changed

4 files changed

+13
-15
lines changed

clang-tools-extra/clangd/CodeComplete.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,7 @@ struct CompletionCandidate {
294294
std::optional<llvm::StringRef>
295295
headerToInsertIfAllowed(const CodeCompleteOptions &Opts,
296296
CodeCompletionContext::Kind ContextKind) const {
297-
if (Opts.InsertIncludes ==
298-
CodeCompleteOptions::IncludeInsertion::NeverInsert ||
297+
if (Opts.InsertIncludes == Config::HeaderInsertionPolicy::NeverInsert ||
299298
RankedIncludeHeaders.empty() ||
300299
!contextAllowsHeaderInsertion(ContextKind))
301300
return std::nullopt;

clang-tools-extra/clangd/CodeComplete.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ struct CodeCompleteOptions {
7171
/// Whether to present doc comments as plain-text or markdown.
7272
MarkupKind DocumentationFormat = MarkupKind::PlainText;
7373

74-
using IncludeInsertion = Config::HeaderInsertionPolicy;
75-
Config::HeaderInsertionPolicy InsertIncludes = IncludeInsertion::IWYU;
74+
Config::HeaderInsertionPolicy InsertIncludes =
75+
Config::HeaderInsertionPolicy::IWYU;
7676

7777
/// Whether include insertions for Objective-C code should use #import instead
7878
/// of #include.

clang-tools-extra/clangd/tool/ClangdMain.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -251,19 +251,19 @@ opt<std::string> EnableFunctionArgSnippets{
251251
init("-1"),
252252
};
253253

254-
opt<CodeCompleteOptions::IncludeInsertion> HeaderInsertion{
254+
opt<Config::HeaderInsertionPolicy> HeaderInsertion{
255255
"header-insertion",
256256
cat(Features),
257257
desc("Add #include directives when accepting code completions"),
258258
init(CodeCompleteOptions().InsertIncludes),
259259
values(
260-
clEnumValN(CodeCompleteOptions::IncludeInsertion::IWYU, "iwyu",
260+
clEnumValN(Config::HeaderInsertionPolicy::IWYU, "iwyu",
261261
"Include what you use. "
262262
"Insert the owning header for top-level symbols, unless the "
263263
"header is already directly included or the symbol is "
264264
"forward-declared"),
265265
clEnumValN(
266-
CodeCompleteOptions::IncludeInsertion::NeverInsert, "never",
266+
Config::HeaderInsertionPolicy::NeverInsert, "never",
267267
"Never insert #include directives as part of code completion")),
268268
};
269269

@@ -668,7 +668,7 @@ class FlagsConfigProvider : public config::Provider {
668668
std::optional<Config::ExternalIndexSpec> IndexSpec;
669669
std::optional<Config::BackgroundPolicy> BGPolicy;
670670
std::optional<Config::ArgumentListsPolicy> ArgumentLists;
671-
std::optional<Config::HeaderInsertionPolicy> _HeaderInsertion;
671+
std::optional<Config::HeaderInsertionPolicy> HeaderInsertionPolicy;
672672

673673
// If --compile-commands-dir arg was invoked, check value and override
674674
// default path.
@@ -714,8 +714,8 @@ class FlagsConfigProvider : public config::Provider {
714714
}
715715

716716
// If CLI has set never, use that regardless of what the config files have
717-
if (HeaderInsertion == CodeCompleteOptions::IncludeInsertion::NeverInsert) {
718-
_HeaderInsertion = CodeCompleteOptions::IncludeInsertion::NeverInsert;
717+
if (HeaderInsertion == Config::HeaderInsertionPolicy::NeverInsert) {
718+
HeaderInsertionPolicy = Config::HeaderInsertionPolicy::NeverInsert;
719719
}
720720

721721
if (std::optional<bool> Enable = shouldEnableFunctionArgSnippets()) {
@@ -732,8 +732,8 @@ class FlagsConfigProvider : public config::Provider {
732732
C.Index.Background = *BGPolicy;
733733
if (ArgumentLists)
734734
C.Completion.ArgumentLists = *ArgumentLists;
735-
if (_HeaderInsertion)
736-
C.Completion.HeaderInsertion = *_HeaderInsertion;
735+
if (HeaderInsertionPolicy)
736+
C.Completion.HeaderInsertion = *HeaderInsertionPolicy;
737737
if (AllScopesCompletion.getNumOccurrences())
738738
C.Completion.AllScopes = AllScopesCompletion;
739739

clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -882,8 +882,7 @@ TEST(CompletionTest, IncludeInsertionPreprocessorIntegrationTests) {
882882
ElementsAre(AllOf(named("X"), insertInclude("\"bar.h\""))));
883883
// Can be disabled via option.
884884
CodeCompleteOptions NoInsertion;
885-
NoInsertion.InsertIncludes =
886-
CodeCompleteOptions::IncludeInsertion::NeverInsert;
885+
NoInsertion.InsertIncludes = Config::HeaderInsertionPolicy::NeverInsert;
887886
Results = completions(TU, Test.point(), {Sym}, NoInsertion);
888887
EXPECT_THAT(Results.Completions,
889888
ElementsAre(AllOf(named("X"), Not(insertInclude()))));
@@ -1192,7 +1191,7 @@ TEST(CompletionTest, CommentsOnMembersFromHeaderOverloadBundling) {
11921191
int delta(int i);
11931192
11941193
void epsilon(long l);
1195-
1194+
11961195
/// This one has a comment.
11971196
void epsilon(int i);
11981197
};

0 commit comments

Comments
 (0)