aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmldom/qqmldomelements_p.h
Commit message (Collapse)AuthorAgeFilesLines
* qmlformat: add support for virtual and override keywordsDmitrii Akshintsev12 days1-0/+3
| | | | | | | | | | | | | | | | | | | This patch adds corresponding - VirtualKeywordRegion and OverrideKeywordRegion - isVirtual and isOverride members to Dom::PropertyDefinition adjusts the corresponding PropertyDefinition::writeOut method and introduces a test for the PropertyDefinition structure, currently covering / focusing only on the functionality relevant to the scope of this patch Note: maybe it is a good idea from now on to use newly added tests/auto/qmldom/elements directory for the tests covering qqmldomelements_p.h Task-number: QTBUG-98320 Change-Id: Ifac60d3e52900605778afaf3819a9af46c97954a Reviewed-by: Sami Shalayel <[email protected]>
* DOM: rename dvReferenceField(s) to invokeVisitorOnReference(s)Sami Shalayel2025-11-281-3/+4
| | | | | | | | | | dvReferenceField is not really expressive, rename it to show that it calls the visitor argument on a reference-wrapped version of its reference argument. Task-number: QTBUG-142187 Change-Id: I2ceb90b63e3e63bb4acd9f5d19278eddf1a51a3a Reviewed-by: Semih Yavuz <[email protected]>
* DOM: rename dvWrapField to invokeVisitorOnFieldSami Shalayel2025-11-281-3/+3
| | | | | | | | | dvWrapField is not really expressive, rename it to show that it calls the visitor argument on a field-wrapped version of its field argument. Task-number: QTBUG-142187 Change-Id: Ied467d5fa857934dea069982672f313cd961eb67 Reviewed-by: Semih Yavuz <[email protected]>
* DOM: rename dvValue to invokeVisitorOnValueSami Shalayel2025-11-281-16/+21
| | | | | | | | | dvValue is not really expressive, rename it to show that it calls the visitor argument on a value-wrapped version of its value argument. Task-number: QTBUG-142187 Change-Id: I95e37f72e8596185294ecf92452b6925eb17e606 Reviewed-by: Semih Yavuz <[email protected]>
* DOM: replace dvItem with direct callsSami Shalayel2025-11-281-4/+3
| | | | | | | | | It only calls its first argument with the two other arguments, and does not use this. Remove it and replace all usages with a direct call. Task-number: QTBUG-142187 Change-Id: Icb42f38199803ee5c1fac1636d10430e7385551b Reviewed-by: Semih Yavuz <[email protected]>
* DOM: remove dvItemFieldSami Shalayel2025-11-281-3/+4
| | | | | | | | | | It only calls dvItem(). Replace all usages, and change the second argument to use PathEls::Field(). This helps unclutter the DomItem interface. Task-number: QTBUG-142187 Change-Id: Ieb14e4cf1d542ba257ec3d23b290504148cbf5ed Reviewed-by: Semih Yavuz <[email protected]>
* DOM: remove dvValueFieldSami Shalayel2025-11-281-16/+16
| | | | | | | | | | It only calls dvValue(). Replace all usages, and change the second argument to use PathEls::Field(). This helps unclutter the DomItem interface. Task-number: QTBUG-142187 Change-Id: If32856e115528c1c0f8db737e8c7c78d3912c233 Reviewed-by: Semih Yavuz <[email protected]>
* qmlformat: Add GroupAttributesTogether optionXavier BESSON2025-11-251-2/+3
| | | | | | | | | | | | Equivalent to NormalizeOrder but reorder QML categories without sorting attributes (property definitions, property bindings, methods, signals, enums) Fixes: QTBUG-132060 Change-Id: Ib46ce4bb58ce46e3293d14954b0e363837b64b76 Original-patch-by: Oliver Kuss <[email protected]> Reviewed-by: Semih Yavuz <[email protected]> Reviewed-by: Sami Shalayel <[email protected]>
* Fix coverity warningsUlf Hermann2025-10-081-35/+36
| | | | | | | | | | | | | | | | | | | | | Pass large objects by const ref, small ones by value, and move-only ones by rvalue ref. std::move where necessary, avoid some temporaries, make some locals const. Coverity-Id: 896149 Coverity-Id: 896150 Coverity-Id: 896151 Coverity-Id: 896152 Coverity-Id: 896154 Coverity-Id: 896155 Coverity-Id: 896156 Coverity-Id: 896157 Coverity-Id: 896158 Coverity-Id: 896159 Change-Id: I77ff3c89b52aa377ad64035c0a859e43c24a7c0f Reviewed-by: Fabian Kosmale <[email protected]> Reviewed-by: Sami Shalayel <[email protected]> Reviewed-by: Olivier De Cannière <[email protected]>
* qmlformat: Pass fileLocations to writeRegion for conditional outputSemih Yavuz2025-10-011-1/+1
| | | | | | | | | | | | | | Refactor writeRegion and related calls to accept fileLocations, enabling conditional region output and improved location tracking. Refactor writeOut API to consistently pass DomItem Update writeOutReturnType and Import related methods to accept DomItem, enabling consistent access to FileLocationsTree. Task-number: QTBUG-97796 Change-Id: Ie0883170ba3412e5607bc5e91edb33a2517ff7a1 Reviewed-by: Sami Shalayel <[email protected]>
* QQmlDomAstCreator: enable scriptexpressions for DomCreationOption::DefaultSami Shalayel2025-10-011-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit enables scriptexpressions for DomCreationOptions::Default. QQmlDomAstCreator does not know how to handle certain script expressions, notably JS lists due to the weird way PatternElementList::accept0() is implemented. QQmlDomAstCreatorWithQQmlJSScope uses custom list iteration for types like PatternElementList to make QQmlDomAstCreator support them correctly. Move the custom list iteration functionality out of QQmlDomAstCreatorWithQQmlJSScope so that QQmlDomAstCreator can also benefit from it. Rename QQmlDomAstCreator to QQmlDomAstCreatorBase. The Base version does not do any custom iteration and can be used by QQmlDomAstCreatorWithQQmlJSScope (otherwise you end up doing the custom iteration twice when adding it to QQmlDomAstCreatorBase). Create a new class called QQmlDomAstCreator that inherits from QQmlDomAstCreatorBase and uses the custom list iteration on top of it. Add a test in tst_qmldomitem to make sure that a JS list (that contains parts which are parsed as PatternElementList) is correctly loaded in the DOM. Furthermore, add minimal support for WithStatements in QQmlDomAstCreator to avoid weird test failures because of writeoutchecks in tst_qmlformat_cli::settings that uses a file with a with-statement. Also fix the qmldom tool to correctly output "null" values in JSON format by simplifying DomBase::dump()'s handling of values, and add a test for it. Not outputting "null" leads to invalid JSON generation and a failure in tst_qtquickview_signallistener at build time on android in the CI. Change-Id: I7f9258921d8515eb6b3f9cf5dbb2539ffb980aa7 Reviewed-by: Ulf Hermann <[email protected]>
* qml: silence clang-21 warningsTim Blechmann2025-09-241-1/+2
| | | | | | | | | | | | | clang-21 emits -Wunnecessary-virtual-specifier when having virtual functions in classes declared as `final`. This patch removes these unnecessary `virtual` keywords and delcares the formerly protected function private, as protected does not make sense for final classes. Pick-to: 6.10 Change-Id: Ic6d91de5573f4b325e89bfbc2a9449791ccf94e2 Reviewed-by: Ulf Hermann <[email protected]>
* Add security header for src/qmldomSemih Yavuz2025-09-171-0/+1
| | | | | | | | | | | | There is no security critic code in qmldom. Everything remains at the default "signicant" security level. Exception is one file containing only headers marked "insignificant". QUIP: 23 Fixes: QTBUG-136197 Pick-to: 6.10 6.9 6.8 Change-Id: Ied3f8f9299b8c429e903922b815ee5db8f2d1a9e Reviewed-by: Ulf Hermann <[email protected]>
* QQmlDomElements: remove unused enumSami Shalayel2025-09-151-6/+0
| | | | | | | | Amends 288e03a84d16f43d220a7f7912f1a5cbd3093062 that removed the need for the ParseMode struct, but didn't removed it. Change-Id: Id5b05b1e3c4907c42f822b4722cc721fc39c5125 Reviewed-by: Ulf Hermann <[email protected]>
* Dom : simplify ScriptExpression a bitDmitrii Akshintsev2025-09-081-40/+5
| | | | | | | | | | | | this commit removes dead code. Some of the things were there, but never used. For example, wrapping script expression into object defitinion, however there is no reason/usages for that. Most of the complexity in ScriptExpression::setCode was coming from it. Change-Id: I1e1653a3f052fb138e4ab31cf3c9b375e90842bb Task-number: QTBUG-121933 Reviewed-by: Ulf Hermann <[email protected]> Reviewed-by: Sami Shalayel <[email protected]>
* Dom: remove redundant codeDmitrii Akshintsev2025-09-081-23/+11
| | | | | | | | | | | | | This commit removes the following: - pre and postCode from MethodInfo and ScriptExpression - setCode from MethodInfo and MutableDomItem - some other dead code of MutableDomItem Change-Id: Id5be7626d75c2c469bafd792994c3030c23a5595 Task-number: QTBUG-121518 Task-number: QTBUG-121933 Reviewed-by: Sami Shalayel <[email protected]> Reviewed-by: Ulf Hermann <[email protected]>
* QmlCompiler: Rename sequences' "valueType" to "elementType"Ulf Hermann2025-08-311-3/+3
| | | | | | | | | "valueType" is ambiguous. The prevailing meaning is a type that's passed by value in QML. We mean the type of the list contents (or elements) here. Change-Id: Iaf4c0efe272dc6ec7511d2361e7e5ce475936fba Reviewed-by: Olivier De Cannière <[email protected]>
* qmlformat: customizable semicolonSemih Yavuz2025-05-131-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add semicolon option to qmlformat. While --Always always appends semicolons to the JS statements, --essential removes the semicolons unless it is not safe to rely on ASI once semicolons are removed. Change the way EmptyStatements are handled. Prior to this commit, semicolons following if, for, foreach, while statements without bodies were added to the new line with some indentation. Make the semicolon following no-body items stick to the right paranthesis. If there is a chain of empty statements, write out a single one. [ChangeLog][qmlformat] New option semicolon-rule is added and EmptyStatement formatting behavior has changed. * Added --semicolon-rule option with modes: - --semicolon-rule=always: Always appends semicolons to JS statements. - --semicolon-rule=essential: Removes semicolons unless ASI makes it unsafe. * Changed handling of EmptyStatements: - Semicolons after control structures without a body (e.g., if, for, while) now appear directly after the closing parenthesis, instead of on a new line. - Consecutive empty statements are collapsed into a single semicolon. Fixes: QTBUG-107152 Change-Id: Ic95047a1f0077937d4c1f01328d77a3e6a4f22d6 Reviewed-by: Olivier De Cannière <[email protected]>
* Port away from QPairZhao Yuhang2025-04-121-2/+2
| | | | | | | | QPair is just an alias of std::pair anyway. Task-number: QTBUG-115841 Change-Id: I26fc90adcc775aac9955ad57304af914dc4ed48f Reviewed-by: Ulf Hermann <[email protected]>
* Remove some unneeded destructor declarationsGiuseppe D'Angelo2025-01-201-1/+0
| | | | | | | | They serve no purpose, but interfere with the RO5 and cause Clang to issue -Wdeprecated warnings. Change-Id: I15e30ff5ccb89429ab3ac6c0234388afee4976dd Reviewed-by: Ulf Hermann <[email protected]>
* QQmlDom: fix buildGiuseppe D'Angelo2025-01-201-1/+1
| | | | | | | | | We can't assign into a unique_ptr<T> if T has just been forward-declared. Move the definition of the method out of line. Pick-to: 6.9 6.8 6.5 Change-Id: Ia785d68ccf9d4608169396b8a269fed04d0457a7 Reviewed-by: Ulf Hermann <[email protected]>
* qmldom: make Path methods less deceitfulSami Shalayel2025-01-161-35/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Stop the confusion between Path::field() and Path::Field() and just rename * Path::Field() to Path::fromField() and * Path::field() to Path::withField() Previously, Path::field() would return a new Path with the Field appended to to the current path, while Path::Field() would create a new Path only containing the passed Field, which I think is a bit confusing. Same for the other methods returning copies with components appended to it, and their uppercased counterparts: * Path::empty() * Path::key() * Path::index() * Path::any() * Path::filter() * Path::current() * Path::path() I won't explain here why I believe how Path::empty(), for example, was particularly deceitful with its previous name. Also rename appendComponent to withComponent that actually does not append anything: it returns a copy with the component appended to it. Change-Id: I9120c3827e30330f715e699cbbb88780d2fd358d Reviewed-by: Olivier De Cannière <[email protected]>
* split QmlObject::writeOut into smaller functionsSami Shalayel2024-11-041-0/+15
| | | | | | | | | | | | | | Make the code easier to read by splitting it off into multiple helper methods. Also add some newlines to get some structure. This does not change any existing functionality and only moves code around. Also replace "isRootObject" bool with "component" DomItem, as "component" is only set when "isRootObject" is set: that saves us from passing one redundant bool parameter to the newly introduced helper methods. Change-Id: I4844a7ac5f6af1aba9399d6b7e82d1018f2ac6e2 Reviewed-by: Semih Yavuz <[email protected]>
* qmldom: don't construct unique_ptr on incomplete typesSami Shalayel2024-10-091-2/+2
| | | | | | | | | | | | This should fix the compiler error on XCode 16, by moving the default constuction of std::unique_ptr<BindingValue> into the cpp file, where BindingValue is known. Pick-to: 6.7 6.8 Fixes: QTBUG-129766 Change-Id: I58aae92c28553d0a0bff0c39a352d4f1444bd6aa Reviewed-by: Olivier De Cannière <[email protected]> Reviewed-by: Fabian Kosmale <[email protected]>
* DocumentSymbol add Detail deriving functionalityDmitrii Akshintsev2024-09-241-0/+4
| | | | | | | | | | | | | | | | | | | This commit introduces support for detail field of DocumentSymbol. For Dom::Id it's the .name() For EnumMember is implicit or explicit .value() For QmlObject it's - .idStr if it exists - "root" if .idStr doesnt's exist + object is indeed root - null otherwise For MethodInfo it's a signature, however, because this field is absent from the MethodInfo struct, it needs to be derived here. Dom lacks unified support for querying signatures, esp. of "Singal"-s, hence it's manually handled and a bit messy. As for Binding, detail is constructed using BindingValue Task-number: QTBUG-120002 Change-Id: I96ed605d96caaa778e09a156bed51ac4a4f09b50 Reviewed-by: Sami Shalayel <[email protected]>
* unify MethodInfo::writeOutDmitrii Akshintsev2024-09-241-2/+5
| | | | | | | | | Initial refactoring made by Sami prompted me to wrap and unify writeOut method further :) Task-number: QTBUG-128423 Change-Id: I5fc25828eea13762c510f6a31d078b38cace7415 Reviewed-by: Sami Shalayel <[email protected]>
* dom: add a method to print a method signatureSami Shalayel2024-09-241-0/+4
| | | | | | | | | | | | Add a method to print the method signature, to be used in the Outline feature of qmlls that reuses existing method formatting methods. Extract some common code from the method formatting methods to reuse them in the signature method. Task-number: QTBUG-128423 Change-Id: I88b46da38ce2bed1db173e3cbc97bdf7707f32bf Reviewed-by: Sami Shalayel <[email protected]>
* qmlformat: respect the type annotated signal formSemih Yavuz2024-09-031-1/+5
| | | | | | | | | | | A qml signal can have both a(int x) and a(x: int) form. qmlformat currently converts the type annotated signal form into type prefixed form. It should respect the order. Pick-to: 6.7 6.8 Task-number: QTBUG-128423 Change-Id: I746ea66949abc72e8012974b3fb0a06878950b77 Reviewed-by: Sami Shalayel <[email protected]>
* qmlformat: Do not remove the enum items' default valueSemih Yavuz2024-06-051-2/+9
| | | | | | | | | | | | | | | | Figuring out if the enum item has an explicit value is quite error-prone in dom. Instead, retrieve this information from the parser by checking if the value token exist. Introduce an enum that tracks if enumitem's value is explicitly set or not. Also, fix incorrect region mapping while writing out the enum item dom element. Fixes: QTBUG-125914 Pick-to: 6.8 6.7 6.5 Change-Id: I911621b215de09ff3f18279d83881bc9421080c2 Reviewed-by: Ulf Hermann <[email protected]> Reviewed-by: Sami Shalayel <[email protected]>
* dom: fix semantic scopes in property definitionsSami Shalayel2024-03-211-4/+4
| | | | | | | | | | Make sure that property definitions contain their semantic scope instead of the semantic scope of their binding. Add a test for that and move the semantic scope from MethodInfo and PropertyDefinition into their common base class. Change-Id: I39171922fe5dce3cfb4be7cd2c06448ba6995cc8 Reviewed-by: Ulf Hermann <[email protected]>
* qmlls: find usages of inline components in property definitionsSami Shalayel2024-03-211-0/+8
| | | | | | | | | | | | | | | | | | | | | | | Find usages of QML inline components used in property definitions. Model property type annotations as FieldMemberExpression, so that they match QmlObject types and QML type annotations. Fix the tests that were actually looking for usages of the property type by requesting usages on the space between property type and property name instead of requesting usages of the property itself. Also fix the tests that expected a property definition to start at the 'property' keyword instead of the property name inside the property definition. Also add some tests, and mark them as QEXPECT_FAIL while waiting for the completion of the find usages feature on multiple files. Task-number: QTBUG-114990 Change-Id: I9b8a8ea0db64d42e687fdb703fc8761850eedfe9 Reviewed-by: Fabian Kosmale <[email protected]> Reviewed-by: Ulf Hermann <[email protected]>
* qmlls: find usages of inline components in same fileSami Shalayel2024-03-211-0/+5
| | | | | | | | | | | | | | | | Find usages of QML inline components that are defined in the current file. Model inline component type names as FieldMemberExpression, so that they match QmlObject types and QML type annotations. Adapt the QQmlLSUtils::baseObject method to work on inline components, and adapt an tst_qmlls_modules::findTypeDefinition to only expect the qml component name instead of the entire `component ...` declaration. Task-number: QTBUG-114990 Change-Id: Id3b9bc8f3a9acfd39a4dd8e93ceb7b2bade75cab Reviewed-by: Fabian Kosmale <[email protected]>
* DOM: Allow loading and parsing of .mjs files + minor renameDmitrii Akshintsev2024-03-201-4/+5
| | | | | | | | | | | | This commit introduces a possibility of loading and parsing of .mjs files by DOM environment and universe. (Without DOM construction) This is made possible through the support of DomType::JsFile, employing existing JsFile abstraction and expanding it. Task-number: QTBUG-117849 Change-Id: Ieb47655d87bfb5aa3ede9d3ba4cf84622bf19e06 Reviewed-by: Sami Shalayel <[email protected]> Reviewed-by: Ulf Hermann <[email protected]>
* dom: use implicit QmlComponent copy constructorSami Shalayel2024-03-191-6/+0
| | | | | | | | | | | | Get rid of the buggy QmlComponent copy constructor and copy assignment, and use the implicit ones instead. This commit is a preparation for the find usages of inline component features of qmlls. Task-number: QTBUG-123295 Change-Id: I4fd6fc8fe8dbe0db05ed146802483dfe4edd8060 Reviewed-by: Fabian Kosmale <[email protected]>
* ScriptExpression allow storing .mjs codeDmitrii Akshintsev2024-03-131-1/+5
| | | | | | | | | | | | | Because currently parsing of the code is happening inside the contexts, where "extension" is no longer available, it's helpful to have a enum specifying whether parseModule() or parseScript() should be invoked Task-number: QTBUG-117849 Change-Id: I04216d55330fd841a15690fdea8c2a28394c2182 Reviewed-by: Olivier De Cannière <[email protected]> Reviewed-by: Sami Shalayel <[email protected]> Reviewed-by: Fabian Kosmale <[email protected]>
* QmlFormat | ScriptExpression | extract parse function from ::setCodeDmitrii Akshintsev2024-03-131-0/+19
| | | | | | | | | | | | | | This is a preparotory change before introducing support of the module js. Once .mjs files are supported ScriptExpression should support parsing of the module js (parseModule), which will be incorporated within this parse() function To avoid passing boolean as argument ParseMode Enum helper has been introduced. Task-number: QTBUG-117849 Change-Id: Ie12a8bb1d8420c3500a9d4061452ba669dbc194a Reviewed-by: Sami Shalayel <[email protected]>
* qmldom: make type a FieldMemberExpressionSami Shalayel2024-01-161-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit prepares the Dom to be able to provide correct completions on binding scripts ending with a `.`. In addition to saving qualified types as a string, like `QQ.Item` for example, save them also as a FieldMemberExpression. Do this for QmlObjects, like `QQ.Item {}` for example, and type annotations, like `function f(): QQ.Item {}` for example. This will allow qmlls to suggest completions after `root.` in cases like ``` x: root. SomeQualifiedModule.Item {} ``` for example, or after `QQ.` in cases like ``` (x as QQ.Item) ``` for example. The latter magically makes the asCompletion test work (which was previously QEXPECT_FAIL'd). Prior to this commit, the Dom did not contain enough information to know where exactly the completion gets requested inside of `root.SomeQualifiedModule.Item` and therefore could not suggest any meaningful suggestion. Basically reuses a44f21f19462cc79f82080404515c4322b7728ee to model the nameIdentifiers, a FieldMemberExpression that contains the current type of the QmlObject. Adapt existing tests propertyDefinitionBinding and ignoreNonRelatedTypesForpropertyDefinitionBinding to the changes in the Dom: the qml object type in a binding, for example `Item` in `myBinding: Item {}`, is now part of the QmlObject. It was part of the Binding prior to this commit. Adapt the qmllsutils method to the change in structure. Pick-to: 6.7 Task-number: QTBUG-119839 Change-Id: Ie7bc7692f731a01467392dc1dffdf7e67c4d7c46 Reviewed-by: Ulf Hermann <[email protected]>
* Dom: Initialize QmltypesComponent::m_accessSemanticsUlf Hermann2023-12-181-1/+1
| | | | | | Coverity-Id: 433938 Change-Id: If6124e25b459ffe5a4b0c5e38a50587a04ab7bee Reviewed-by: Fabian Kosmale <[email protected]>
* QmlDom: Pass arguments by const ref, next roundUlf Hermann2023-12-151-96/+109
| | | | | | | | | | | | | | | | | | | | | | | | In some of those places we could move instead, but let's first get the basics right. Coverity-Id: 433005 Coverity-Id: 433004 Coverity-Id: 433003 Coverity-Id: 433001 Coverity-Id: 432999 Coverity-Id: 432998 Coverity-Id: 432997 Coverity-Id: 432996 Coverity-Id: 432995 Coverity-Id: 432993 Coverity-Id: 432992 Coverity-Id: 432991 Coverity-Id: 432989 Coverity-Id: 432988 Change-Id: I90680511aec16fdd05b632dbdfa44d3cac1d09d0 Reviewed-by: Sami Shalayel <[email protected]> Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Fabian Kosmale <[email protected]>
* DOM: Add js code holder to JsFileDmitrii Akshintsev2023-12-071-1/+2
| | | | | | | | | | | | | | This commit introduces 1. A new ScriptExpression Type designated to represent the "whole" file as one ScriptExpression. 2. ScriptExpression member of JsFile class holding the content of the file 3. Corresponding test Change-Id: I61de118f923a1d763f938822c8adf29bd65754b9 Task-number: QTBUG-117849 Reviewed-by: Fabian Kosmale <[email protected]> Reviewed-by: Semih Yavuz <[email protected]>
* QML: Allow JavaScript extension typesUlf Hermann2023-11-161-0/+3
| | | | | | | | | | | | | | | | | | | | | | | This is what we routinely do in the builtins. In particular: - Add the jsroot metatypes to qmltyperegistrar so that it can validate the JavaScript types - Add a special class info "ExtensionIsJavaScript" - Pass this through metatypes and qmltyperegistrar. - Treat it like an extension type in QQmlJSScope but give it its own name. - Ignore it in qmltc. We cannot express JavaScript extensions in C++. Now qmltyperegistrar has to deal with name conflicts between JavaScript and C++ types. It does so by always preferring the C++ type if available. The new class info is private and we don't want to surprisingly inject JavaScript types into people's QML modules. For our own types we shall make sure to avoid name conflicts. There is one prominent name conflict, 'Qt', which we really want to be resolved towards the C++ side. Change-Id: Iac224f4b0df2d6398fba0124f0b52d8ddfccace1 Reviewed-by: Fabian Kosmale <[email protected]> Reviewed-by: Semih Yavuz <[email protected]>
* qmldom: Dom representation for dot separated identifiersSemih Yavuz2023-10-311-0/+4
| | | | | | | | | | | | | | | | | We were keeping attached or grouped property names in Dom::Binding as a single string in form of "id.property" or "AttachedObj.property" which was not suitable to use in helper functions in qmlls utils. Add a new field in Dom::Binding to represent bindingIdentifier in the form of ScriptBinaryExpression<ScriptIdentifier, ScriptIdentifier> to for grouped/attached properties or ScriptIdentifier for the normal binding names which doesn't contain a dot.. resolveExpressionType can find the same scope more than one due to the new fiels, do not add location results if they were already added. Task-number: QTBUG-117380 Change-Id: Iccaf74095356fa181d1936a48e92316069e50051 Reviewed-by: Fabian Kosmale <[email protected]>
* qmlls: autocompletion for singletons, attached types, enumsSami Shalayel2023-10-111-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add static helpers enumerationCompletion and enumerationValueCompletion to provide completion for enumerations types and enumeration values inside of script identifier expressions. Extend the LocalSymbolsType enum to be able to query Singleton types and AttachedTypes Implement filteredImportedNames to be able to filter imported names by singleton-ity or attached-ity for example. Add a semantic scope to QmltypesComponent. They are very similar to QmlComponents, except that those were created from a .qmltypes file instead of a .qml file. This allows to query QQmlJSScope's from imported types, for example when searching for Singletons or Attached types. Also, this is 'for free' because the qqmldomtypesreader already has a semantic scope when it constructs the QmltypesComponent. Also add the semantic scope to the QmlObjects inside the QmltypesComponent. Fix Export::isSingleton member: Exports obtained from qmltypes file did not set this member value. Extend QQmlLSUtils::resolveIdentifierExpressionType() to be able to resolve enums, singleton types and attached types (for attached properties). Implement completion support in qmlls for enumerator names and values, and Singleton types using the improved resolveIdentifierExpressionType(). Also autocomplete attached types, and make a difference between Constructors that represent constructable types and Classes which represent all kind of types, including attached types. Autocompletion for properties and co inside the attached types is not supported yet. Extend the QQmlJSTypeResolver to be able to access all imported types, needed for searching singletons or attached types for example, and remove the duplicated DOM methods (duplicated in the sense that they do the same thing as the QQmlJSTypeResolver). Task-number: QTBUG-116899 Change-Id: Ibadeb72e2250a6530c42b9d4a7f25105ab6ea31f Reviewed-by: Ulf Hermann <[email protected]> Reviewed-by: Qt CI Bot <[email protected]>
* qmldom: Use QQmlJSScope::ConstPtr rather than optional<QQmlJSScope::Ptr>Ulf Hermann2023-09-181-10/+10
| | | | | | | | | | | | | | | We never want a non-const QQmlJSScope in qmldom. Furthermore, QQmlJSScope::ConstPtr already has an "invalid" state. It can be null. Wrapping it in std::optional doesn't add anything meaningful. Besides simplifying and hardening the code, this also works around the difficulties coverity seems to have with std::optional. Coverity-Id: 417089 Coverity-Id: 417091 Change-Id: Ifd99e3d54a90affb3ec6889198e65030148b6c4c Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Sami Shalayel <[email protected]>
* qmldom: Fix coverity warningsUlf Hermann2023-09-151-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | - initialize members - iterate const containers, and use const refs for elements - pass values by reference - provide move constructors Coverity-Id: 417104 Coverity-Id: 417102 Coverity-Id: 417101 Coverity-Id: 417100 Coverity-Id: 417099 Coverity-Id: 417098 Coverity-Id: 417097 Coverity-Id: 417096 Coverity-Id: 417095 Coverity-Id: 417094 Coverity-Id: 417093 Coverity-Id: 417092 Coverity-Id: 417090 Coverity-Id: 417088 Coverity-Id: 417087 Coverity-Id: 417086 Coverity-Id: 417085 Change-Id: I624ed4e71c49c3eebced9483dd73554dbdcb981b Reviewed-by: Sami Shalayel <[email protected]>
* QmlDom: Add const-correctnessUlf Hermann2023-09-151-74/+66
| | | | | | | | | | We almost never want non-const DomItems anywhere. There is exactly one exception: From a MutableDomItem we need to poke into the internals of the respective DomItem and const_cast them. However, MutableDomItem is to be handled with care anyway. Change-Id: I826f0669c049462beec9ad71dccb39c5191a1d3f Reviewed-by: Sami Shalayel <[email protected]>
* qmlformat: correctly handle rest operator in method parametersSemih Yavuz2023-09-121-0/+1
| | | | | | | | | | | | Method parameter can have the rest operator leading to an identifier or a binding element. So far this is not represented in MethodParamter dom item. Initialize a new field "isRestOperator" and populate that information when creating method parameter dom item. Task-number: QTBUG-116392 Pick-to: 6.6 6.5 Change-Id: I701390b8ec1e323628072d43796c40499c4d56e1 Reviewed-by: Sami Shalayel <[email protected]>
* Replace signal name manipulations with QQmlSignalNamesSami Shalayel2023-08-151-3/+2
| | | | | | | | | | | | | | | Remove custom implementations found in qqmljs* and use the static helper methods from qqmlsignalnames_p.h instead. This sometimes requires to move some code around to avoid bugs with property that do not have letters in their name. Add a warning in the JS implementation of the SignalSpy.qml that the used heuristic might fail on certain signal names. Add tests in in tst_qqmllanguage to see if the property change handlers work correctly for weird names. Change-Id: I4dc73c34df7f77f529511fa04ab5fcc5385b59fc Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Fabian Kosmale <[email protected]>
* qmlformat: Handle pragma directive correctlySemih Yavuz2023-06-091-1/+6
| | | | | | | | | | | | | Dom representation for pragma used to be created by leaving out pragma directive value list. That caused qmlformat to remove the corresponding list. Fix it by including value list while creating dom for pragma. Fixes: QTBUG-114364 Pick-to: 6.5 6.6 Change-Id: I87f6e324452f196c147f5606f15c01e22caa39a5 Reviewed-by: Sami Shalayel <[email protected]>
* qmlls: find usages of methodsSami Shalayel2023-06-051-1/+1
| | | | | | | | | Implement find usages for methods in qmlls. Task-number: QTBUG-111415 Change-Id: I7e0aa55ca326bfd8d15d1553607e6c551b713aab Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Fabian Kosmale <[email protected]>