aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/parser
diff options
context:
space:
mode:
authorSami Shalayel <sami.shalayel@qt.io>2023-09-11 15:50:26 +0200
committerSami Shalayel <sami.shalayel@qt.io>2023-09-26 20:46:38 +0200
commit8237998bf4e22571a2dd6d80ea897171fed762af (patch)
tree61ad1e5e5e803184463aa53b77b71849415f32fe /src/qml/parser
parente3ffea6d42191e5b2d00aab9cfbd628913af4754 (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 'src/qml/parser')
0 files changed, 0 insertions, 0 deletions