Skip to content

Commit f7b02c0

Browse files
committed
Rename getAssertion() to getAttributes() in the extractor
1 parent 1d9ee5d commit f7b02c0

File tree

6 files changed

+116
-65
lines changed

6 files changed

+116
-65
lines changed

javascript/extractor/src/com/semmle/js/ast/DynamicImport.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ public Expression getSource() {
1414
return source;
1515
}
1616

17-
/** Returns the second "argument" provided to the import, such as <code>{ assert: { type: "json" }}</code>. */
17+
/**
18+
* Returns the second "argument" provided to the import, such as <code>{ "with": { type: "json" }}
19+
* </code>.
20+
*/
1821
public Expression getAttributes() {
1922
return attributes;
2023
}

javascript/extractor/src/com/semmle/js/ast/ExportAllDeclaration.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@
99
*/
1010
public class ExportAllDeclaration extends ExportDeclaration {
1111
private final Literal source;
12-
private final Expression assertion;
12+
private final Expression attributes;
1313

14-
public ExportAllDeclaration(SourceLocation loc, Literal source, Expression assertion) {
14+
public ExportAllDeclaration(SourceLocation loc, Literal source, Expression attributes) {
1515
super("ExportAllDeclaration", loc);
1616
this.source = source;
17-
this.assertion = assertion;
17+
this.attributes = attributes;
1818
}
1919

2020
public Literal getSource() {
2121
return source;
2222
}
2323

24-
public Expression getAssertion() {
25-
return assertion;
24+
public Expression getAttributes() {
25+
return attributes;
2626
}
2727

2828
@Override

javascript/extractor/src/com/semmle/js/ast/ExportNamedDeclaration.java

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,30 @@ public class ExportNamedDeclaration extends ExportDeclaration {
1515
private final Statement declaration;
1616
private final List<ExportSpecifier> specifiers;
1717
private final Literal source;
18-
private final Expression assertion;
18+
private final Expression attributes;
1919
private final boolean hasTypeKeyword;
2020

2121
public ExportNamedDeclaration(
22-
SourceLocation loc, Statement declaration, List<ExportSpecifier> specifiers, Literal source, Expression assertion) {
23-
this(loc, declaration, specifiers, source, assertion, false);
22+
SourceLocation loc,
23+
Statement declaration,
24+
List<ExportSpecifier> specifiers,
25+
Literal source,
26+
Expression attributes) {
27+
this(loc, declaration, specifiers, source, attributes, false);
2428
}
2529

2630
public ExportNamedDeclaration(
27-
SourceLocation loc, Statement declaration, List<ExportSpecifier> specifiers, Literal source,
28-
Expression assertion, boolean hasTypeKeyword) {
31+
SourceLocation loc,
32+
Statement declaration,
33+
List<ExportSpecifier> specifiers,
34+
Literal source,
35+
Expression attributes,
36+
boolean hasTypeKeyword) {
2937
super("ExportNamedDeclaration", loc);
3038
this.declaration = declaration;
3139
this.specifiers = specifiers;
3240
this.source = source;
33-
this.assertion = assertion;
41+
this.attributes = attributes;
3442
this.hasTypeKeyword = hasTypeKeyword;
3543
}
3644

@@ -59,9 +67,12 @@ public <C, R> R accept(Visitor<C, R> v, C c) {
5967
return v.visit(this, c);
6068
}
6169

62-
/** Returns the expression after the <code>assert</code> keyword, if any, such as <code>{ type: "json" }</code>. */
63-
public Expression getAssertion() {
64-
return assertion;
70+
/**
71+
* Returns the expression after the <code>with</code> keyword, if any, such as <code>
72+
* { type: "json" }</code>.
73+
*/
74+
public Expression getAttributes() {
75+
return attributes;
6576
}
6677

6778
/** Returns true if this is an <code>export type</code> declaration. */

javascript/extractor/src/com/semmle/js/ast/ImportDeclaration.java

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package com.semmle.js.ast;
22

3-
import java.util.List;
4-
53
import com.semmle.ts.ast.INodeWithSymbol;
4+
import java.util.List;
65

76
/**
87
* An import declaration, which can be of one of the following forms:
@@ -23,21 +22,27 @@ public class ImportDeclaration extends Statement implements INodeWithSymbol {
2322
/** The module from which declarations are imported. */
2423
private final Literal source;
2524

26-
private final Expression assertion;
25+
private final Expression attributes;
2726

2827
private int symbol = -1;
2928

3029
private boolean hasTypeKeyword;
3130

32-
public ImportDeclaration(SourceLocation loc, List<ImportSpecifier> specifiers, Literal source, Expression assertion) {
33-
this(loc, specifiers, source, assertion, false);
31+
public ImportDeclaration(
32+
SourceLocation loc, List<ImportSpecifier> specifiers, Literal source, Expression attributes) {
33+
this(loc, specifiers, source, attributes, false);
3434
}
3535

36-
public ImportDeclaration(SourceLocation loc, List<ImportSpecifier> specifiers, Literal source, Expression assertion, boolean hasTypeKeyword) {
36+
public ImportDeclaration(
37+
SourceLocation loc,
38+
List<ImportSpecifier> specifiers,
39+
Literal source,
40+
Expression attributes,
41+
boolean hasTypeKeyword) {
3742
super("ImportDeclaration", loc);
3843
this.specifiers = specifiers;
3944
this.source = source;
40-
this.assertion = assertion;
45+
this.attributes = attributes;
4146
this.hasTypeKeyword = hasTypeKeyword;
4247
}
4348

@@ -49,9 +54,12 @@ public List<ImportSpecifier> getSpecifiers() {
4954
return specifiers;
5055
}
5156

52-
/** Returns the expression after the <code>assert</code> keyword, if any, such as <code>{ type: "json" }</code>. */
53-
public Expression getAssertion() {
54-
return assertion;
57+
/**
58+
* Returns the expression after the <code>with</code> keyword, if any, such as <code>
59+
* { type: "json" }</code>.
60+
*/
61+
public Expression getAttributes() {
62+
return attributes;
5563
}
5664

5765
@Override

javascript/extractor/src/com/semmle/js/ast/NodeCopier.java

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
package com.semmle.js.ast;
22

3-
import java.util.ArrayList;
4-
import java.util.List;
5-
63
import com.semmle.js.ast.jsx.JSXAttribute;
74
import com.semmle.js.ast.jsx.JSXClosingElement;
85
import com.semmle.js.ast.jsx.JSXElement;
@@ -42,16 +39,18 @@
4239
import com.semmle.ts.ast.ParenthesizedTypeExpr;
4340
import com.semmle.ts.ast.PredicateTypeExpr;
4441
import com.semmle.ts.ast.RestTypeExpr;
42+
import com.semmle.ts.ast.SatisfiesExpr;
4543
import com.semmle.ts.ast.TemplateLiteralTypeExpr;
4644
import com.semmle.ts.ast.TupleTypeExpr;
4745
import com.semmle.ts.ast.TypeAliasDeclaration;
4846
import com.semmle.ts.ast.TypeAssertion;
49-
import com.semmle.ts.ast.SatisfiesExpr;
5047
import com.semmle.ts.ast.TypeParameter;
5148
import com.semmle.ts.ast.TypeofTypeExpr;
5249
import com.semmle.ts.ast.UnaryTypeExpr;
5350
import com.semmle.ts.ast.UnionTypeExpr;
5451
import com.semmle.util.data.IntList;
52+
import java.util.ArrayList;
53+
import java.util.List;
5554

5655
/** Deep cloning of AST nodes. */
5756
public class NodeCopier implements Visitor<Void, INode> {
@@ -429,7 +428,8 @@ public TemplateLiteral visit(TemplateLiteral nd, Void q) {
429428

430429
@Override
431430
public TemplateLiteralTypeExpr visit(TemplateLiteralTypeExpr nd, Void q) {
432-
return new TemplateLiteralTypeExpr(visit(nd.getLoc()), copy(nd.getExpressions()), copy(nd.getQuasis()));
431+
return new TemplateLiteralTypeExpr(
432+
visit(nd.getLoc()), copy(nd.getExpressions()), copy(nd.getQuasis()));
433433
}
434434

435435
@Override
@@ -523,7 +523,8 @@ public MetaProperty visit(MetaProperty nd, Void c) {
523523

524524
@Override
525525
public ExportAllDeclaration visit(ExportAllDeclaration nd, Void c) {
526-
return new ExportAllDeclaration(visit(nd.getLoc()), copy(nd.getSource()), copy(nd.getAssertion()));
526+
return new ExportAllDeclaration(
527+
visit(nd.getLoc()), copy(nd.getSource()), copy(nd.getAttributes()));
527528
}
528529

529530
@Override
@@ -538,7 +539,7 @@ public ExportNamedDeclaration visit(ExportNamedDeclaration nd, Void c) {
538539
copy(nd.getDeclaration()),
539540
copy(nd.getSpecifiers()),
540541
copy(nd.getSource()),
541-
copy(nd.getAssertion()));
542+
copy(nd.getAttributes()));
542543
}
543544

544545
@Override
@@ -559,7 +560,11 @@ public ExportSpecifier visit(ExportSpecifier nd, Void c) {
559560
@Override
560561
public ImportDeclaration visit(ImportDeclaration nd, Void c) {
561562
return new ImportDeclaration(
562-
visit(nd.getLoc()), copy(nd.getSpecifiers()), copy(nd.getSource()), copy(nd.getAssertion()), nd.hasTypeKeyword());
563+
visit(nd.getLoc()),
564+
copy(nd.getSpecifiers()),
565+
copy(nd.getSource()),
566+
copy(nd.getAttributes()),
567+
nd.hasTypeKeyword());
563568
}
564569

565570
@Override
@@ -725,7 +730,8 @@ public INode visit(ParenthesizedTypeExpr nd, Void c) {
725730

726731
@Override
727732
public INode visit(TupleTypeExpr nd, Void c) {
728-
return new TupleTypeExpr(visit(nd.getLoc()), copy(nd.getElementTypes()), copy(nd.getElementNames()));
733+
return new TupleTypeExpr(
734+
visit(nd.getLoc()), copy(nd.getElementTypes()), copy(nd.getElementNames()));
729735
}
730736

731737
@Override
@@ -787,9 +793,7 @@ public INode visit(TypeAssertion nd, Void c) {
787793
@Override
788794
public INode visit(SatisfiesExpr nd, Void c) {
789795
return new SatisfiesExpr(
790-
visit(nd.getLoc()),
791-
copy(nd.getExpression()),
792-
copy(nd.getTypeAnnotation()));
796+
visit(nd.getLoc()), copy(nd.getExpression()), copy(nd.getTypeAnnotation()));
793797
}
794798

795799
@Override
@@ -907,7 +911,8 @@ public INode visit(XMLDotDotExpression nd, Void c) {
907911

908912
@Override
909913
public INode visit(GeneratedCodeExpr nd, Void c) {
910-
return new GeneratedCodeExpr(visit(nd.getLoc()), nd.getOpeningDelimiter(), nd.getClosingDelimiter(), nd.getBody());
914+
return new GeneratedCodeExpr(
915+
visit(nd.getLoc()), nd.getOpeningDelimiter(), nd.getClosingDelimiter(), nd.getBody());
911916
}
912917

913918
@Override

0 commit comments

Comments
 (0)