| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add declarationKindToken location in the pattern element node. This is
required for semantic highlighting to highlight the type correctly
within iteration statements.
Add type identifier region for the declaration kind token in the
for-declaration construct.
Fixes: QTBUG-124677
Task-number: QTBUG-120000
Change-Id: I02520bdc6f1b9dfc5d47078cd7e5e8d2f40bf382
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
|
|
|
|
|
|
|
|
|
|
|
|
| |
Otherwise, we can't find the source location of the binding identifier
in object destructuring syntax. For example, const {x: y = 34} = obj
case, we now can get the location of y which is required for semantic
highlighting.
Task-number: QTBUG-120000
Change-Id: If8d78e7604179e9a13f62e3fd9ccdb2b3aefd6cd
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add missing identifier token location in the grammar file. Implement the
missing file location regions for Pragma dom element. Those regions are
the way to get source location of the corresponding dom element in the
Dom API. It is needed in semantic highlighting implementation.
Adding new region breaks a few of the pragma completions tests since it
changes the closest item found and this makes the assumption that colon
region exist wrong . Fix it by passing the Pragma element instead of the
subelements of it to insidePragmaCompletion function. This guarantees that we
find the ColonTokenRegion in the current item.
Task-number: QTBUG-123775
Task-number: QTBUG-120000
Change-Id: I2759412810ce125d6ee36bb0d70509a859667266
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
|
|
|
|
|
|
|
| |
Rename the properties to control recovery to use the canonical namings.
Change-Id: I7f05a3ad95baa54d7a374391ae2bfb1d48db4789
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add a recovery mode to the parser to accept bindings that are not
completely written out, and create an empty statement for that. This
mode is called enableIncompleteBindings and is only enabled for qmlls.
Also adapt qqmldomastcreator to those empty statements, and qmllsutils.
Pick-to: 6.7
Fixes: QTBUG-120169
Task-number: QTBUG-92876
Change-Id: Ic24cbb61e3be08368027371e377bf75ce87fafb1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add the equal token sourcelocation into a ScriptPattern. This is
somewhat cumbersome because the parser has no direct access to it.
Instead, create a new ExpressionNode type called InitializerExpression:
it contains an ExpressionNode and an equaltoken, and is populated in the
parser for Initializer and Initializer_In rules. It also implements some
pure virtual methods to not be abstract, and has its own
Kind_InitializerExpression.
The PatternElement constructor extracts the location of the equaltoken
from the InitializerExpression in its constructor, and saves it in its
new member equaltoken.
Later on, the Dom constructor will be able to add the location of the
equal token to the Dom, such that qmlls's completion can decide whether
or not completion is required in variable declaration statements.
With this commit, qmlls will provide completions only after the above
mentioned equal token. The explanation is in a comment in qqmllsutils,
but the rough idea is that everything before the '=' is a variable name
(so it should not be in use yet, to avoid shadowing and confusing QML
programs) and that everything behind a '=' is a default value that can
be any arbitrary expression in JS. This default value can be a method
name, a property name, etc, so provide completion at this place.
Also takes care of completions inside of deconstructions nested inside
variable declarations.
Task-number: QTBUG-117445
Change-Id: Ie58ffda4de9636796a9a690537affef85ede398d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
For the completion in qmlls, users usually expect to see a list of
completions after typing in a T_DOT ("."). Sadly, this T_DOT usually
makes the QML code invalid or ambiguous, such that the parser aborts
parsing.
For qmlls, this is quite bad: no completions can be proposed if the AST
cannot be computed. Therefore, this commit tries to make the parser a
little bit more resistant to missing T_IDENTIFIER behind T_DOT.
Add a yyprevtoken field in the parser to keep track of what was the
last successfully parsed token, and update it with yytoken before yytoken
changes.
Extract the pushTokenWithEmptyLocation() logic from the automatic
semicolon inserting code, and reuse it for the automatic insertion of
identifiers after dots.
Add some tests in tst_qmlls_utils and adapt the qmlls completion code to
work with missing right hand sides (RHS) of dotted expression
`a.b`. Create a new file missingRHS.qml because yyy.qml does not seem to
stop growing.
The fix of this commit does not take care of all possible cases: when
T_DOT is followed by an T_IDENTIFIER, then no T_IDENTIFIER is inserted
even if the parsing fails afterwards. This happens when a JS
statement is behind a T_DOT without identifier, for example. Add tests
for that too, QEXPECT_FAIL them and put them in a separate file
missingRHS.parserfail.qml. They need to be in a separate file because no
completions can be obtained when the parser fails, and that affects all
the completions of the entire file. This special file
missingRHS.parserfail.qml also needs to be ignored by tst_qmlformat.
Task-number: QTBUG-115836
Change-Id: If307430131a7df25ae9bd4ea0393d47c0641c8d3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add a RecoveryOption enum that can be passed to QmlFile's constructor to
enable or disable recovery.
Extend DomCreationOption by another value WithRecovery, such that
users of the Dom can enable recovery via the FileToLoad argument of the
Dom's file to load.
Enable the recovery in the qqmlcodemodel for qmlls.
The actual recovery is implemented in a separate commit in the relation
chain.
Task-number: QTBUG-115836
Change-Id: Icb6b115cf667c77c596fa335bc37bb12bf680cce
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Typing `someProperty.x` would propose methods and properties that
do not exist in someProperty in qmlls.
Add the operator sourcelocation inside the BinaryExpression so that qmlls
can distinguish if currently working on the left or right hand side of
the binary expression.
Also fix the resolveExpressionType call to not use the last bit of the
qualified identifier: in `console.l`, only resolve up to `console` and
ignore the `l` bit that might not have been spelled out completely.
Previously, the resolution step would fail because of the `l` and no
completion would get generated.
Task-number: QTBUG-117445
Change-Id: I5929d7153d5b9f5104efd1b88d24d76e0d7a514a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
|
|
|
|
|
|
|
|
| |
Also add test and update documentation
Task-number: QTBUG-114528
Change-Id: I7baa3a3268c4ccd2efe5bd8be7d790e909c430c6
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Make QQmlLSUtils::itemsFromTextLocation smarter: it differentiates now
between property definitions and bindings.
Example:
For this property
```
property var somePropertyDef: Item { property var propertyDef: 42; }
```
The ranges of the filelocations are as follows:
somePropertyDef FileLocations range:
|------------------------------------------------------------------|
propertyDef FileLocations range: |-----------------------------|
binding FileLocations range: |----------------|
The previous behavior of QQmlLSUtils::itemsFromTextLocation could
not distinguish between a binding being alone or a binding being in
a property definition, and would return the binding.
The new implementation recognizes when a binding is inside a property
definition, and returns this propertydefinition if the current text
position is before the ':'-token. It even can choose the right property
definition when there are nested ones, like in the example above with
somePropertyDef and propertyDef.
This means that qmlls can now differentiate between being inside a
property definition name and the binding of the property definition.
This allows to suppress completions inside of property definition
names. Completion inside the binding of a property definition are
still handled by the code for normal bindings.
Fixes: QTBUG-117440
Change-Id: If0592ccadd8b1e3e9efbf4952c8044c40854202b
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
To be able to decide how a pragma is completed, one needs to know if we
are before or after the ':', for example in
'pragma NativeMethodehavior: AcceptThisObject', one needs to know if we
are completing the pragma names or the pragma values.
For this, add a sourcelocation for the colon in AST::UiPragma in the
parser, and pass it on in the FileLocations so the sourcelocation of the
colon, when existing, can be accessed from the DomItem.
Once the position of the colon is known, the names or values for the
pragmas can be completed.
To easily obtain the position of the colon of a DomItem, move some code
from the Binding completion into a static helper to reuse it for
pragmas.
Also fix some typos in the warning messages about invalid pragmas in
qqmljsimportvisitor.
Task-number: QTBUG-116899
Change-Id: Ib20bb6aa50e9b8dc5830f426d0ca9719693c0a15
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously, it was hardcoding a StringLiteralPropertyName for
a BindingIdentifier. This does not make sense because
BindingIdentifier cannot be string literals, they have to be
identifiers.
Also, this is problematic for deconstruction, e.g.:
```
function f(something) {
let { x = 'x' } = something; // (1)
return x;
}
```
In (1), you cannot differentiate between the property
name x and the string literal x, because the parser creates a
string literal with value 'x' for both.
Notably, qmlls cannot differentiate between a 'find usages' on the
first x that is supposed to find the x in the return statement, and
the second "x" that is supposed to find no usages because it is a string
literal.
Same happens also for deconstruction in method parameters.
Add tests for qmlls for deconstruction in let-statements, and method
parameters. Make sure qmlformat ignores this qmlfile as it cannot
format deconstruction yet.
Task-number: QTBUG-100084
Change-Id: Ib7df974437e442dc0bfca75381c773c4d30b11bb
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Instead of highlighting the base type of the inline component, highlight
the name of the inline component, e.g. highlight 'C' in
```
component C: Item {}
```
instead of 'Item'.
This requires changing QQmlLSUtils::findTypeDefinitionOf's signature to
return a QQmlLSUtilsLocation instead of a DomItem.
QQmlLSUtils::findDefinitionOf already returns a QQmlLSUtilsLocation.
Also, the QQmlJS::UiInlineComponent parser class did not know about its
identifier token. Add it, so the corresponding DomItem knows where its
identifier lies.
Fix the tests that finds definitions of inline components by removing
the QEXPECT_FAIL and adjusting the column numbers. Also simplify the test
by removing the "name" that is not related to the actual test.
Fix other failing tests by setting their QEXPECT_FAIL at the right
place (they fail earlier because of this change, when looking for the
type definition of int for example).
Change-Id: I00b2f73c2357b7e7fb74619bbc7b948e67619420
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The following issues are fixed:
- [1]Incorrect detection of the property name as a string literal and
thus writing out them with quotation marks
- [2] Duplication of property name when a scoped variable is used as
property key
- [3] Writing out additional brackets during deconstruction
- [4] Incorrect formatting when a default is assigned to a lhs variable
like [a = 24, b] = array
- [5] Automatic addition of "" characters into the object keys
- [6] Automatic addition of assignment operator, instead only add it
when there is a pending initializer
Also, add the colon token location which was missing in the pattern
property rules. Remove it from a couple of rules that was giving
incorrect result. We require the location information of the colon token
to be correct when formatting.
A few of tst_qmlformat and tst_reformatter tests are adapted to the
above mentioned changes [1], [2], [5].
[ChangeLog][qmlformat][Important Behavior Changes] qmlformat will no
longer add "" characters automatically in the object keys unless the
object key is actually a string literal. Also, using a scoped variable
as the property key will no longer result in the duplication of the
property name.
Pick-to: 6.6
Fixes: QTBUG-108275
Fixes: QTBUG-114839
Change-Id: I272d41d13df34ff5877f3efebe43c80255dd7c2b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
|
|
|
|
|
|
|
|
|
|
|
| |
Remove the forward declarations of TypeArgument(List) and its uses.
This amends e89a06753c772bd96b3299e03b2f7ad78ffc9fb9 that removed
TypeArgument(List)'s definition while leaving its forward declarations
and uses around.
Change-Id: I1a3e27ce18611beaf84b7c59e01a622f9e7f2477
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
|
|
|
|
|
|
|
|
|
| |
This will be needed in follow-up changes.
Task-number: QTBUG-94807
Change-Id: I6243ea31290251c30dd0aceaae878568bc1c0525
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously all list types used as arguments or return types for methods
had to be looked up via the imports. However, builtin types are not part
of the imports at run time. Therefore, recognize list types already
early on, when generating the IR. This is the same way we do it for
property types and it allows us to easily identify lists of builtins.
Pick-to: 6.5
Fixes: QTBUG-109147
Change-Id: I91fa9c8fc99c1e0155cc5db5faddd928ca7fabbc
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|
|
|
|
|
|
|
|
|
|
| |
There can in fact only be one type argument, and we don't need a
finish() method. In fact the finish() method didn't return the type
argument at all.
Task-number: QTBUG-107171
Change-Id: Ifb7d85ca42a38d37da71b6453b458c7ec10cd64d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Introduces support for line by line indentation and reformatting
This is done with a simplified restartable lexer and parser.
* qqmldomscanner: a tokenizer for a single line, built on the top of
the normal lexer. One of the key property is that the state can be
stored and restarted.
Thus after an edit, re-indenting or split of a line one can restart
the lexer with the state at the end of the previous line, and
re-evaluate from there on.
* qqmlcodeformatter: contains a stack based parser that is used for
syntax highlighting and indentation. The state is a stack of integers,
and along with it also the indent level is stored
and the accepted syntax is a superset of the grammar (typically
repetitions are allowed and order is more permissive).
This builds on the top of the scanner, and also allows restarts.
The public interface focuses on having the stored state of the parser
and lexer, and being able to update it after a line of text, or give
the correct indentation for a line.
* qqmldomindentinglinewriter: has a LineWriter that uses the
CodeFormatter internally to re-indent every line.
Change-Id: Ifce9ed14ecd157bec65fb740b2c7ee8a5fc0729a
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
"static" is a keyword in the context of JS classes, no matter how deeply
nested. Therefore, keep track of the nesting level.
Switching the keywordiness of "static" off during method definition
parsing makes no sense as the standard doesn't mention such a thing.
Method bodies are strict code where you cannot use "static" as
identifier. Methods and properties can be called "static" no matter if
static is a keyword or not.
Pick-to: 6.4
Fixes: QTBUG-96631
Change-Id: Ia09e52fe2ae72721fe1c8a9b95899a31095db988
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The Qml lexer was not restartable, make it so that a line can be
parsed independently from another.
This is a requirement for efficient indenting and highlighting.
Old approach in creator used a separate finite state machien "scanner",
now it is possible to use the same lexer as the parser.
One can "checkpoint" every few lines, and restart the process form the
line above the change, and stop when the status is the same as before.
Change-Id: I72a13a767ac7adfe103e56e60902e61c88e4fd82
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
As detected in Creator by hjk:
Detaching the rawString_stack alone shows up at 0.85% when loading
Creator inside Creator. One write access is actually used from
qmljs.g:593, so making the whole function const would need more work.
Take a short cut and replace the unneeded reference counted container
with a non-reference counted one.
Change-Id: I480d539f532f9dbfbb0ddef986a7177dfca9b173
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
|
|
|
|
|
|
|
|
| |
[ChangeLog][QML] It is now possible to use negative integers as values
for QML enum declarations.
Change-Id: I321ad45ab41d5ef23d37d202a384d40e2e1e239d
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|
|
|
|
|
|
|
| |
this adds possibility for qmlls to highlight an enum name
Change-Id: If802bfa3afd8bdcd5eed894fce50bad5907464bf
Reviewed-by: Ulf Hermann <ulf.hermann@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>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We cannot convert to QVariant using QMetaType::convert(). But we can
just construct a QVariant with the desired type and data. This will
become an issue once we automatically convert argument types to match
the desired type inside the function.
As a side effect, also allow declaring "var" arguments to functions.
Change-Id: Idc14021d8d85d3d09ee7b7f286de91b56ea02bfd
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
|
|
|
|
|
|
|
|
|
|
|
| |
We apply the same trick we already use for the UiObjectMember rules: We
add an ExpressionStatementLookahead before the T_LBRACKET starting the
UiArrayMemberList.
Task-number: QTBUG-82443
Change-Id: Ibdb3111b7721d2af087c14b79538dee131b8e301
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
|
|
|
|
|
|
|
|
|
|
| |
We can return void from a function, explicitly or implicitly, and we
need to be able to wrap that into a QVariant. In order to explicitly
return void, we need the void type to be exposed and understood.
Pick-to: 6.2
Change-Id: I513cabb25469b89a85b5d212a6825a037400729d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit introduces a new AST node for property attributes (currently
required, default and readonly). That node is not integrated into our
visitors, as it is only meant as an internal implementaion detail of
UiPublicMember. All information stored in it is meant to be accessed by
UiPublicMember's methods (see also the note below).
We use an union of SourceLocation and a node pointer to only pay the
overhead of the new node for properties; signals simply store the signal
token.
The grammar is rewritten with a new UiPropertyAttributes rule, which
avoids quite a bit of duplication in various rules, which had to deal
with the combinatorial explosion of attributes. Some parse errors are
now turned into semantic errors instead (readonly without initializer,
required with initializer).
By centralizing the handling of attributes in the grammar, we now can
easily support e.g. default properties with a list initializer.
As part of this restructuring, UiPublicMember's firstSourceLocation is
fixed to ensure that we actually return the first source location,
independent of the order in which the attributes are written.
Note: In theory, we would not need to make UiPropertyAttributes an AST
node. It could be a simple data class. However, the parser currently
assumes that every pointer in its parser stack is an AST node, and
touching that part would be a larger undertaking. As we use a pool
allocator, the cost is not that high (though we use more memory from the
pool then we would strictly need to).
Change-Id: Ia1d9fd7a6553d443cc57bc3d773f5be0aebe0e0e
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|
|
|
|
|
|
|
|
|
|
|
|
| |
Instead of directly accessing the attribute related members of
UiPublicMember, we access them via a function.
Moreover, we remove some redundancy: A property is
readonly/default/required if and only if the corresponding token is
valid. Thus we can drop the boolean members.
Change-Id: I22f15b2b037e857d2f9d3167cb761cba9516a135
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|
|
|
|
|
|
|
| |
operatorToken was not set in all cases for assignments
Change-Id: I0c2a3aba022034ed9b3c8021433b71b3df4b3ccf
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
|
|
|
|
|
|
|
|
|
|
| |
[ChangeLog][QtQml] You can now specify the list property assignment
behavior in QML using the "ListPropertyAssignBehavior" pragma. This is
analogous to the macros you can use in C++.
Fixes: QTBUG-93642
Change-Id: I9bdcf198031f1e24891f947b0990a3253d29a998
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
|
|
|
|
|
|
|
|
|
| |
* 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>
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before this change, they were treated as script bindings, which are less
efficient, and could not be used in ListElement.
Fixes: QTBUG-95139
Pick-to: 6.2
Change-Id: Ic66052c7f58b3ffdf1b7c0c169f42b4f99df62a1
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Type assertions actually check whether the expression matches the type,
and return null if it doesn't.
[ChangeLog][QtQml] You can use TypeScript-like type assertions using
"as" now. In contrast to TypeScript, QML's type assertions are enforced
at runtime. If the type doesn't match, null is returned for object
types. Also, type assertions can only cast to object types. There is no
way to create a value type or primitive type reference. As value types
and primitives cannot be polymorphic, this doesn't matter, though.
There are other ways of converting those.
Task-number: QTBUG-93662
Change-Id: I00fce3d4ea7a8c6b4631c580eaf6c113ac485813
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This change implements optional chaining (https://github.com/tc39/proposal-optional-chaining) by adding a new type of optional lookup with an offset to the end of a chain.
If `undefined` or `null` is encountered during an access marked as optional, we jump to that end offset.
Features:
- Full support for all kinds of optional chain
- With some codegen overhead but zero overhead during normal non-optional FieldMemberExpression resolution
- Properly retains this contexts and does not need to resolve anything twice (this has been an issue previously)
- No extra AST structures, just flags for existing ones
[ChangeLog][QtQml] Added support for optional chaining (https://github.com/tc39/proposal-optional-chaining)
Fixes: QTBUG-77926
Change-Id: I9a41cdc4ca272066c79c72b9b22206498a546843
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Arrow functions introduce a virtual functions and return statements to
simplify code generation (arrow function look like normal function
definitions), but to have correct firstSourceLocation /
lastSourcelocation other tokens were reused.
Use an empty SourceLocation at the correct position instead, so code
that expects the correct location (for error messages,...) works and
code that expects the correct token content (rewriter in QtCreator for
example) also works.
Introduce helper SourceLocation::startZeroLengthLocation/
endZeroLengthLocation to simplify such code.
Change-Id: I1c5df16e1704df2df9b7cbd1a039ce56be3727d3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
|
|
|
|
|
|
|
|
| |
The corresponding rules were missing so far.
Fixes: QTBUG-85716
Change-Id: Ic97546ea2e574f694a96d974ee355ac84f8650b5
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
|
|
|
|
|
|
|
|
| |
Task-number: QTBUG-84319
Change-Id: I2dcfb8a2db98282c7a1acdad1e6f4f949f26df15
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
|
|
|
|
|
|
|
| |
Fixes: QTBUG-81392
Change-Id: Ic83091c547a7854b7fa86b44d93c575bd7426bae
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|
|
|
|
|
|
|
|
|
|
| |
An import statement without version specifier imports the latest version
available, one with only a major version imports the latest minor
version from that major version.
Task-number: QTBUG-71278
Change-Id: I43907ae4e1052be533039d545de5391c41d38307
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
|
|\
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Conflicts:
src/qml/compiler/qqmlirbuilder_p.h
src/qml/qml/qqmlpropertycachecreator_p.h
src/qmltyperegistrar/qmltypesclassdescription.cpp
src/qmltyperegistrar/qmltypesclassdescription.h
src/qmltyperegistrar/qmltypescreator.cpp
src/quick/items/qquicktext_p.h
src/quick/util/qquickvaluetypes_p.h
Change-Id: Ic209741592e7b85820bf3845722023a190ebc1c5
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This is needed in a few places outside of declarative, so this change
restores the loc member in DiagnosticMessage and moves
QQmlJS::AST::SourceLocation into common's QQmlJS namespace/directory.
QQmlError is unaffected and retains only line/column.
Amends d4d197d06279f9257647628f7e1ccc9ec763a6bb
Change-Id: Ifb9d344228e3c6e9e26fc4fe112686f9336ea2b2
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
|
|\|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Conflicts:
src/imports/qtqml/plugin.cpp
src/qml/qml/qqml.h
src/qml/qml/qqmlmetatype.cpp
src/qml/qml/qqmlmetatype_p.h
src/qml/qml/qqmltypeloader.cpp
src/qml/types/qqmlbind.cpp
src/quick/items/qquickitemsmodule.cpp
tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
Change-Id: I52548938a582cb6510271ed4bc3a9aa0c3c11df6
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This is a partial patch that is fuilly fixed with the following
one (big restructure) because it needs extra visit methods,
and that leads to conflicts, but I think it gets lost if merged with
the next one.
Change-Id: I54331a47a5c7faaf78a97e580825d1feec5adf92
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Annotations are added to UiObjectMember.
This makes it easy to find the annotations of any UiObjectMember
through the annotations attribute.
The clean AST approach would add an UiAnnotatedObjectMember that contains
both the annotation list and an UiObjectMember, but that makes
finding the annotation more difficult.
The annotations are not visited by default, if one wants to dump them
before the current object the simplest way is to use the preVisit and
use .uiObjectMemberCast().
Depending on how we use annotation we could change the current
approach.
Task-number: QTBUG-81714
Change-Id: I543a2cfe5157bcc86de6de9faebde9aea22974eb
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|
|/
|
|
|
|
|
|
|
| |
Check that the version parsed is in the valid range for QTypeRevision
and produce a compile error if not.
Task-number: QTBUG-71278
Change-Id: I9a957a10f4254387f9868a8f3f1e231440bc2cd2
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
|
|
|
|
|
|
|
|
| |
It is now possible to mark a property of a parent class as required in
the child by writing required <propertyName>
Change-Id: I9e9d58c7b5c00577b056e905b39744b2fa359ea0
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
A QML Annotation is a Qml Object declaration prepended with @.
The name of the annotation is restricted to a dot separated list of
non keyword identifiers.
Annotations can be put before an Object definition, or any object
member declaration: bindings, property declarations, function
declarations.
This patch, aside parsing the annotations does absolutely nothing, the
list of annotations is discarded and never touches the AST.
[ChangeLog][QML] Add Qml Annotations
Task-number: QTBUG-81714
Change-Id: I4d79559a0d1fb23acaf482d0ef8f7d106dbf099d
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
|