| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Mark the lexing / parsing code as security critical, because they are
data parsers. While _running_ QML code needs to assume trusted input, we
probably should not have this restriction on the parser, so that tools
like qmllint, qmlls and qdoc can safely pass any file to the parser,
without having to worry about security implications.
The criticality extends to qqmljskeywords_p.h, as we do custom bounds
checking in the functions defined there.
qqmljsastfwd_p is marked as insignificant, as it only contains fowrard
declarations and no logic at all.
The other marked files have the default level (significant).
QUIP: 23
Task-number: QTBUG-136966
Pick-to: 6.10 6.9 6.8
Change-Id: I1e44f346d91d6d66c8e9632f0dec4a11fffc935a
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|
| |
|
|
|
|
|
|
| |
There is no logic in the code based on the T_RESERVED_WORD, therefore
this commit removes it in favor of using explicit tokens.
Change-Id: Ie71f805e87bcee5c0b41ca24dc0c8fb20d13871b
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
|
| |
Initial implementation was based on the 3rd edition of ECMAScript.
Many things have changed since then and most of keywords were removed
from that section, even starting from the 5th edition of the standard.
This commit removes most of these reserved keywords, while leaving out
some which might potentially be useful for QML in the future.
Change-Id: I0190a6ea6d08b5d0797eb46c6636ffdb295b4565
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
|
| |
|
|
|
|
|
|
|
|
| |
Accept QStringView instead of QChat* and size.
This will be handy in later patches to compare keywords
through strings and not by characters
Change-Id: Ie6750feb643614ceb37cad508e3bb0b33ea13952
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
|
| |
|
|
|
|
|
|
|
| |
Note that any actual language support for final will be added in later
commits.
Task-number: QTBUG-98320
Change-Id: I8b8f9fbc998219ed4cd504c10f54bc3483e65f06
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add a check in the lexer and fail in the parser if the file to be parsed
is too big for qsizetype and quint32.
QQmlJS::SourceLocation uses quint32 to save the offset, and code using
QQmlJS::SourceLocation's offset usually do their computation on
qsizetype.
Therefore, limit the QML file size to
std::numerical_limits<quint32>::max() on 64 bits machine when qsizetype
has a representation for std::numerical_limits<quint32>::max(), and to
std::numerical_limits<qsizetype>::max() otherwise.
Thats 2Gb on 32 bits machine and 4Gb on 64 bits machine.
Currently, using qml tooling on files bigger than the limits mentioned
above already leads to UB without this patch.
Add a helper to construct SourceLocation from qsizetype indexes.
Task-number: QTBUG-127833
Change-Id: Ic255964e13ebae08488ed160e59d504638f1b9ad
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Partially reverts commit 4ba86a97011dda2d8792ee23f0e86015715a592e
that tried to reduce the number of parser conflicts by introducing
new parser rules and a new token T_FUNCTION_STAR.
The new token T_FUNCTION_STAR seems unnecessary: removing it does not
make new conflicts appear in the parser. Furthermore, it allows
removing some special handling from the lexer.
Therefore, remove all occurrences of T_FUNCTION_STAR and replace it with
T_FUNCTION and T_STAR. Add the sourcelocation of the star to the
FunctionExpression so it becomes available (previously the star was
located at the end of the function-token sourcelocation).
Change the parser to create Function Declaration early in its
FunctionStar rule, so it can save the sourcelocation of the "function"
keyword and the "*" token in FunctionDeclaration.
Also fix indexes in the parser where T_FUNCTION T_STAR does shift all
the following arguments by one position to the left.
Pick-to: 6.8
Fixes: QTBUG-126676
Change-Id: I4c405c136137628e58469b91f2b93dc2edb110e3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
|
| |
|
|
|
|
| |
Pick-to: 6.8
Change-Id: I0625e5675f9a7424eebee84b734faa69f676f74a
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We're going to make the QChar constructors not perform implicit
conversions anymore, but only accept exactly the listed constructor
arguments, and enums are not one of these, so fix by using char16_t
instead. The variable is anyway only compared to char16_t literals in
the rest of the function.
As a drive-by, mark the variable const and remove overparenthesization.
Amends dad5d1cc82a57a4f657aa3f37ad2f55b69d5b015
Change-Id: I81d6adbb290d994c8a3bb4b998572da3765c08a9
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
ES2021 introduced numeric separators in numeric literals to improve
readability.
For example, one billion can be written "1_000_000_000" where "_" are
the numeric separators.
Update the QML lexer to allow numeric separators, based on
https://262.ecma-international.org/12.0/#prod-NumericLiteralSeparator.
Add a non-exhaustive test case to `tst_qqmlparser` to track the behavior.
Fixes: QTBUG-123792
Change-Id: Ie62d1f40fc8e0c7678e7dfea16408bdeeba6d150
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Dmitrii Akshintsev <dmitrii.akshintsev@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
| |
|
|
|
|
|
|
| |
...and move one of them out-of-line; it's only used inside the
lexer's implementation file anyway.
Change-Id: I19ad039dda804a4283f644b58b555e082a770f04
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is a semantic patch using ClangTidyTransformator as in
qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8:
auto QtContainerClass = anyOf(
expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o),
expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o));
makeRule(cxxMemberCallExpr(on(QtContainerClass),
callee(cxxMethodDecl(hasAnyName({"count", "length"),
parameterCountIs(0))))),
changeTo(cat(access(o, cat("size"), "()"))),
cat("use 'size()' instead of 'count()/length()'"))
a.k.a qt-port-to-std-compatible-api with config Scope: 'Container',
with the extended set of container classes recognized.
Change-Id: Idb1f75dfe2323bd1d9e8b4d58d54f1b4b80c7ed7
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
|
| |
|
|
|
| |
Change-Id: I8ce66f5d7a75ae8ba8733ddb464c2198bd18ce27
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
The Qml lexer was not restartable, make it so that a line can be
parsed independently from another.
This is a requirement for efficient indenting and highlighting.
Old approach in creator used a separate finite state machien "scanner",
now it is possible to use the same lexer as the parser.
One can "checkpoint" every few lines, and restart the process form the
line above the change, and stop when the status is the same as before.
Change-Id: I72a13a767ac7adfe103e56e60902e61c88e4fd82
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
|
| |
Replace the current license disclaimer in files by
a SPDX-License-Identifier.
Files that have to be modified by hand are modified.
License files are organized under LICENSES directory.
Pick-to: 6.4
Task-number: QTBUG-67283
Change-Id: I63563bbeb6f60f89d2c99660400dca7fab78a294
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
| |
Moves all variables that represent the lexers state into a separate struct
that can be read and modified from the outside. This is necessary in order
to enable per-line formatting in qmldom
Change-Id: Iedde139cec6380bd62fa12c5ddec2a943a3b50f9
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This change implements optional chaining (https://github.com/tc39/proposal-optional-chaining) by adding a new type of optional lookup with an offset to the end of a chain.
If `undefined` or `null` is encountered during an access marked as optional, we jump to that end offset.
Features:
- Full support for all kinds of optional chain
- With some codegen overhead but zero overhead during normal non-optional FieldMemberExpression resolution
- Properly retains this contexts and does not need to resolve anything twice (this has been an issue previously)
- No extra AST structures, just flags for existing ones
[ChangeLog][QtQml] Added support for optional chaining (https://github.com/tc39/proposal-optional-chaining)
Fixes: QTBUG-77926
Change-Id: I9a41cdc4ca272066c79c72b9b22206498a546843
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
|
| |
|
|
|
|
|
|
|
| |
This is helpful for the upcoming handling of ?., which needs to be
treated as a single token (T_QUESTION_DOT), unless it is followed by a
number literal.
Change-Id: Id5e992bd037c2df88ef6e66905ec58a39bb67d73
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|
| |
|
|
|
|
|
| |
identifierWithEscapeChars is just set to true a few lines before.
Change-Id: I6c2b1ff4146d1a606c78f21669fb3d45cfaa2de3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The "qml" tool was the only way of loading QML files that would respect
a shebang line. This is problematic as this way you cannot load such
files programatically using QQmlComponent, limiting their re-use. Common
tools like Qt Creator, but also qmllint, qmlformat, qmlcachegen, etc
would not recognize files with shebangs.
By moving she-bang support directly in the lexer all tools implicitly
support it.
Note that we could just as easily support '#' as extra comment
character along with //, but here we narrowly add support for in
the first line only, as node does (this means that javascript files
using she-bang accepted by node, are now accepted also by qml).
The only tool needing some adjustments is qmlformat, that has to emit
the she-bang again as she-bang and as first line.
Add tests for qmlformat, and sprinkle some she-bangs in the other
tests just to be sure it doesn't affect anything.
Change-Id: I1f6d881c7438bdb23163b5dbe829d59a35d11132
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
|
| |
|
|
|
| |
Change-Id: Idb26e2df6d4fe8940db57066a30fa8c243f6d2c9
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
|
| |
|
|
|
|
|
| |
Potentially saves a few cycles by avoiding a strlen call.
Change-Id: I3c1e4ddf3fb0a52e9f44edea11616a8969604091
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
|
| |
|
|
|
|
|
|
|
|
| |
qstrtod is no longer exported, but instead an inline function. This
replaces the existing forward declarations with an include of the
required private header.
Change-Id: I50bd32557c55dddcb197f163609fd7d5a1b2301b
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
|
| |
|
|
|
|
|
|
| |
Task-number: QTBUG-84319
Change-Id: I2dcfb8a2db98282c7a1acdad1e6f4f949f26df15
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
| |
Follow-up lines of continuations strings that directly end
with an unescaped line feed still broke the line numbers of
code following the string. Fix by explicitly handling the
first character inside a string differently.
Amends 126ee5c901a9675a9ab61d4c6f2961c95b8bceac.
Change-Id: Ia945546d35db844114064ae34d6189704ceefe3b
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
|
| |
|
|
|
|
|
| |
This avoids the warnings on conversion to QChar.
Change-Id: Ib774f24592d6f09a531c60bb6fa6e5bdbec88120
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
|
| |
|
|
|
|
|
|
| |
If a string ends with a line terminator follow-up lines had a
wrong line number.
Change-Id: I98a8f69cbc876e07b3fe83490d517bf7771c59b5
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|
| |
|
|
|
|
|
|
|
| |
The lexer handled escape sequences inside string literals
wrongly which could led to follow-up problems like wrong
offsets or even lines of tokens.
Change-Id: Ief14dda77f9079931a7d19ea549017a1d59c2d0b
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|
| |
|
|
|
|
| |
Task-number: QTBUG-71278
Change-Id: Ie3167d44780a192b5010052eea5192eee8c21c32
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
|
| |
This is needed in a few places outside of declarative, so this change
restores the loc member in DiagnosticMessage and moves
QQmlJS::AST::SourceLocation into common's QQmlJS namespace/directory.
QQmlError is unaffected and retains only line/column.
Amends d4d197d06279f9257647628f7e1ccc9ec763a6bb
Change-Id: Ifb9d344228e3c6e9e26fc4fe112686f9336ea2b2
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
A QML Annotation is a Qml Object declaration prepended with @.
The name of the annotation is restricted to a dot separated list of
non keyword identifiers.
Annotations can be put before an Object definition, or any object
member declaration: bindings, property declarations, function
declarations.
This patch, aside parsing the annotations does absolutely nothing, the
list of annotations is discarded and never touches the AST.
[ChangeLog][QML] Add Qml Annotations
Task-number: QTBUG-81714
Change-Id: I4d79559a0d1fb23acaf482d0ef8f7d106dbf099d
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|
| |
|
|
|
|
|
|
|
|
| |
Implements the '??' operator as specified in https://github.com/tc39/proposal-nullish-coalescing.
Also adds a few tests.
Task-number: QTBUG-77926
Change-Id: I3993450c192d11bf1ade0662d945c1553b4c6976
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
|
| |
First, let the lexer create a T_FUNCTION_STAR token for "function *",
which makes the job of the parser significantly easier.
Then, by using GeneratorDeclaration instead of GeneratorExpression, we can
avoid the conflicts between UiObjectMember and PrimaryExpression
Change-Id: Ib08918e3977ed1a80cdea0948da80bf37886f7de
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|
| |
|
|
|
|
|
| |
We need it in both, the compiler and the runtime.
Change-Id: Iffacb9d150bf9eef6ef477bfd427dbac9bf49359
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Be more strict in parsing version numbers
This also makes it easier to access the version number in other places
using the Visitor interface, like (soon) the linter and avoids reparsing
the text twice.
Potential disadvantages: previously allowed import statements will
rejected at parse time, e.g.
import QtQuick 0b10
Potential further advantage: Weird import statements like
import QtQuick 0b10
will be rejected earlier
Change-Id: Ifcd187b79a90952bc964c688afa4ea9b158e5109
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We only need two classes to describe all possible diagnostics:
* A low-level private POD DiagnosticMessage. This is easily copied and
passed around internally. It doesn't need to adhere to a stable API
and it doesn't carry any extra baggage.
* The high-level public QQmlError with its stable interface. This can
internally also use a DiagnosticMessage as storage.
Change-Id: I52be88d9b5d9855a661b8032b01eedb43a0fb0b3
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
|
| |\
| |
| |
| |
| |
| |
| |
| | |
Conflicts:
src/qml/jsruntime/qv4script.cpp
src/qml/parser/qqmljslexer.cpp
Change-Id: I82252a8c504a4b77c45f4f8efe849ff9acb949fd
|
| | |
| |
| |
| |
| |
| |
| | |
Fixes: QTBUG-71812
Change-Id: I93b99496a7572c0f5128c69b865bb2b4f87d29af
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
|
| |/
|
|
|
|
|
|
| |
This is required to properly implement support for tagged templates
and String.raw.
Change-Id: Id548f97dd8ebfb7206abb55967f979c3fa6f6eea
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
| |
Move properties from RegExpObject to getters in RegExp.prototype
to be compliant with the JS spec.
Implement support for the sticky flags ('y') and correctly parse
the flags in the RegExp constructor.
Change-Id: I5cf05d14e8139cf30d46235b8d466fb96084fcb7
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
|
| |
|
|
|
|
|
| |
Add support for the 'u' flag for regular expressions.
Change-Id: I409054eaa9c50183619752d14f2638f5a38c0ea7
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
|
| |
* Always parse 'import' as a keyword, as it is now one in Qml and ES.
* Always parse 'as' as keyword but allow it as identifier using the same
trick as for the other keywords.
This fixes basic import statements such as import "foo.mjs" as bar but
still allows funny variations such as import "foo.mjs" as as.
Change-Id: I76a600aab90c1b5c07d079bf11b0a78742d44c53
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
|
| |
|
|
|
|
| |
Task-number: QTBUG-67476
Change-Id: Ia8c6863ad35c8a92298e5dffd750d17628200573
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
The support is basically at the same level as for for-in
at the moment.
Currently unimplemented:
* Destructuring
* Proper lexical scoping
* calling iterator.throw()/return() when required
Change-Id: If193ce0b054c4315fc16b7e174334a31b2730dcf
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
|
| |
|
|
|
|
|
|
|
| |
Some smaller changes to the codegen are included as well to ensure
that we catch all uses of generators and properly throw an unimplemented
error on them for now.
Change-Id: Ib915a0e862e128644ff00dfe989507783c912c66
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
|
| |
|
|
|
|
|
|
| |
In some valid cases, the lexer would add an automatic semicolon
before the ++/-- operators even if it shouldn't.
Change-Id: I2935259fd98a4c7f3f929cc1cecea85f7dde8016
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
|
| |
|
|
|
| |
Change-Id: I58a21e70fdd040175b52465d6ba52e7fceaf6398
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
|
| |
|
|
|
| |
Change-Id: Ib228925db9285e61acebc79f881acfbc2de9ff16
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
|
| |
|
|
|
|
|
|
|
|
|
|
| |
It's not a keyword outside of generator functions, so extend the
qmlmode boolean on the lexer to become a more general parsemode that
we can use to also turn the yield keyword on and of.
The parser can then set the flag when it enters the body of a generator
function.
Change-Id: Ibf792d4c7c567d825c6706f7b4997362c87fc575
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
|