@@ -242,13 +242,13 @@ opt<std::string> FallbackStyle{
242
242
init (clang::format::DefaultFallbackStyle),
243
243
};
244
244
245
- opt<int > EnableFunctionArgSnippets{
245
+ opt<std::string > EnableFunctionArgSnippets{
246
246
" function-arg-placeholders" ,
247
247
cat (Features),
248
248
desc (" When disabled (0), completions contain only parentheses for "
249
249
" function calls. When enabled (1), completions also contain "
250
250
" placeholders for method parameters" ),
251
- init (- 1 ),
251
+ init (" -1 " ),
252
252
};
253
253
254
254
opt<CodeCompleteOptions::IncludeInsertion> HeaderInsertion{
@@ -636,6 +636,22 @@ loadExternalIndex(const Config::ExternalIndexSpec &External,
636
636
llvm_unreachable (" Invalid ExternalIndexKind." );
637
637
}
638
638
639
+ std::optional<bool > shouldEnableFunctionArgSnippets () {
640
+ std::string Val = EnableFunctionArgSnippets;
641
+ // Accept the same values that a bool option parser would, but also accept
642
+ // -1 to indicate "unspecified", in which case the ArgumentListsPolicy
643
+ // config option will be respected.
644
+ if (Val == " 1" || Val == " true" || Val == " True" || Val == " TRUE" )
645
+ return true ;
646
+ if (Val == " 0" || Val == " false" || Val == " False" || Val == " FALSE" )
647
+ return false ;
648
+ if (Val != " -1" )
649
+ elog (" Value specified by --function-arg-placeholders is invalid. Provide a "
650
+ " boolean value or leave unspecified to use ArgumentListsPolicy from "
651
+ " config instead." );
652
+ return std::nullopt;
653
+ }
654
+
639
655
class FlagsConfigProvider : public config ::Provider {
640
656
private:
641
657
config::CompiledFragment Frag;
@@ -696,10 +712,9 @@ class FlagsConfigProvider : public config::Provider {
696
712
BGPolicy = Config::BackgroundPolicy::Skip;
697
713
}
698
714
699
- if (EnableFunctionArgSnippets >= 0 ) {
700
- ArgumentLists = EnableFunctionArgSnippets
701
- ? Config::ArgumentListsPolicy::FullPlaceholders
702
- : Config::ArgumentListsPolicy::Delimiters;
715
+ if (std::optional<bool > Enable = shouldEnableFunctionArgSnippets ()) {
716
+ ArgumentLists = *Enable ? Config::ArgumentListsPolicy::FullPlaceholders
717
+ : Config::ArgumentListsPolicy::Delimiters;
703
718
}
704
719
705
720
Frag = [=](const config::Params &, Config &C) {
0 commit comments