aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/parser/qqmljsast_p.h
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2019-01-22 14:20:18 +0100
committerSimon Hausmann <simon.hausmann@qt.io>2019-07-09 16:52:17 +0200
commit1b866db65eb45ff347b51a2bc3b08d2a0bc166d6 (patch)
treea3c5c8fdd71a1ff06fb5872974e366398e357f19 /src/qml/parser/qqmljsast_p.h
parenta06736cab722c2a4283cdcbda8d003d8e91d7f54 (diff)
Fix internal boundNames() API to expose optional types
This allows extracting the type information for variable declarations. Change-Id: I1241df3b27ae292b83392d5caaa1587caafa46a3 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/parser/qqmljsast_p.h')
-rw-r--r--src/qml/parser/qqmljsast_p.h32
1 files changed, 27 insertions, 5 deletions
diff --git a/src/qml/parser/qqmljsast_p.h b/src/qml/parser/qqmljsast_p.h
index 21d143edf1..cdee4843b0 100644
--- a/src/qml/parser/qqmljsast_p.h
+++ b/src/qml/parser/qqmljsast_p.h
@@ -830,6 +830,28 @@ public:
SourceLocation propertyNameToken;
};
+struct QML_PARSER_EXPORT BoundName
+{
+ QString id;
+ TypeAnnotation *typeAnnotation = nullptr;
+ BoundName(const QString &id, TypeAnnotation *typeAnnotation)
+ : id(id), typeAnnotation(typeAnnotation)
+ {}
+ BoundName() = default;
+};
+
+struct BoundNames : public QVector<BoundName>
+{
+ int indexOf(const QString &name, int from = 0) const
+ {
+ auto found = std::find_if(constBegin() + from, constEnd(),
+ [name](const BoundName &it) { return it.id == name; });
+ if (found == constEnd())
+ return -1;
+ return found - constBegin();
+ }
+};
+
class QML_PARSER_EXPORT PatternElement : public Node
{
public:
@@ -886,7 +908,7 @@ public:
bool isVariableDeclaration() const { return scope != VariableScope::NoScope; }
bool isLexicallyScoped() const { return scope == VariableScope::Let || scope == VariableScope::Const; }
- virtual void boundNames(QStringList *names);
+ virtual void boundNames(BoundNames *names);
// attributes
SourceLocation identifierToken;
@@ -924,7 +946,7 @@ public:
void accept0(Visitor *visitor) override;
- void boundNames(QStringList *names);
+ void boundNames(BoundNames *names);
SourceLocation firstSourceLocation() const override
{ return elision ? elision->firstSourceLocation() : element->firstSourceLocation(); }
@@ -964,7 +986,7 @@ public:
return loc.isValid() ? loc : name->lastSourceLocation();
}
- void boundNames(QStringList *names) override;
+ void boundNames(BoundNames *names) override;
bool convertLiteralToAssignmentPattern(MemoryPool *pool, SourceLocation *errorLocation, QString *errorMessage) override;
// attributes
@@ -992,7 +1014,7 @@ public:
void accept0(Visitor *visitor) override;
- void boundNames(QStringList *names);
+ void boundNames(BoundNames *names);
inline PatternPropertyList *finish ()
{
@@ -2390,7 +2412,7 @@ public:
QStringList formals() const;
- QStringList boundNames() const;
+ BoundNames boundNames() const;
void accept0(Visitor *visitor) override;