forked from qt-creator/qt-creator
qml | Fix trailing comments formatting
Change-Id: I0461c4616cff15b7010e3844850d32e9f07469ea Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
committed by
selatnick
parent
8dc16d55c2
commit
8f7cbd6416
@@ -96,6 +96,7 @@ class Rewriter : protected Visitor
|
|||||||
int _lastNewlineOffset = -1;
|
int _lastNewlineOffset = -1;
|
||||||
bool _hadEmptyLine = false;
|
bool _hadEmptyLine = false;
|
||||||
int _binaryExpDepth = 0;
|
int _binaryExpDepth = 0;
|
||||||
|
bool _hasOpenComment = false;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Rewriter(Document::Ptr doc)
|
Rewriter(Document::Ptr doc)
|
||||||
@@ -201,6 +202,9 @@ protected:
|
|||||||
|
|
||||||
void out(const QString &str, const SourceLocation &lastLoc = SourceLocation())
|
void out(const QString &str, const SourceLocation &lastLoc = SourceLocation())
|
||||||
{
|
{
|
||||||
|
if (_hasOpenComment) {
|
||||||
|
newLine();
|
||||||
|
}
|
||||||
if (lastLoc.isValid()) {
|
if (lastLoc.isValid()) {
|
||||||
QList<SourceLocation> comments = _doc->engine()->comments();
|
QList<SourceLocation> comments = _doc->engine()->comments();
|
||||||
for (; _nextComment < comments.size(); ++_nextComment) {
|
for (; _nextComment < comments.size(); ++_nextComment) {
|
||||||
@@ -371,6 +375,7 @@ protected:
|
|||||||
{
|
{
|
||||||
// if preceded by a newline, it's an empty line!
|
// if preceded by a newline, it's an empty line!
|
||||||
_hadEmptyLine = _line.trimmed().isEmpty();
|
_hadEmptyLine = _line.trimmed().isEmpty();
|
||||||
|
_hasOpenComment = false;
|
||||||
|
|
||||||
// if the preceding line wasn't empty, reindent etc.
|
// if the preceding line wasn't empty, reindent etc.
|
||||||
if (!_hadEmptyLine) {
|
if (!_hadEmptyLine) {
|
||||||
@@ -524,6 +529,7 @@ protected:
|
|||||||
|
|
||||||
out(" ");
|
out(" ");
|
||||||
out(toString(nextCommentLoc));
|
out(toString(nextCommentLoc));
|
||||||
|
_hasOpenComment = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -21,5 +21,13 @@ Item {
|
|||||||
{
|
{
|
||||||
console.log("test")
|
console.log("test")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var a = 1
|
||||||
|
if (a > 0) {
|
||||||
|
console.log("positive")
|
||||||
|
} // Final condition
|
||||||
|
else {
|
||||||
|
console.log("negative or zero")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user