diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2018-07-03 13:57:01 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2018-07-31 17:09:44 +0000 |
commit | 4caedd14c7926e65378836262808bda6e928936c (patch) | |
tree | a0bbadf5e0556be3e050ec943a52b9b06c9b1da5 /src/qml/parser/qqmljsast.cpp | |
parent | 53dba3fddef25d5668ed77c929c5ad611c9da544 (diff) |
Build AST nodes when parsing ES6 modules
This introduces the structures in the AST that allow for the extraction
of imports, exports as well as location of tokens.
The ModuleItemList as entry point is special with regards to the
statements (so not import/export declarations) in the sense that the
statement list contained in ModuleItemList::item is not linked yet
between different ModuleItemList instances.
Change-Id: If553a6ebaf53d5f3cf755c8327d3fe0ea7db68c2
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/parser/qqmljsast.cpp')
-rw-r--r-- | src/qml/parser/qqmljsast.cpp | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/src/qml/parser/qqmljsast.cpp b/src/qml/parser/qqmljsast.cpp index d254279cbf..73b6131d52 100644 --- a/src/qml/parser/qqmljsast.cpp +++ b/src/qml/parser/qqmljsast.cpp @@ -1058,6 +1058,130 @@ void Program::accept0(Visitor *visitor) visitor->endVisit(this); } +void ImportSpecifier::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + + } + visitor->endVisit(this); +} + +void ImportsList::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + for (ImportsList *it = this; it; it = it->next) { + accept(it->importSpecifier, visitor); + } + } + + visitor->endVisit(this); +} + +void NamedImports::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(importsList, visitor); + } + + visitor->endVisit(this); +} + +void FromClause::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + } + + visitor->endVisit(this); +} + +void NameSpaceImport::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + } + + visitor->endVisit(this); +} + +void ImportClause::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(nameSpaceImport, visitor); + accept(namedImports, visitor); + } + + visitor->endVisit(this); +} + +void ImportDeclaration::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(importClause, visitor); + accept(fromClause, visitor); + } + + visitor->endVisit(this); +} + +void ExportSpecifier::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + + } + + visitor->endVisit(this); +} + +void ExportsList::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + for (ExportsList *it = this; it; it = it->next) { + accept(it->exportSpecifier, visitor); + } + } + + visitor->endVisit(this); +} + +void ExportClause::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(exportsList, visitor); + } + + visitor->endVisit(this); +} + +void ExportDeclaration::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(fromClause, visitor); + accept(exportClause, visitor); + accept(variableStatementOrDeclaration, visitor); + } + + visitor->endVisit(this); +} + +void ModuleItemList::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + for (ModuleItemList *it = this; it; it = it->next) { + accept(it->item, visitor); + } + } + + visitor->endVisit(this); +} + +void ESModule::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(body, visitor); + } + + visitor->endVisit(this); +} + void DebuggerStatement::accept0(Visitor *visitor) { if (visitor->visit(this)) { |