Rename 'assertions' to 'attributes' in JS extractor

This commit is contained in:
Arthur Baars
2023-10-10 16:12:13 +02:00
parent b936e91fe9
commit 1d9ee5da3c
3 changed files with 16 additions and 14 deletions

View File

@@ -314,8 +314,9 @@ public class ESNextParser extends JSXParser {
this.parseExportSpecifiersMaybe(specifiers, exports);
}
Literal source = (Literal) this.parseExportFrom(specifiers, null, true);
Expression assertion = this.parseImportOrExportAssertionAndSemicolon();
return this.finishNode(new ExportNamedDeclaration(exportStart, null, specifiers, source, assertion));
Expression attributes = this.parseImportOrExportAttributesAndSemicolon();
return this.finishNode(
new ExportNamedDeclaration(exportStart, null, specifiers, source, attributes));
}
return super.parseExportRest(exportStart, exports);
@@ -331,8 +332,9 @@ public class ESNextParser extends JSXParser {
List<ExportSpecifier> specifiers = CollectionUtil.makeList(nsSpec);
this.parseExportSpecifiersMaybe(specifiers, exports);
Literal source = (Literal) this.parseExportFrom(specifiers, null, true);
Expression assertion = this.parseImportOrExportAssertionAndSemicolon();
return this.finishNode(new ExportNamedDeclaration(exportStart, null, specifiers, source, assertion));
Expression attributes = this.parseImportOrExportAttributesAndSemicolon();
return this.finishNode(
new ExportNamedDeclaration(exportStart, null, specifiers, source, attributes));
}
return super.parseExportAll(exportStart, starLoc, exports);

View File

@@ -3447,7 +3447,7 @@ public class Parser {
Statement declaration;
List<ExportSpecifier> specifiers;
Expression source = null;
Expression assertion = null;
Expression attributes = null;
if (this.shouldParseExportStatement()) {
declaration = this.parseStatement(true, false);
if (declaration == null) return null;
@@ -3463,10 +3463,10 @@ public class Parser {
declaration = null;
specifiers = this.parseExportSpecifiers(exports);
source = parseExportFrom(specifiers, source, false);
assertion = parseImportOrExportAssertionAndSemicolon();
attributes = parseImportOrExportAttributesAndSemicolon();
}
return this.finishNode(
new ExportNamedDeclaration(loc, declaration, specifiers, (Literal) source, assertion));
new ExportNamedDeclaration(loc, declaration, specifiers, (Literal) source, attributes));
}
/** Parses the 'from' clause of an export, not including the assertion or semicolon. */
@@ -3494,8 +3494,8 @@ public class Parser {
protected ExportDeclaration parseExportAll(
SourceLocation loc, Position starLoc, Set<String> exports) {
Expression source = parseExportFrom(null, null, true);
Expression assertion = parseImportOrExportAssertionAndSemicolon();
return this.finishNode(new ExportAllDeclaration(loc, (Literal) source, assertion));
Expression attributes = parseImportOrExportAttributesAndSemicolon();
return this.finishNode(new ExportAllDeclaration(loc, (Literal) source, attributes));
}
private void checkExport(Set<String> exports, String name, Position pos) {
@@ -3560,7 +3560,7 @@ public class Parser {
return parseImportRest(loc);
}
protected Expression parseImportOrExportAssertionAndSemicolon() {
protected Expression parseImportOrExportAttributesAndSemicolon() {
Expression result = null;
if (!this.eagerlyTrySemicolon()) {
if (!this.eatContextual("assert")) {
@@ -3585,9 +3585,9 @@ public class Parser {
if (this.type != TokenType.string) this.unexpected();
source = (Literal) this.parseExprAtom(null);
}
Expression assertion = this.parseImportOrExportAssertionAndSemicolon();
Expression attributes = this.parseImportOrExportAttributesAndSemicolon();
if (specifiers == null) return null;
return this.finishNode(new ImportDeclaration(loc, specifiers, source, assertion));
return this.finishNode(new ImportDeclaration(loc, specifiers, source, attributes));
}
// Parses a comma-separated list of module imports.

View File

@@ -943,12 +943,12 @@ public class FlowParser extends ESNextParser {
// `export type { foo, bar };`
List<ExportSpecifier> specifiers = this.parseExportSpecifiers(exports);
this.parseExportFrom(specifiers, null, false);
this.parseImportOrExportAssertionAndSemicolon();
this.parseImportOrExportAttributesAndSemicolon();
return null;
} else if (this.eat(TokenType.star)) {
if (this.eatContextual("as")) this.parseIdent(true);
this.parseExportFrom(null, null, true);
this.parseImportOrExportAssertionAndSemicolon();
this.parseImportOrExportAttributesAndSemicolon();
return null;
} else {
// `export type Foo = Bar;`