diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/miscs/Swc4jAstCatchClause.java b/src/main/java/com/caoccao/javet/swc4j/ast/miscs/Swc4jAstCatchClause.java index 19aebfe4..1b6a965e 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/miscs/Swc4jAstCatchClause.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/miscs/Swc4jAstCatchClause.java @@ -50,6 +50,14 @@ public Swc4jAstCatchClause( setParam(param); } + public static Swc4jAstCatchClause create(Swc4jAstBlockStmt body) { + return create(null, body); + } + + public static Swc4jAstCatchClause create(ISwc4jAstPat param, Swc4jAstBlockStmt body) { + return new Swc4jAstCatchClause(param, body, Swc4jSpan.DUMMY); + } + @Jni2RustMethod public Swc4jAstBlockStmt getBody() { return body; diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/miscs/Swc4jAstJsxAttr.java b/src/main/java/com/caoccao/javet/swc4j/ast/miscs/Swc4jAstJsxAttr.java index 18da52c4..183a0985 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/miscs/Swc4jAstJsxAttr.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/miscs/Swc4jAstJsxAttr.java @@ -52,6 +52,14 @@ public Swc4jAstJsxAttr( setValue(value); } + public static Swc4jAstJsxAttr create(ISwc4jAstJsxAttrName name) { + return create(name, null); + } + + public static Swc4jAstJsxAttr create(ISwc4jAstJsxAttrName name, ISwc4jAstJsxAttrValue value) { + return new Swc4jAstJsxAttr(name, value, Swc4jSpan.DUMMY); + } + @Override public List getChildNodes() { List childNodes = SimpleList.of(name); diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/miscs/Swc4jAstJsxClosingElement.java b/src/main/java/com/caoccao/javet/swc4j/ast/miscs/Swc4jAstJsxClosingElement.java index 9154f762..30b6ada9 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/miscs/Swc4jAstJsxClosingElement.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/miscs/Swc4jAstJsxClosingElement.java @@ -44,6 +44,10 @@ public Swc4jAstJsxClosingElement( setName(name); } + public static Swc4jAstJsxClosingElement create(ISwc4jAstJsxElementName name) { + return new Swc4jAstJsxClosingElement(name, Swc4jSpan.DUMMY); + } + @Override public List getChildNodes() { return SimpleList.of(name); diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/miscs/Swc4jAstJsxClosingFragment.java b/src/main/java/com/caoccao/javet/swc4j/ast/miscs/Swc4jAstJsxClosingFragment.java index 0f51c82d..1fde684e 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/miscs/Swc4jAstJsxClosingFragment.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/miscs/Swc4jAstJsxClosingFragment.java @@ -37,6 +37,10 @@ public Swc4jAstJsxClosingFragment( super(span); } + public static Swc4jAstJsxClosingFragment create() { + return new Swc4jAstJsxClosingFragment(Swc4jSpan.DUMMY); + } + @Override public List getChildNodes() { return EMPTY_CHILD_NODES; diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/miscs/Swc4jAstJsxOpeningElement.java b/src/main/java/com/caoccao/javet/swc4j/ast/miscs/Swc4jAstJsxOpeningElement.java index 461492e8..3c9350fa 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/miscs/Swc4jAstJsxOpeningElement.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/miscs/Swc4jAstJsxOpeningElement.java @@ -56,6 +56,31 @@ public Swc4jAstJsxOpeningElement( this.attrs.forEach(node -> node.setParent(this)); } + public static Swc4jAstJsxOpeningElement create(ISwc4jAstJsxElementName name) { + return create(name, SimpleList.of()); + } + + public static Swc4jAstJsxOpeningElement create( + ISwc4jAstJsxElementName name, + List attrs) { + return create(name, attrs, false); + } + + public static Swc4jAstJsxOpeningElement create( + ISwc4jAstJsxElementName name, + List attrs, + boolean selfClosing) { + return create(name, attrs, selfClosing, null); + } + + public static Swc4jAstJsxOpeningElement create( + ISwc4jAstJsxElementName name, + List attrs, + boolean selfClosing, + Swc4jAstTsTypeParamInstantiation typeArgs) { + return new Swc4jAstJsxOpeningElement(name, attrs, selfClosing, typeArgs, Swc4jSpan.DUMMY); + } + @Jni2RustMethod public List getAttrs() { return attrs; diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/miscs/Swc4jAstJsxOpeningFragment.java b/src/main/java/com/caoccao/javet/swc4j/ast/miscs/Swc4jAstJsxOpeningFragment.java index 18f6a1e5..e13d986f 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/miscs/Swc4jAstJsxOpeningFragment.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/miscs/Swc4jAstJsxOpeningFragment.java @@ -37,6 +37,10 @@ public Swc4jAstJsxOpeningFragment( super(span); } + public static Swc4jAstJsxOpeningFragment create() { + return new Swc4jAstJsxOpeningFragment(Swc4jSpan.DUMMY); + } + @Override public List getChildNodes() { return EMPTY_CHILD_NODES; diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/miscs/Swc4jAstOptCall.java b/src/main/java/com/caoccao/javet/swc4j/ast/miscs/Swc4jAstOptCall.java index 950e0255..75cc736b 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/miscs/Swc4jAstOptCall.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/miscs/Swc4jAstOptCall.java @@ -42,6 +42,7 @@ public class Swc4jAstOptCall protected ISwc4jAstExpr callee; @Jni2RustField(componentBox = true) protected Optional typeArgs; + @Jni2RustMethod public Swc4jAstOptCall( ISwc4jAstExpr callee, @@ -55,6 +56,21 @@ public Swc4jAstOptCall( this.args.forEach(node -> node.setParent(this)); } + public static Swc4jAstOptCall create(ISwc4jAstExpr callee) { + return create(callee, SimpleList.of()); + } + + public static Swc4jAstOptCall create(ISwc4jAstExpr callee, List args) { + return create(callee, args, null); + } + + public static Swc4jAstOptCall create( + ISwc4jAstExpr callee, + List args, + Swc4jAstTsTypeParamInstantiation typeArgs) { + return new Swc4jAstOptCall(callee, args, typeArgs, Swc4jSpan.DUMMY); + } + @Jni2RustMethod public List getArgs() { return args; diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/miscs/Swc4jAstSwitchCase.java b/src/main/java/com/caoccao/javet/swc4j/ast/miscs/Swc4jAstSwitchCase.java index 26499ca0..9c9d7a6a 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/miscs/Swc4jAstSwitchCase.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/miscs/Swc4jAstSwitchCase.java @@ -49,6 +49,18 @@ public Swc4jAstSwitchCase( this.cons.forEach(node -> node.setParent(this)); } + public static Swc4jAstSwitchCase create() { + return create(null); + } + + public static Swc4jAstSwitchCase create(ISwc4jAstExpr test) { + return create(test, SimpleList.of()); + } + + public static Swc4jAstSwitchCase create(ISwc4jAstExpr test, List cons) { + return new Swc4jAstSwitchCase(test, cons, Swc4jSpan.DUMMY); + } + @Override public List getChildNodes() { List childNodes = SimpleList.copyOf(cons); diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/miscs/Swc4jAstTplElement.java b/src/main/java/com/caoccao/javet/swc4j/ast/miscs/Swc4jAstTplElement.java index 8a406fa6..9a0bf122 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/miscs/Swc4jAstTplElement.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/miscs/Swc4jAstTplElement.java @@ -49,6 +49,14 @@ public Swc4jAstTplElement( setTail(tail); } + public static Swc4jAstTplElement create(boolean tail, String raw) { + return create(tail, null, raw); + } + + public static Swc4jAstTplElement create(boolean tail, String cooked, String raw) { + return new Swc4jAstTplElement(tail, cooked, raw, Swc4jSpan.DUMMY); + } + @Override public List getChildNodes() { return EMPTY_CHILD_NODES;