mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[IDE/ModuleInterface] Adjust the indentation of regular comments to match the current indentation level.
Swift SVN r16362
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#include "swift/AST/ASTPrinter.h"
|
||||
#include "swift/AST/Decl.h"
|
||||
#include "swift/AST/Module.h"
|
||||
#include "swift/Basic/PrimitiveParsing.h"
|
||||
#include "swift/ClangImporter/ClangImporter.h"
|
||||
#include "swift/ClangImporter/ClangModule.h"
|
||||
#include "swift/Serialization/ModuleFile.h"
|
||||
@@ -63,6 +64,8 @@ private:
|
||||
// same header).
|
||||
void printCommentsUntil(ClangNode Node);
|
||||
|
||||
void printComment(StringRef Text, unsigned StartLocCol);
|
||||
|
||||
bool isDocumentationComment(clang::SourceLocation CommentLoc,
|
||||
ClangNode Node) const;
|
||||
|
||||
@@ -438,8 +441,8 @@ void ClangCommentPrinter::printCommentsUntil(ClangNode Node) {
|
||||
printIndent();
|
||||
}
|
||||
if (!IsDocComment) {
|
||||
*this << CommentText << "\n";
|
||||
printIndent();
|
||||
unsigned StartLocCol = SM.getSpellingColumnNumber(Tok.getLocation());
|
||||
printComment(CommentText, StartLocCol);
|
||||
}
|
||||
LastPrintedLineNo =
|
||||
SM.getLineNumber(LocInfo.first, LocInfo.second + Tok.getLength());
|
||||
@@ -450,6 +453,17 @@ void ClangCommentPrinter::printCommentsUntil(ClangNode Node) {
|
||||
setResumeOffset(FID, BufPtr - BufStart);
|
||||
}
|
||||
|
||||
void ClangCommentPrinter::printComment(StringRef RawText, unsigned StartCol) {
|
||||
unsigned WhitespaceToTrim = StartCol ? StartCol - 1 : 0;
|
||||
SmallVector<StringRef, 8> Lines;
|
||||
trimLeadingWhitespaceFromLines(RawText, WhitespaceToTrim, Lines);
|
||||
|
||||
for (auto Line : Lines) {
|
||||
*this << Line << "\n";
|
||||
printIndent();
|
||||
}
|
||||
}
|
||||
|
||||
bool ClangCommentPrinter::isDocumentationComment(
|
||||
clang::SourceLocation CommentLoc, ClangNode Node) const {
|
||||
const clang::Decl *D = Node.getAsDecl();
|
||||
|
||||
Reference in New Issue
Block a user