Merge pull request #36551 from ahoppen/pr/internal-labels-in-closures

[CodeComplete] Default parameter names of completed closure to internal names
This commit is contained in:
Alex Hoppen
2021-04-06 15:30:26 +02:00
committed by GitHub
18 changed files with 163 additions and 39 deletions

View File

@@ -4801,10 +4801,23 @@ public:
Printer.printStructurePost(PrintStructureKind::FunctionParameter);
};
if (printLabels && Param.hasLabel()) {
if ((Options.AlwaysTryPrintParameterLabels || printLabels) &&
Param.hasLabel()) {
// Label printing was requested and we have an external label. Print it
// and omit the internal label.
Printer.printName(Param.getLabel(),
PrintNameContext::FunctionParameterExternal);
Printer << ": ";
} else if (Options.AlwaysTryPrintParameterLabels &&
Param.hasInternalLabel()) {
// We didn't have an external parameter label but were requested to
// always try and print parameter labels. Print The internal label.
// If we have neither an external nor an internal label, only print the
// type.
Printer << "_ ";
Printer.printName(Param.getInternalLabel(),
PrintNameContext::FunctionParameterLocal);
Printer << ": ";
}
auto type = Param.getPlainType();