QmlJs: reformatter for multiline-comments

Fix a reformatter bug that causes wrog indentation of multiline
comments.

Task-number: QTCREATORBUG-17426
Change-Id: I05493638dda0a353f5901fd95f06dc2e8e020237
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
This commit is contained in:
Marco Benelli
2017-01-20 11:47:17 +01:00
parent 58639a4a18
commit 1134c097e2

View File

@@ -147,13 +147,24 @@ protected:
out(QString::fromLatin1(str), lastLoc); out(QString::fromLatin1(str), lastLoc);
} }
void outCommentText(const QString &str)
{
QStringList lines = str.split(QLatin1Char('\n'));
for (int i = 0; i < lines.size(); ++i) {
_line = lines.at(i); // multiline comments don't keep track of previos lines
if (i != lines.size() - 1)
newLine();
}
_hadEmptyLine = false;
}
void outComment(const SourceLocation &commentLoc) void outComment(const SourceLocation &commentLoc)
{ {
SourceLocation fixedLoc = commentLoc; SourceLocation fixedLoc = commentLoc;
fixCommentLocation(fixedLoc); fixCommentLocation(fixedLoc);
if (precededByEmptyLine(fixedLoc)) if (precededByEmptyLine(fixedLoc))
newLine(); newLine();
out(toString(fixedLoc)); // don't use the sourceloc overload here outCommentText(toString(fixedLoc)); // don't use the sourceloc overload here
if (followedByNewLine(fixedLoc)) if (followedByNewLine(fixedLoc))
newLine(); newLine();
else else