diff options
author | Sami Shalayel <sami.shalayel@qt.io> | 2023-07-04 17:12:32 +0200 |
---|---|---|
committer | Sami Shalayel <sami.shalayel@qt.io> | 2023-08-10 19:55:40 +0200 |
commit | a130481af21af38f931b98a33b84eaa0637e69c7 (patch) | |
tree | a548fe660ea9fa5b632b6639eaaff9be9fa209a3 /src/qml/parser/qqmljslexer.cpp | |
parent | 62014e9cecc633a046754e5f76cae66f052ae17b (diff) |
qmlls: check user-supplied names on renaming
Implement the checking of user-supplied names for renaming operations
in QmlLSUtils and qqmlrenamesymbolsupport.cpp
Add a helper method QQmlLSUtils::isValidEcmaScriptIdentifier that runs
the lexer on an identifier. Reject identifiers that do not parse as
T_IDENTIFIER, like keywords and invalid unicode escapes, for example.
Extend QQmlLSUtilsExpressionType to contain the name of the current
object.
Drive-by change: fix a off-by-one bug in the lexer, where files (or
identifiers, in this case) could not be lexed when they were ending with
an unicode-sequence.
Also, do not crash on JSIdentifiers without semantic scope in
resolveIdentifierExpressionType.
Add some tests, and fix a warning about positionAfterOneIndent
not being used in tst_qmlls_modules.cpp.
Add QQmlLSUtils::isChangedSignalName next to
QQmlLSUtils::isChangedHandlerName, and QQmlLSUtils::isHandlerName
and add tests for all three.
Fixes: QTBUG-114951
Task-number: QTBUG-114788
Change-Id: I0f1a544b70dfb69bca4aef355a8a8658f1d23081
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/parser/qqmljslexer.cpp')
-rw-r--r-- | src/qml/parser/qqmljslexer.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/qml/parser/qqmljslexer.cpp b/src/qml/parser/qqmljslexer.cpp index 28f4684649..704c7eb00d 100644 --- a/src/qml/parser/qqmljslexer.cpp +++ b/src/qml/parser/qqmljslexer.cpp @@ -368,7 +368,8 @@ uint Lexer::decodeUnicodeEscapeCharacter(bool *ok) { Q_ASSERT(_state.currentChar == u'u'); scanChar(); // skip u - if (_codePtr + 4 <= _endPtr && isHexDigit(_state.currentChar)) { + constexpr int distanceFromFirstHexToLastHex = 3; + if (_codePtr + distanceFromFirstHexToLastHex <= _endPtr && isHexDigit(_state.currentChar)) { uint codePoint = 0; for (int i = 0; i < 4; ++i) { int digit = hexDigit(_state.currentChar); |