diff options
author | Sami Shalayel <sami.shalayel@qt.io> | 2023-09-11 15:50:26 +0200 |
---|---|---|
committer | Sami Shalayel <sami.shalayel@qt.io> | 2023-09-26 20:46:38 +0200 |
commit | 8237998bf4e22571a2dd6d80ea897171fed762af (patch) | |
tree | 61ad1e5e5e803184463aa53b77b71849415f32fe /tests/auto/qml/qmlformat | |
parent | e3ffea6d42191e5b2d00aab9cfbd628913af4754 (diff) |
qmlls: autocomplete scriptexpressions
Add some support for autocompletion in script expressions.
Add missing getter in QQmlJSScope to be able to list js identifiers of a
semantic scope in qmlls.
Add static helper methods XXXCompletion that collect some information
JavaScript identifiers, methods and properties made available from a
QQmlJSScope. Another helper method collectFromAllJavaScriptParents
can collect the results of a XXXCompletion method through all
JavaScript scopes of a DomItem.
Avoid code duplication and remove the implementation searching for
methods in the DOM: instead, use the already existing implementation in
QQmlJSScope::methods.
Finally, add the method scriptIdentifierCompletion() that computes all
autocompletions for a scriptIdentifier, that is called in
QQmlLSUtils::completions and in the tests.
Fix some tests to flag property as properties, inside of "Fields", and
add extra tests to see if the newly implemented completions work.
Cleanup QQmlLSUtils::completions() by extracting its code into static
helper methods reachableTypes() and reachableMethods(), replace two
enums by one QFlag as both enums were always used together.
Extend reachableTypes() to find also non-object types, like the value
types int, date, for example. This is later used for property type or
function parameter type completion, for example.
Make QQmlLSUtils::completions() more readable by returning early and
by separating the completion by QML language constructs, instead of
grouping multiple unrelated constructs together. This became possible
thanks to the new static helpers mentioned above.
Suppress completion inside of function parameter definitions and inside
of id definitions.
Add some tests for property type completion and pragma completion with
QEXPECT_FAIL, those features will be implemented in a later commit.
Add 'import' completion for empty files + a test that test completions
on an empty file.
Fix tests for colon-checking: some completions insert
'<propertyName>: ' for properties, e.g. for bindings, and some do not,
e.g. for property usage in JS expressions.
Also fix the test in tst_qmlls_modules to expect methods instead of
functions.
Add exception in tst_qmlformat for the empty qml file used to test if
completions work in a completely empty file.
Task-number: QTBUG-116899
Change-Id: I63de62c71d63aa4ab62ca6d83c6be157f4e6f96c
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlformat')
-rw-r--r-- | tests/auto/qml/qmlformat/tst_qmlformat.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlformat/tst_qmlformat.cpp b/tests/auto/qml/qmlformat/tst_qmlformat.cpp index a763e2b5cc..c5c51f178c 100644 --- a/tests/auto/qml/qmlformat/tst_qmlformat.cpp +++ b/tests/auto/qml/qmlformat/tst_qmlformat.cpp @@ -129,6 +129,7 @@ void TestQmlformat::initTestCase() m_invalidFiles << "tests/auto/qml/qqmllanguage/data/nullishCoalescing_RHS_Or.qml"; m_invalidFiles << "tests/auto/qml/qqmllanguage/data/typeAnnotations.2.qml"; m_invalidFiles << "tests/auto/qml/qqmlparser/data/disallowedtypeannotations/qmlnestedfunction.qml"; + m_invalidFiles << "tests/auto/qmlls/utils/data/emptyFile.qml"; // Files that get changed: // rewrite of import "bla/bla/.." to import "bla" |