parser: don't parse error on empty import statement

Report the error later when loading the import.
That way, we get a more complete AST for auto-completion
This commit is contained in:
Olivier Goffart 2023-04-15 17:32:17 +02:00 committed by Olivier Goffart
parent 7d3968f025
commit 40922874fa
5 changed files with 11 additions and 10 deletions

View file

@ -252,15 +252,15 @@ fn parse_import_specifier(p: &mut impl Parser) -> bool {
/// { Type1 }
/// { Type2, Type3 }
/// { Type as Alias1, Type as AnotherAlias }
/// {}
/// ```
fn parse_import_identifier_list(p: &mut impl Parser) -> bool {
let mut p = p.start_node(SyntaxKind::ImportIdentifierList);
if !p.expect(SyntaxKind::LBrace) {
return false;
}
if p.peek().kind == SyntaxKind::RBrace {
p.error("Import names are missing. Please specify which types you would like to import");
return false;
if p.test(SyntaxKind::RBrace) {
return true;
}
loop {
parse_import_identifier(&mut *p);