[SourceKit][PlaceholderExpand] Avoid function signatures when expanding trailing closures of ()->(). rdar://21879249

This commit is contained in:
Xi Ge
2015-12-07 11:46:43 -08:00
parent 825348fdee
commit ab969d14a4
2 changed files with 13 additions and 2 deletions

View File

@@ -2594,6 +2594,13 @@ void SwiftEditorDocument::formatText(unsigned Line, unsigned Length,
Consumer.recordAffectedLineRange(LineRange.startLine(), LineRange.lineCount());
}
bool isReturningVoid(SourceManager &SM, CharSourceRange Range) {
if (Range.isInvalid())
return false;
StringRef Text = SM.extractText(Range);
return "()" == Text || "Void" == Text;
}
void SwiftEditorDocument::expandPlaceholder(unsigned Offset, unsigned Length,
EditorConsumer &Consumer) {
auto SyntaxInfo = Impl.getSyntaxInfo();
@@ -2672,8 +2679,7 @@ void SwiftEditorDocument::expandPlaceholder(unsigned Offset, unsigned Length,
OS << "{ ";
bool ReturningVoid = ClosureReturnTypeRange.isValid() &&
"Void" == SM.extractText(ClosureReturnTypeRange);
bool ReturningVoid = isReturningVoid(SM, ClosureReturnTypeRange);
bool HasSignature = !ClosureParams.empty() ||
(ClosureReturnTypeRange.isValid() && !ReturningVoid);