|
@@ -344,6 +344,20 @@ BreakableBlockComment::BreakableBlockComment(
|
|
for (size_t i = 1; i < Lines.size(); ++i)
|
|
for (size_t i = 1; i < Lines.size(); ++i)
|
|
adjustWhitespace(i, IndentDelta);
|
|
adjustWhitespace(i, IndentDelta);
|
|
|
|
|
|
|
|
+ // Align decorations with the column of the star on the first line,
|
|
|
|
+ // that is one column after the start "/*".
|
|
|
|
+ DecorationColumn = StartColumn + 1;
|
|
|
|
+
|
|
|
|
+ // Account for comment decoration patterns like this:
|
|
|
|
+ //
|
|
|
|
+ // /*
|
|
|
|
+ // ** blah blah blah
|
|
|
|
+ // */
|
|
|
|
+ if (Lines.size() >= 2 && Content[1].startswith("**") &&
|
|
|
|
+ static_cast<unsigned>(ContentColumn[1]) == StartColumn) {
|
|
|
|
+ DecorationColumn = StartColumn;
|
|
|
|
+ }
|
|
|
|
+
|
|
Decoration = "* ";
|
|
Decoration = "* ";
|
|
if (Lines.size() == 1 && !FirstInLine) {
|
|
if (Lines.size() == 1 && !FirstInLine) {
|
|
// Comments for which FirstInLine is false can start on arbitrary column,
|
|
// Comments for which FirstInLine is false can start on arbitrary column,
|
|
@@ -373,6 +387,10 @@ BreakableBlockComment::BreakableBlockComment(
|
|
// trailing */. We also need to preserve whitespace, so that */ is
|
|
// trailing */. We also need to preserve whitespace, so that */ is
|
|
// correctly indented.
|
|
// correctly indented.
|
|
LastLineNeedsDecoration = false;
|
|
LastLineNeedsDecoration = false;
|
|
|
|
+ // Align the star in the last '*/' with the stars on the previous lines.
|
|
|
|
+ if (e >= 2 && !Decoration.empty()) {
|
|
|
|
+ ContentColumn[i] = DecorationColumn;
|
|
|
|
+ }
|
|
} else if (Decoration.empty()) {
|
|
} else if (Decoration.empty()) {
|
|
// For all other lines, set the start column to 0 if they're empty, so
|
|
// For all other lines, set the start column to 0 if they're empty, so
|
|
// we do not insert trailing whitespace anywhere.
|
|
// we do not insert trailing whitespace anywhere.
|
|
@@ -382,12 +400,15 @@ BreakableBlockComment::BreakableBlockComment(
|
|
}
|
|
}
|
|
|
|
|
|
// The first line already excludes the star.
|
|
// The first line already excludes the star.
|
|
|
|
+ // The last line excludes the star if LastLineNeedsDecoration is false.
|
|
// For all other lines, adjust the line to exclude the star and
|
|
// For all other lines, adjust the line to exclude the star and
|
|
// (optionally) the first whitespace.
|
|
// (optionally) the first whitespace.
|
|
unsigned DecorationSize = Decoration.startswith(Content[i])
|
|
unsigned DecorationSize = Decoration.startswith(Content[i])
|
|
? Content[i].size()
|
|
? Content[i].size()
|
|
: Decoration.size();
|
|
: Decoration.size();
|
|
- ContentColumn[i] += DecorationSize;
|
|
|
|
|
|
+ if (DecorationSize) {
|
|
|
|
+ ContentColumn[i] = DecorationColumn + DecorationSize;
|
|
|
|
+ }
|
|
Content[i] = Content[i].substr(DecorationSize);
|
|
Content[i] = Content[i].substr(DecorationSize);
|
|
if (!Decoration.startswith(Content[i]))
|
|
if (!Decoration.startswith(Content[i]))
|
|
IndentAtLineBreak =
|
|
IndentAtLineBreak =
|
|
@@ -400,7 +421,8 @@ BreakableBlockComment::BreakableBlockComment(
|
|
llvm::dbgs() << "IndentAtLineBreak " << IndentAtLineBreak << "\n";
|
|
llvm::dbgs() << "IndentAtLineBreak " << IndentAtLineBreak << "\n";
|
|
for (size_t i = 0; i < Lines.size(); ++i) {
|
|
for (size_t i = 0; i < Lines.size(); ++i) {
|
|
llvm::dbgs() << i << " |" << Content[i] << "| "
|
|
llvm::dbgs() << i << " |" << Content[i] << "| "
|
|
- << (Content[i].data() - Lines[i].data()) << "\n";
|
|
|
|
|
|
+ << "CC=" << ContentColumn[i] << "| "
|
|
|
|
+ << "IN=" << (Content[i].data() - Lines[i].data()) << "\n";
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|