forked from qt-creator/qt-creator
qmljsreformatter: support nullish coalescing
qmljsscanner did interpret ?? and ?. as a single ? and thus as the start of a ternary operator, breaking reformatting. Fixes: QTCREATORBUG-27344 Change-Id: I0429d20aed0196743f1c20e6ceac11351d5a7a3b Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -498,6 +498,18 @@ QList<Token> Scanner::operator()(const QString &text, int startState)
|
||||
setRegexpMayFollow(&_state, true);
|
||||
break;
|
||||
|
||||
case '?':
|
||||
switch (la.unicode()) {
|
||||
case '?':
|
||||
case '.':
|
||||
tokens.append(Token(index, 2, Token::Delimiter));
|
||||
index += 2;
|
||||
default:
|
||||
tokens.append(Token(index++, 1, Token::Delimiter));
|
||||
}
|
||||
setRegexpMayFollow(&_state, true);
|
||||
break;
|
||||
|
||||
default:
|
||||
if (ch.isSpace()) {
|
||||
do {
|
||||
|
||||
Reference in New Issue
Block a user