1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

ast, parser: add syms_pos to import ast (#9541)

This commit is contained in:
Ned Palacios 2021-03-31 18:17:06 +08:00 committed by GitHub
parent 6daefde5cb
commit 0b39de2fd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View File

@ -305,6 +305,7 @@ pub:
pos token.Position
mod_pos token.Position
alias_pos token.Position
syms_pos token.Position
pub mut:
syms []ImportSymbol // the list of symbols in `import {symbol1, symbol2}`
comments []Comment

View File

@ -2530,7 +2530,14 @@ fn (mut p Parser) import_stmt() ast.Import {
}
}
if p.tok.kind == .lcbr { // import module { fn1, Type2 } syntax
mut initial_syms_pos := p.tok.position()
p.import_syms(mut import_node)
initial_syms_pos = initial_syms_pos.extend(p.tok.position())
import_node = ast.Import{
...import_node
syms_pos: initial_syms_pos
pos: import_node.pos.extend(initial_syms_pos)
}
p.register_used_import(mod_alias) // no `unused import` msg for parent
}
pos_t := p.tok.position()