diff options
author | Sami Shalayel <sami.shalayel@qt.io> | 2023-09-15 13:02:33 +0200 |
---|---|---|
committer | Sami Shalayel <sami.shalayel@qt.io> | 2023-09-26 20:46:38 +0200 |
commit | 35cdfc32e7f272efbdbc08f395b570ff1d2a75cc (patch) | |
tree | b90a071b0178842ba6547043f7cb32908a2544f1 /src/qml/parser | |
parent | 8237998bf4e22571a2dd6d80ea897171fed762af (diff) |
qmlls: add completion for pragmas
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>
Diffstat (limited to 'src/qml/parser')
-rw-r--r-- | src/qml/parser/qqmljs.g | 1 | ||||
-rw-r--r-- | src/qml/parser/qqmljsast_p.h | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/src/qml/parser/qqmljs.g b/src/qml/parser/qqmljs.g index 5b8c5d0eaa..849ec67c45 100644 --- a/src/qml/parser/qqmljs.g +++ b/src/qml/parser/qqmljs.g @@ -758,6 +758,7 @@ UiPragma: T_PRAGMA PragmaId T_COLON UiPragmaValueList Semicolon; AST::UiPragma *pragma = new (pool) AST::UiPragma( stringRef(2), sym(4).UiPragmaValueList->finish()); pragma->pragmaToken = loc(1); + pragma->colonToken = loc(3); pragma->semicolonToken = loc(5); sym(1).Node = pragma; } break; diff --git a/src/qml/parser/qqmljsast_p.h b/src/qml/parser/qqmljsast_p.h index 494fca9e28..8e1724af4b 100644 --- a/src/qml/parser/qqmljsast_p.h +++ b/src/qml/parser/qqmljsast_p.h @@ -3142,6 +3142,7 @@ public: QStringView name; UiPragmaValueList *values; SourceLocation pragmaToken; + SourceLocation colonToken; SourceLocation semicolonToken; }; |