diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstLabeledStmt.java b/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstLabeledStmt.java index 431243e6..d36f8eb5 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstLabeledStmt.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstLabeledStmt.java @@ -51,6 +51,10 @@ public Swc4jAstLabeledStmt( setLabel(label); } + public static Swc4jAstLabeledStmt create(Swc4jAstIdent label, ISwc4jAstStmt body) { + return new Swc4jAstLabeledStmt(label, body, Swc4jSpan.DUMMY); + } + @Jni2RustMethod public ISwc4jAstStmt getBody() { return body; diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstReturnStmt.java b/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstReturnStmt.java index 12ff6922..703f4e95 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstReturnStmt.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstReturnStmt.java @@ -45,6 +45,10 @@ public Swc4jAstReturnStmt( setArg(arg); } + public static Swc4jAstReturnStmt create() { + return create(null); + } + public static Swc4jAstReturnStmt create(ISwc4jAstExpr arg) { return new Swc4jAstReturnStmt(arg, Swc4jSpan.DUMMY); } diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstSwitchStmt.java b/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstSwitchStmt.java index 332a9a98..905c4437 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstSwitchStmt.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstSwitchStmt.java @@ -53,6 +53,14 @@ public Swc4jAstSwitchStmt( this.cases.forEach(node -> node.setParent(this)); } + public static Swc4jAstSwitchStmt create(ISwc4jAstExpr discriminant) { + return create(discriminant, SimpleList.of()); + } + + public static Swc4jAstSwitchStmt create(ISwc4jAstExpr discriminant, List cases) { + return new Swc4jAstSwitchStmt(discriminant, cases, Swc4jSpan.DUMMY); + } + @Jni2RustMethod public List getCases() { return cases; diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstThrowStmt.java b/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstThrowStmt.java index 00cfd19a..9fb62f18 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstThrowStmt.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstThrowStmt.java @@ -48,6 +48,10 @@ public Swc4jAstThrowStmt( setArg(arg); } + public static Swc4jAstThrowStmt create(ISwc4jAstExpr arg) { + return new Swc4jAstThrowStmt(arg, Swc4jSpan.DUMMY); + } + @Jni2RustMethod public ISwc4jAstExpr getArg() { return arg; diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstTryStmt.java b/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstTryStmt.java index 6c38b6da..8df1676a 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstTryStmt.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstTryStmt.java @@ -54,6 +54,25 @@ public Swc4jAstTryStmt( setHandler(handler); } + public static Swc4jAstTryStmt create(Swc4jAstBlockStmt block) { + return create(block, null, null); + } + + public static Swc4jAstTryStmt create(Swc4jAstBlockStmt block, Swc4jAstCatchClause handler) { + return create(block, handler, null); + } + + public static Swc4jAstTryStmt create(Swc4jAstBlockStmt block, Swc4jAstBlockStmt finalizer) { + return create(block, null, finalizer); + } + + public static Swc4jAstTryStmt create( + Swc4jAstBlockStmt block, + Swc4jAstCatchClause handler, + Swc4jAstBlockStmt finalizer) { + return new Swc4jAstTryStmt(block, handler, finalizer, Swc4jSpan.DUMMY); + } + @Jni2RustMethod public Swc4jAstBlockStmt getBlock() { return block; diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstTsEnumDecl.java b/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstTsEnumDecl.java index aa276f34..79eb54ec 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstTsEnumDecl.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstTsEnumDecl.java @@ -56,6 +56,29 @@ public Swc4jAstTsEnumDecl( this.members.forEach(node -> node.setParent(this)); } + public static Swc4jAstTsEnumDecl create(Swc4jAstIdent id) { + return create(id, SimpleList.of()); + } + + public static Swc4jAstTsEnumDecl create(Swc4jAstIdent id, List members) { + return create(false, id, members); + } + + public static Swc4jAstTsEnumDecl create( + boolean declare, + Swc4jAstIdent id, + List members) { + return create(declare, false, id, members); + } + + public static Swc4jAstTsEnumDecl create( + boolean declare, + boolean _const, + Swc4jAstIdent id, + List members) { + return new Swc4jAstTsEnumDecl(declare, _const, id, members, Swc4jSpan.DUMMY); + } + @Override public List getChildNodes() { List childNodes = SimpleList.copyOf(members); diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstTsInterfaceDecl.java b/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstTsInterfaceDecl.java index 07e8b85b..901d0de8 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstTsInterfaceDecl.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstTsInterfaceDecl.java @@ -63,6 +63,34 @@ public Swc4jAstTsInterfaceDecl( this._extends.forEach(node -> node.setParent(this)); } + public static Swc4jAstTsInterfaceDecl create(Swc4jAstIdent id, Swc4jAstTsInterfaceBody body) { + return create(id, SimpleList.of(), body); + } + + public static Swc4jAstTsInterfaceDecl create( + Swc4jAstIdent id, + List _extends, + Swc4jAstTsInterfaceBody body) { + return create(id, null, _extends, body); + } + + public static Swc4jAstTsInterfaceDecl create( + Swc4jAstIdent id, + Swc4jAstTsTypeParamDecl typeParams, + List _extends, + Swc4jAstTsInterfaceBody body) { + return create(id, false, typeParams, _extends, body); + } + + public static Swc4jAstTsInterfaceDecl create( + Swc4jAstIdent id, + boolean declare, + Swc4jAstTsTypeParamDecl typeParams, + List _extends, + Swc4jAstTsInterfaceBody body) { + return new Swc4jAstTsInterfaceDecl(id, declare, typeParams, _extends, body, Swc4jSpan.DUMMY); + } + @Jni2RustMethod public Swc4jAstTsInterfaceBody getBody() { return body; diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstTsModuleDecl.java b/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstTsModuleDecl.java index 1004a9b0..17b37614 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstTsModuleDecl.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstTsModuleDecl.java @@ -58,6 +58,29 @@ public Swc4jAstTsModuleDecl( setId(id); } + public static Swc4jAstTsModuleDecl create(ISwc4jAstTsModuleName id) { + return create(id, null); + } + + public static Swc4jAstTsModuleDecl create(ISwc4jAstTsModuleName id, ISwc4jAstTsNamespaceBody body) { + return create(false, id, body); + } + + public static Swc4jAstTsModuleDecl create( + boolean declare, + ISwc4jAstTsModuleName id, + ISwc4jAstTsNamespaceBody body) { + return create(declare, false, id, body); + } + + public static Swc4jAstTsModuleDecl create( + boolean declare, + boolean global, + ISwc4jAstTsModuleName id, + ISwc4jAstTsNamespaceBody body) { + return new Swc4jAstTsModuleDecl(declare, global, id, body, Swc4jSpan.DUMMY); + } + @Jni2RustMethod public Optional getBody() { return body; diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstTsTypeAliasDecl.java b/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstTsTypeAliasDecl.java index 67f488b5..8c42b745 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstTsTypeAliasDecl.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstTsTypeAliasDecl.java @@ -58,6 +58,25 @@ public Swc4jAstTsTypeAliasDecl( setTypeParams(typeParams); } + public static Swc4jAstTsTypeAliasDecl create(Swc4jAstIdent id, ISwc4jAstTsType typeAnn) { + return create(id, null, typeAnn); + } + + public static Swc4jAstTsTypeAliasDecl create( + Swc4jAstIdent id, + Swc4jAstTsTypeParamDecl typeParams, + ISwc4jAstTsType typeAnn) { + return create(id, false, typeParams, typeAnn); + } + + public static Swc4jAstTsTypeAliasDecl create( + Swc4jAstIdent id, + boolean declare, + Swc4jAstTsTypeParamDecl typeParams, + ISwc4jAstTsType typeAnn) { + return new Swc4jAstTsTypeAliasDecl(id, declare, typeParams, typeAnn, Swc4jSpan.DUMMY); + } + @Override public List getChildNodes() { List childNodes = SimpleList.of(id, typeAnn); diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstUsingDecl.java b/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstUsingDecl.java index 3dd20bda..946b59a6 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstUsingDecl.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstUsingDecl.java @@ -50,6 +50,18 @@ public Swc4jAstUsingDecl( this.decls.forEach(node -> node.setParent(this)); } + public static Swc4jAstUsingDecl create() { + return create(SimpleList.of()); + } + + public static Swc4jAstUsingDecl create(List decls) { + return create(false, decls); + } + + public static Swc4jAstUsingDecl create(boolean _await, List decls) { + return new Swc4jAstUsingDecl(_await, decls, Swc4jSpan.DUMMY); + } + @Override public List getChildNodes() { return SimpleList.copyOf(decls); diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstVarDeclarator.java b/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstVarDeclarator.java index 724ba0ea..51044d5b 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstVarDeclarator.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstVarDeclarator.java @@ -58,7 +58,11 @@ public static Swc4jAstVarDeclarator create(ISwc4jAstPat name) { } public static Swc4jAstVarDeclarator create(ISwc4jAstPat name, ISwc4jAstExpr init) { - return new Swc4jAstVarDeclarator(name, init, false, Swc4jSpan.DUMMY); + return create(name, init, false); + } + + public static Swc4jAstVarDeclarator create(ISwc4jAstPat name, ISwc4jAstExpr init, boolean definite) { + return new Swc4jAstVarDeclarator(name, init, definite, Swc4jSpan.DUMMY); } @Override diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstWhileStmt.java b/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstWhileStmt.java index 2d3127a2..34f209e7 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstWhileStmt.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstWhileStmt.java @@ -52,6 +52,10 @@ public Swc4jAstWhileStmt( setTest(test); } + public static Swc4jAstWhileStmt create(ISwc4jAstExpr test, ISwc4jAstStmt body) { + return new Swc4jAstWhileStmt(test, body, Swc4jSpan.DUMMY); + } + @Jni2RustMethod public ISwc4jAstStmt getBody() { return body; diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstWithStmt.java b/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstWithStmt.java index 630bf981..95345f25 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstWithStmt.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/stmt/Swc4jAstWithStmt.java @@ -52,6 +52,10 @@ public Swc4jAstWithStmt( setObj(obj); } + public static Swc4jAstWithStmt create(ISwc4jAstExpr obj, ISwc4jAstStmt body) { + return new Swc4jAstWithStmt(obj, body, Swc4jSpan.DUMMY); + } + @Jni2RustMethod public ISwc4jAstStmt getBody() { return body;