[IDE/ModuleInterface] Adjust the indentation of regular comments to match the current indentation level.

Swift SVN r16362
This commit is contained in:
Argyrios Kyrtzidis
2014-04-15 06:27:40 +00:00
parent 22d11c52f0
commit a9ea63a7f7
7 changed files with 115 additions and 45 deletions

View File

@@ -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();