Dom construction fails before this commit if it encounters one of
null expression, true and false literals. Add dom representation for
them.
Change-Id: I2dbb2ebfce83b32426eb5e159fe9e4f0f68c56c3
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Add test for null statements inside blocks. Also, add tests for const and
var variable declarations.
Change-Id: I7eacb74a848e3ee7a4c0b2053de72c902330ce2b
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Divide scriptExpressions test into smaller testable units
Change-Id: Ib8a3b58e43bfe9a22ae72f35600f67bef163d855
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Implement and test the DOM representation of a JS return statement.
Task-number: QTBUG-100084
Task-number: QTBUG-111415
Change-Id: I2c11c0b9be3c93cf5be2bd9db5575335d4be19c1
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Rename the getter from {setQ,q}QmlJSScope() to {setS,s}emanticScope().
Set the semantic scope in the script elements where needed.
Test that BlockStatements contain their semantic scope.
Task-number: QTBUG-100084
Task-number: QTBUG-111415
Change-Id: If8b34c7edaac6aaf42a1cb2c47b12820358709e5
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Add a benchmark for DomConstruction using the scriptexpressions.
Task-number: QTBUG-92876
Change-Id: Ieab942a194d82933601424247d6ab71bce0540e2
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Implement the Dom representation for some constructs, like:
* Literals (string and numbers)
* IdentifierExpressions (variableNames appearing in expressions)
* VariableDeclarations and VariableDeclarationEntries
* ForStatements
* BlockStatements
* IfStatements
Introduce the namespace QQmlJS::Dom::ScriptElements that will contain
the Dom representation of javascript statements and expressions.
To incorporate the new DomItem wrappers in the Dom, extend the
qqmldomastcreator to also visit the corresponding javascript AST parts.
Like this, it can create the new Dom script elements using its stack:
visit() pushes new elements on the stack while endVisit() collects the
children of the current element from the stack (note: in the reverse
order they were pushed on the stack). The implementation uses two stacks
to avoid having to check every time if the top of the stack is a
QmlStackElement or a ScriptStackElement, but logically both stacks work
as one stack, containing first all QmlStackElements and then all
ScriptStackElements.
In case non-implemented script elements are encountered by
QQmlDomAstCreator, it will disable the script expression
construction and print a warning, instead of asserting and making a lot
of unrelated tests fail. This mechanism can be removed once all script
elements are implemented in the DOM.
Wrap script element pointers into a ScriptElementVariant variant that
can be used to contain any script element.
Added a flag to enable script element construction during DOM
construction.
Task-number: QTBUG-92876
Change-Id: I24b070ca3ff6ce916036842280cf91a21d049f30
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Add a flag that allows to construct the Dom with the QQmlJSScopes
obtained by semantic analysis.
Added a new AST visitor called QQmlDomAstCreatorWithQQmlJSScope.
This visitor synchronizes the qqmldomastcreator and the qqmljsimportvisitor
to construct the Dom and the QQmlJSScope from the AST at the same time.
It mainly does keeping track which subvisitor (dom creator or scope creator)
is active, as one subvisitor may visit AST nodes that the other does not.
Using both visitors at the same time allows to insert the newly-generated
QQmlJSScope::Ptr directly into the correct Dom structure.
The actual implementation of QQmlDomAstCreatorWithQQmlJSScope is in its
visitT and endVisitT methods. Both are called in the AST-visitor-overloads.
Added a benchmark on two big generated qml files to see how fast/slow
does the qqmljsccope semantic analysis runs, compared to the QmlDom
creation runtime.
Task-number: QTBUG-92876
Change-Id: Ia05b6fdd59a637fef9c14b6ab284f4550414f908
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
The loadFile overload (in DomItem, DomEnvironment and DomUnivers) for
different files (in-memory files and files that needs to be loaded from
disk) are either copypasted or just calling the other overload.
Encapsulate the file-related arguments of all loadFile overloads into a
new struct called FileToLoad, such that the copypasted overloads can be
removed. Use the static factory function FileToLoad::fromMemory and
FileToLoad::fromFileSystem to create the FileToLoad struct.
In addition, FileToLoad allows to specify the environment in which a
file should be loaded. Prior this commit, myEnv.loadFile() was creating
a new environment for each loaded file.
Change-Id: I3b6acb681cb77faefdaa447d985bdfbe4f6a9ce2
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Inline objects were missing information about their prototype in their
Dom representation. Add the prototype information and test that the
information really is in the Dom representation.
On the other hand, types defined by inline components cannot be found
using the DomItem::lookup() method, so fix the visitLookup1 method by
removing a broken shortcut and making sure that visitScopeChain also
visits inline component scopes. Also, make sure to not add component
maps multiple times, as else the visit runtime might grow squarely in
the number of inline components.
Task-number: QTBUG-110309
Change-Id: I39d0e408c9fd956b72be4d27f830f7cf0d231520
Reviewed-by: Fabian Kosmale <fabian.kosmale@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>
Import as resolution (i.e. finding a type that was imported with an import as)
was broken in two ways: the shortcut looking for types did look only to types
imported without as, and the normal lookup for symbols declared the ImportScope
as visited (to avoid loops) too early in one case and would skip it.
This was visible in qmlls completions of Controls.
Pick-to: 6.4
Change-Id: Ifc1e777973ddc251bd0685290e8d28bfb025f269
Reviewed-by: Fabian Kosmale <fabian.kosmale@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>
finding the qmlObject from a script value (owner) did fail due to a
bug in filterUp.
Change-Id: I924ae5cb5db0548332594a0b36081da620d661a3
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
fromMultiMapRef had an elWrapper argument that was not really used.
Remove it, and fix QmlDirectory where it was expected to be used,
and it lead to not loading its dependencies.
Change-Id: I40998bc30ee22fd356cabce311f9428550d81b90
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
alias properties are resolved, until they refer to a property of an
imported type, or to a local type.
Alias of aliased properties are not officially supported, but works
in most cases. Set LocallyResolvedAlias::nAliases to non zero if such
an access happens to be able to warn about it.
Fixes: QTBUG-98276
Change-Id: I7c123d0a49d3ae283fc4c06e449f67b1d89e72c9
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This allows us to enable testing on declarative for the module
as a whole and have some sort of test verification for the mean
time, and fix the fails over time.
Pick-to: 6.2 6.3
Task-number: QTBUG-100003
Task-number: QTBUG-100014
Task-number: QTBUG-100016
Task-number: QTBUG-100018
Task-number: QTBUG-100020
Task-number: QTBUG-100021
Task-number: QTBUG-100164
Task-number: QTBUG-100166
Task-number: QTBUG-100167
Task-number: QTBUG-100169
Task-number: QTBUG-100171
Task-number: QTBUG-100173
Task-number: QTBUG-100175
Task-number: QTBUG-100176
Task-number: QTBUG-100177
Task-number: QTBUG-100191
Task-number: QTBUG-100253
Task-number: QTBUG-100254
Task-number: QTBUG-100256
Task-number: QTBUG-100257
Task-number: QTBUG-100258
Change-Id: I85bf1501b94f04853a1ca715e35df0a56041308a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Store imports of urls or directories as QmlUri objects.
Uri and path imports are kept distinguished, relative
path are not resolved before storing the import.
This allows one to always recover the original import.
Relative paths are resolved when imported if required.
Fixes: QTBUG-98275
Change-Id: Id91c739dc95ae9aed0b169a0e503be0658687d1c
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Support to remove a whole path and its sub files/directories.
This is needed by the code model, relying a re-scan of the directory
to removes files is not reliable, as some might have been deleted
in the meantime.
Change-Id: Ia2009bca66a68bd55b3cdf4b07d8323c973ba23a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* fromCode convenince method to load a file having only a memory
representation
* avoid adding implicit directory import if the directory is not
defined.
* add test for this functionality (used by tests in Design Studio)
Change-Id: I4b5604988a64f59b103c0cf5bf323bd5b5b6a711
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
The universe is the cache where loaded files are stored, so to compare
them immediately after load it is useful that the makeCopy method which
creates a deep copy, works also on files in the files without
environment.
Change-Id: I35fc5a769b422d367d07af3374566997dd6b0153
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
- qqmldomitem: main API for generic access to the Dom
- qqmldomtop: represent top level elements: DomEnvironment and Universe
- qqmldomelements: definition of the classes representing Qml
- qqmldomastcreator: instatiate Dom elements from AST
- qqmldomcomments: represent comments in Qml
- qqmldomexternalitems: represent files
- qqmldommoduleindex: represent types in a module
- tst_dom_all: combined test running all dom tests
Change-Id: If2320722bc3e6eaab9669ecec6962d5473184f29
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>