aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qmldom
Commit message (Collapse)AuthorAgeFilesLines
* Disable failing declarative tests on AndroidAssam Boudjelthia2022-02-101-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. 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> (cherry picked from commit f22d884faff5f68230981fc191527c67aeb8a18f) Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmldom: remove pathFawzi Mohamed2021-12-091-3/+18
| | | | | | | | | | 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>
* qmldom: avoid merging declaration and binding when not supportedFawzi Mohamed2021-11-263-0/+50
| | | | | | | | | | | | currently there are several limitations to merging binding and declaration: * array bindings can be merged only if the type is parametric * default binding supports only script expressions * object bindings cannot be merged with a parametric types Keep these grammar limitations in account when reformatting. Change-Id: Ifc9cd65777544f131daab71d0cb9cdc324e2f53f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmldom: follow the QML code conventions when reformattingFawzi Mohamed2021-11-097-14/+61
| | | | | | | | | Reorder the attributes according to the sequence defined in the QML Coding Conventions. Change-Id: I4f71c51e86c33100ce2d9622cf7ed6e03d672453 Pick-to: 6.2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmldom: improve handling of memory qmldocuments without pathsFawzi Mohamed2021-10-071-0/+7
| | | | | | | | | | | | * 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>
* qmldom: correctly handle comma expression when reformattingFawzi Mohamed2021-09-172-0/+2
| | | | | Change-Id: Ia036c7531bc465f3c5ac151994c4c4247223efa2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* fix handling of arrow functionsFawzi Mohamed2021-09-173-0/+18
| | | | | | | | | * correctly set lbraceToken in all cases (there was a wrong index in the grammar) * avoid semicolon for "virtual" return statements of arrow functions Change-Id: I2966558c835fdc74ecfb4d31e001a22dda385912 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmldom: improve function comment handlingFawzi Mohamed2021-09-093-0/+14
| | | | | | | | | set regions for paren and braces in function declarations, so that comments can be prepended/appeded to them. Change-Id: I06638ef26e8715aa0b3a268b8d3d6288b42b52b3 Pick-to: 6.2 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmldom: DomItem::makeCopy also for elements of the universeFawzi Mohamed2021-08-271-0/+13
| | | | | | | | | | 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>
* replace devtools library with QtQmlFawzi Mohamed2021-07-027-7/+0
| | | | | | | | | | | | | | | qmldevtools was needed when building with qmake, and to avoid circular dependencies in the tools (before making QtQml minimal). Now it can be avoided. This change will make qmldom, qmlformat, qmlimportscanner and qmllint depend on QtQml (just like the other Qml tools) and not be always completely static (qmldevtools was always a static library, QtQml normally isn't). Change-Id: Idfa0a70e51f0d4999fb9753121c6c228ae69c9bb Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* qmldom: writeOut, write reformatted QmlFawzi Mohamed2021-06-0524-0/+807
| | | | | | | | | | | | Adding writeOut: support for reformatted Qml - linewriter: write line by line with caching, callbacks, SourceLoaction updating - outwriter: write to line writer, and keep track of updated file locations and reformatted ScriptExpressions - reformatter: reformat javascript Change-Id: I4bdc393fb2d9b5a3db944a850719c24ef8726d15 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmldom: compare and dump to file, domtoolFawzi Mohamed2021-06-057-1/+231
| | | | | | | | | | | * qqmldomfieldfilter: ignore fields or types in dump or comparison * qqmldomcompare: compare DomItem * qqmldomfilewriter: safely write to a file (keep backups, avoid overwrite before success is confirmed, avoid overwrite if equal) * qmldomtool: command line tool to dump dom Change-Id: If4fbff7dff70d3a780293ac8b458f674e8f91591 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmldom: representation and load of Qml FilesFawzi Mohamed2021-06-059-152/+706
| | | | | | | | | | | | | | - 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>
* qmldom: improve PathFawzi Mohamed2021-05-311-2/+10
| | | | | | | | | | | | | | | * PathEls::PathComponent allows heap free handling of a single path component, so make it more public and allow the creation and append to a Path using it. * ensure initialization * use QString in PathEls::Key (will need an extra allocation in fromString, but spares it on key lookups) * make operator bool explicit (it is dangerous to potentially convert to int silently) * consider top==env==universe simplifying path comparisons Change-Id: I293674366a260b61cb7f5a65912714022aff218a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmldom: Improve basic infrastructureFawzi Mohamed2021-04-1410-300/+433
| | | | | | | | | | | | | | | * introduce function_ref to represent a reference to a function and use it consistently (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0792r5.html) * restricted errormessage levels to those of QtMsgType * made path iterate on its segments * made path methods mirror the DomItem methods, so that path construction and access are similar * AttachedInfo to keep the location information * SourceLocation::combine Change-Id: I152c4cc2c601e867f205a4f4b7b3f24884d60ad9 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove the qmake project filesFabian Kosmale2021-01-155-106/+0
| | | | | | | | | Remove all qmake project files, except for examples which are used to test that qmake continues to work. Change-Id: Ic4abb72dc2dcd75df7a797c56056b6b3c5fe62ac Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* CMake: Regenerate projects using pro2cmake one last timeAlexandru Croitor2020-12-109-17/+12
| | | | | | | | | And fix up some incorrect qmake project files Pick-to: 6.0 Change-Id: Ia6d27ac68195635021fe7c4a5f06386a60f3f323 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* qmldom: DomItem and common APIFawzi Mohamed2020-12-035-0/+232
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit adds the main API of the Dom model: The idea of the Dom Model is to expose a simplified an uniform model, while keeping typed objects (as one is used in C++, and ideally using the modern C++ approach with containers, and avoiding manual memory management). In particular this approach avoids reducing everything to an untyped model. The central object in this is the DomItem, it is a value type that keeps a pointer to the actual element. A non empty DomItem always keeps some context (a canonicalPath) and one can explore its containers and its contents. Non existing or missing values simply translate to empty DomItems and one does not need to check at each step for invalid things. See the DomItem documentation for more information. The as() ad ownerAs() templates let one cast back the DomItem to the underlying elements. To expose an element with minimal effort one has to mainly implement the method iterateDirectSubpaths(), and iterate through all elements contained in that element (see the documentation of DomBase for more details). Containers, simple data and references can be wrapped in DomItem elements just when accessed, so the underlying C++ object can use the usual containers/datatypes. A good model should not just be easy to browse, reference and extend with new elements, it should also have a clear parallelizazion/ multithreading policy. This is less relevant for a single pass compiler, but for is relevannt for a code model. The fact that the current code model now somehow works only from the GUI thread show the importance of a clear policy when multiple people can contribute. In the Dom model there is the following idea: - During build time pointers to the elements can change (MutableDomItem should be used) - Access to sub elements normally has no locks, they should be either accessed by a single thread or immutable. - OwningItem are the unit of multithread safe updates, the have a mutex and protect the parts that need protection - A DomEnvironment can refer to a parent Environment, perform several changes (in a separate thread), and commit them all at once (in a sparate commit). This commit contains all the main API, and tests for it. The bulk of the concrete element will be in followup patches. Task-number: QTBUG-74840 Change-Id: I9e14e8560e3b4aa3268a733fed37e9090c18e3ab Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmldom: Add Path and ErrorMessage to DomFawzi Mohamed2020-12-018-0/+409
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adds more groundwork for the Dom library. QQml::Dom::Path represents a path in the Dom model. It goes from an element of the Dom model (DomItem) to another. It can be created either from a string, with the path static functions or by modifying an existing path Path qmlFilePath = Path::fromString(u"$env.qmlFilesByPath[\"/path/to/file\"]"); Path imports = qmlFilePath.subField(u"imports") Path currentComponentImports = Path::current(u"component") .subField(u"imports"); This is a way to refer to elements in the Dom models that is not dependent from the source location, and thus can be used also be used in visual tools. A Path is quite stable toward reallocations or changes in the Dom model, and accessing it is safe even when "dangling", thus it is a good long term reference to an element in the Dom model. In this commit the element of the Dom Model (DomItem) is represented just by a stub object, it will be added in a subsequent commit. This commit also introduces the ErrorMessage object. ErrorMessage is an object used to represent error, warning and other messages in the Dom model. Errors are grouped by tags (ErrorGroups). ErrorMessages might have a unique identifying string (using a number in a base library that cannot have a list of all possible errors does not work well. ErrorMessages should be localized and *can* be pre-registered, but do not have to be. ErrorMessages can be associated with a QQml::Dom::Path, a file and a Sourcelocation. The path (if present) might allows one to show errors also in more visual tools. Task-number: QTBUG-74840 Change-Id: I77fb4b78e15ba3674d74937106d40dba4076cedc Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmldom: Start of the Qml Dom libraryFawzi Mohamed2020-11-235-0/+168
The goal of the Dom library is to provide a nicer to use basis for the Qml Code model, to be used by the various QML tools, the designer and the new compiler. This commit just adds some common utilities used by the library, to output strings to a Sink, i.e. a function<void(QStringView). This allows writing without allocations of extra temporary strings. The more interesting parts are added in subsequent commits Task-number: QTBUG-74840 Change-Id: I8fa43d5b622f59c8761b2469551127c0508c23c3 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>