[CursorInfo] Add Clang documentation to SymbolGraph output

This currently doesn't check for inherited docs, ie. either the
imported declaration has docs or it doesn't. There's also a few odd
cases with mixed doc types and when each line is prefixed with '*', but
it's good enough for an initial implementation.

Moves UTF8 sanitisation out of ASTPrinter.h and into Unicode.h so that
it can be used here as well.

Resolves rdar://91388603.
This commit is contained in:
Ben Barham
2022-04-08 13:41:37 -07:00
parent 66b08a8a6c
commit e2c9836a1d
9 changed files with 347 additions and 125 deletions

View File

@@ -22,6 +22,7 @@
#include "swift/AST/PrintOptions.h"
#include "swift/AST/SourceFile.h"
#include "swift/Basic/PrimitiveParsing.h"
#include "swift/Basic/Unicode.h"
#include "swift/ClangImporter/ClangImporter.h"
#include "swift/ClangImporter/ClangModule.h"
#include "swift/Parse/Token.h"
@@ -977,7 +978,7 @@ void ClangCommentPrinter::printDeclPost(const Decl *D,
return;
for (auto CommentText : PendingComments) {
*this << " " << ASTPrinter::sanitizeUtf8(CommentText);
*this << " " << unicode::sanitizeUTF8(CommentText);
}
PendingComments.clear();
if (auto ClangN = swift::ide::getEffectiveClangNode(D))
@@ -1068,7 +1069,7 @@ void ClangCommentPrinter::printComment(StringRef RawText, unsigned StartCol) {
trimLeadingWhitespaceFromLines(RawText, WhitespaceToTrim, Lines);
for (auto Line : Lines) {
*this << ASTPrinter::sanitizeUtf8(Line) << "\n";
*this << unicode::sanitizeUTF8(Line) << "\n";
printIndent();
}
}