From 7116c86733acd4ffe4e597fee2aed0b2454c0a36 Mon Sep 17 00:00:00 2001 From: Sam Cao Date: Wed, 5 Jun 2024 09:43:07 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20Add=20create()=20v13?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../swc4j/ast/ts/Swc4jAstTsMappedType.java | 32 +++++++++ .../ast/ts/Swc4jAstTsMethodSignature.java | 55 +++++++++++++++ .../swc4j/ast/ts/Swc4jAstTsOptionalType.java | 4 ++ .../swc4j/ast/ts/Swc4jAstTsParamProp.java | 56 +++++++++++++--- .../ast/ts/Swc4jAstTsParenthesizedType.java | 4 ++ .../ast/ts/Swc4jAstTsPropertySignature.java | 67 +++++++++++++++++++ .../swc4j/ast/ts/Swc4jAstTsQualifiedName.java | 4 ++ .../swc4j/ast/ts/Swc4jAstTsRestType.java | 4 ++ .../ast/ts/Swc4jAstTsSetterSignature.java | 28 ++++++++ .../swc4j/ast/ts/Swc4jAstTsThisType.java | 4 ++ .../swc4j/ast/ts/Swc4jAstTsTplLitType.java | 8 +++ .../swc4j/ast/ts/Swc4jAstTsTupleElement.java | 8 +++ .../swc4j/ast/ts/Swc4jAstTsTupleType.java | 9 ++- .../javet/swc4j/ast/ts/Swc4jAstTsTypeAnn.java | 4 ++ .../javet/swc4j/ast/ts/Swc4jAstTsTypeLit.java | 8 +++ .../swc4j/ast/ts/Swc4jAstTsTypeOperator.java | 4 ++ .../swc4j/ast/ts/Swc4jAstTsTypeParam.java | 35 ++++++++++ .../swc4j/ast/ts/Swc4jAstTsTypeParamDecl.java | 8 +++ .../ts/Swc4jAstTsTypeParamInstantiation.java | 8 +++ .../swc4j/ast/ts/Swc4jAstTsTypePredicate.java | 15 +++++ .../swc4j/ast/ts/Swc4jAstTsTypeQuery.java | 10 +++ .../javet/swc4j/ast/ts/Swc4jAstTsTypeRef.java | 10 +++ .../swc4j/ast/ts/Swc4jAstTsUnionType.java | 8 +++ 23 files changed, 381 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsMappedType.java b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsMappedType.java index a2d46ad8..a1319702 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsMappedType.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsMappedType.java @@ -59,6 +59,38 @@ public Swc4jAstTsMappedType( setTypeParam(typeParam); } + public static Swc4jAstTsMappedType create(Swc4jAstTsTypeParam typeParam) { + return create(null, typeParam); + } + + public static Swc4jAstTsMappedType create(Swc4jAstTruePlusMinus readonly, Swc4jAstTsTypeParam typeParam) { + return create(readonly, typeParam, null); + } + + public static Swc4jAstTsMappedType create( + Swc4jAstTruePlusMinus readonly, + Swc4jAstTsTypeParam typeParam, + ISwc4jAstTsType nameType) { + return create(readonly, typeParam, nameType, null); + } + + public static Swc4jAstTsMappedType create( + Swc4jAstTruePlusMinus readonly, + Swc4jAstTsTypeParam typeParam, + ISwc4jAstTsType nameType, + Swc4jAstTruePlusMinus optional) { + return create(readonly, typeParam, nameType, optional, null); + } + + public static Swc4jAstTsMappedType create( + Swc4jAstTruePlusMinus readonly, + Swc4jAstTsTypeParam typeParam, + ISwc4jAstTsType nameType, + Swc4jAstTruePlusMinus optional, + ISwc4jAstTsType typeAnn) { + return new Swc4jAstTsMappedType(readonly, typeParam, nameType, optional, typeAnn, Swc4jSpan.DUMMY); + } + @Override public List getChildNodes() { List childNodes = SimpleList.of(typeParam); diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsMethodSignature.java b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsMethodSignature.java index e26bd0cf..8b9a23c5 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsMethodSignature.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsMethodSignature.java @@ -68,6 +68,61 @@ public Swc4jAstTsMethodSignature( this.params.forEach(node -> node.setParent(this)); } + public static Swc4jAstTsMethodSignature create(ISwc4jAstExpr key) { + return create(key, SimpleList.of()); + } + + public static Swc4jAstTsMethodSignature create(ISwc4jAstExpr key, List params) { + return create(false, key, params); + } + + public static Swc4jAstTsMethodSignature create( + boolean readonly, + ISwc4jAstExpr key, + List params) { + return create(readonly, key, false, params); + } + + public static Swc4jAstTsMethodSignature create( + boolean readonly, + ISwc4jAstExpr key, + boolean computed, + List params) { + return create(readonly, key, computed, false, params); + } + + public static Swc4jAstTsMethodSignature create( + boolean readonly, + ISwc4jAstExpr key, + boolean computed, + boolean optional, + List params) { + return create(readonly, key, computed, optional, params, null); + } + + public static Swc4jAstTsMethodSignature create( + boolean readonly, + ISwc4jAstExpr key, + boolean computed, + boolean optional, + List params, + Swc4jAstTsTypeAnn typeAnn) { + return create(readonly, key, computed, optional, params, typeAnn, null); + } + + public static Swc4jAstTsMethodSignature create( + boolean readonly, + ISwc4jAstExpr key, + boolean computed, + boolean optional, + List params, + Swc4jAstTsTypeAnn typeAnn, + Swc4jAstTsTypeParamDecl typeParams) { + return new Swc4jAstTsMethodSignature( + readonly, key, computed, optional, params, + typeAnn, typeParams, Swc4jSpan.DUMMY); + } + @Override public List getChildNodes() { List childNodes = SimpleList.copyOf(params); diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsOptionalType.java b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsOptionalType.java index 7ee3483a..849da37d 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsOptionalType.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsOptionalType.java @@ -47,6 +47,10 @@ public Swc4jAstTsOptionalType( setTypeAnn(typeAnn); } + public static Swc4jAstTsOptionalType create(ISwc4jAstTsType typeAnn) { + return new Swc4jAstTsOptionalType(typeAnn, Swc4jSpan.DUMMY); + } + @Override public List getChildNodes() { return SimpleList.of(typeAnn); diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsParamProp.java b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsParamProp.java index 92f4f492..c67c06f7 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsParamProp.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsParamProp.java @@ -20,7 +20,9 @@ import com.caoccao.javet.swc4j.ast.clazz.Swc4jAstDecorator; import com.caoccao.javet.swc4j.ast.enums.Swc4jAstAccessibility; import com.caoccao.javet.swc4j.ast.enums.Swc4jAstType; -import com.caoccao.javet.swc4j.ast.interfaces.*; +import com.caoccao.javet.swc4j.ast.interfaces.ISwc4jAst; +import com.caoccao.javet.swc4j.ast.interfaces.ISwc4jAstParamOrTsParamProp; +import com.caoccao.javet.swc4j.ast.interfaces.ISwc4jAstTsParamPropParam; import com.caoccao.javet.swc4j.ast.visitors.ISwc4jAstVisitor; import com.caoccao.javet.swc4j.ast.visitors.Swc4jAstVisitorResponse; import com.caoccao.javet.swc4j.jni2rust.*; @@ -59,6 +61,38 @@ public Swc4jAstTsParamProp( this.decorators.forEach(node -> node.setParent(this)); } + public static Swc4jAstTsParamProp create(ISwc4jAstTsParamPropParam param) { + return create(SimpleList.of(), param); + } + + public static Swc4jAstTsParamProp create(List decorators, ISwc4jAstTsParamPropParam param) { + return create(decorators, null, param); + } + + public static Swc4jAstTsParamProp create( + List decorators, + Swc4jAstAccessibility accessibility, + ISwc4jAstTsParamPropParam param) { + return create(decorators, accessibility, false, param); + } + + public static Swc4jAstTsParamProp create( + List decorators, + Swc4jAstAccessibility accessibility, + boolean _override, + ISwc4jAstTsParamPropParam param) { + return create(decorators, accessibility, _override, false, param); + } + + public static Swc4jAstTsParamProp create( + List decorators, + Swc4jAstAccessibility accessibility, + boolean _override, + boolean readonly, + ISwc4jAstTsParamPropParam param) { + return new Swc4jAstTsParamProp(decorators, accessibility, _override, readonly, param, Swc4jSpan.DUMMY); + } + @Jni2RustMethod public Optional getAccessibility() { return accessibility; @@ -86,6 +120,16 @@ public Swc4jAstType getType() { return Swc4jAstType.TsParamProp; } + @Jni2RustMethod + public boolean isOverride() { + return _override; + } + + @Jni2RustMethod + public boolean isReadonly() { + return readonly; + } + @Override public boolean replaceNode(ISwc4jAst oldNode, ISwc4jAst newNode) { if (!decorators.isEmpty() && newNode instanceof Swc4jAstDecorator) { @@ -105,16 +149,6 @@ public boolean replaceNode(ISwc4jAst oldNode, ISwc4jAst newNode) { return false; } - @Jni2RustMethod - public boolean isOverride() { - return _override; - } - - @Jni2RustMethod - public boolean isReadonly() { - return readonly; - } - public Swc4jAstTsParamProp setAccessibility(Swc4jAstAccessibility accessibility) { this.accessibility = Optional.ofNullable(accessibility); return this; diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsParenthesizedType.java b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsParenthesizedType.java index 7413a4a2..f50f5249 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsParenthesizedType.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsParenthesizedType.java @@ -47,6 +47,10 @@ public Swc4jAstTsParenthesizedType( setTypeAnn(typeAnn); } + public static Swc4jAstTsParenthesizedType create(ISwc4jAstTsType typeAnn) { + return new Swc4jAstTsParenthesizedType(typeAnn, Swc4jSpan.DUMMY); + } + @Override public List getChildNodes() { return SimpleList.of(typeAnn); diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsPropertySignature.java b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsPropertySignature.java index 1c495df9..baffad0a 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsPropertySignature.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsPropertySignature.java @@ -72,6 +72,73 @@ public Swc4jAstTsPropertySignature( this.params.forEach(node -> node.setParent(this)); } + public static Swc4jAstTsPropertySignature create(ISwc4jAstExpr key) { + return create(key, SimpleList.of()); + } + + public static Swc4jAstTsPropertySignature create(ISwc4jAstExpr key, List params) { + return create(false, key, params); + } + + public static Swc4jAstTsPropertySignature create( + boolean readonly, + ISwc4jAstExpr key, + List params) { + return create(readonly, key, false, params); + } + + public static Swc4jAstTsPropertySignature create( + boolean readonly, + ISwc4jAstExpr key, + boolean computed, + List params) { + return create(readonly, key, computed, false, params); + } + + public static Swc4jAstTsPropertySignature create( + boolean readonly, + ISwc4jAstExpr key, + boolean computed, + boolean optional, + List params) { + return create(readonly, key, computed, optional, null, params); + } + + public static Swc4jAstTsPropertySignature create( + boolean readonly, + ISwc4jAstExpr key, + boolean computed, + boolean optional, + ISwc4jAstExpr init, + List params) { + return create(readonly, key, computed, optional, init, params, null); + } + + public static Swc4jAstTsPropertySignature create( + boolean readonly, + ISwc4jAstExpr key, + boolean computed, + boolean optional, + ISwc4jAstExpr init, + List params, + Swc4jAstTsTypeAnn typeAnn) { + return create(readonly, key, computed, optional, init, params, typeAnn, null); + } + + public static Swc4jAstTsPropertySignature create( + boolean readonly, + ISwc4jAstExpr key, + boolean computed, + boolean optional, + ISwc4jAstExpr init, + List params, + Swc4jAstTsTypeAnn typeAnn, + Swc4jAstTsTypeParamDecl typeParams) { + return new Swc4jAstTsPropertySignature( + readonly, key, computed, optional, init, + params, typeAnn, typeParams, Swc4jSpan.DUMMY); + } + @Override public List getChildNodes() { List childNodes = SimpleList.copyOf(params); diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsQualifiedName.java b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsQualifiedName.java index 5a49d607..4ea1ee2b 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsQualifiedName.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsQualifiedName.java @@ -49,6 +49,10 @@ public Swc4jAstTsQualifiedName( setRight(right); } + public static Swc4jAstTsQualifiedName create(ISwc4jAstTsEntityName left, Swc4jAstIdent right) { + return new Swc4jAstTsQualifiedName(left, right, Swc4jSpan.DUMMY); + } + @Override public List getChildNodes() { return SimpleList.of(left, right); diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsRestType.java b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsRestType.java index d6f936bc..81741ac7 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsRestType.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsRestType.java @@ -47,6 +47,10 @@ public Swc4jAstTsRestType( setTypeAnn(typeAnn); } + public static Swc4jAstTsRestType create(ISwc4jAstTsType typeAnn) { + return new Swc4jAstTsRestType(typeAnn, Swc4jSpan.DUMMY); + } + @Override public List getChildNodes() { return SimpleList.of(typeAnn); diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsSetterSignature.java b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsSetterSignature.java index dc2e7e3f..7d4ea651 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsSetterSignature.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsSetterSignature.java @@ -61,6 +61,34 @@ public Swc4jAstTsSetterSignature( setReadonly(readonly); } + public static Swc4jAstTsSetterSignature create(ISwc4jAstExpr key, ISwc4jAstTsFnParam param) { + return create(false, key, param); + } + + public static Swc4jAstTsSetterSignature create( + boolean readonly, + ISwc4jAstExpr key, + ISwc4jAstTsFnParam param) { + return create(readonly, key, false, param); + } + + public static Swc4jAstTsSetterSignature create( + boolean readonly, + ISwc4jAstExpr key, + boolean computed, + ISwc4jAstTsFnParam param) { + return create(readonly, key, computed, false, param); + } + + public static Swc4jAstTsSetterSignature create( + boolean readonly, + ISwc4jAstExpr key, + boolean computed, + boolean optional, + ISwc4jAstTsFnParam param) { + return new Swc4jAstTsSetterSignature(readonly, key, computed, optional, param, Swc4jSpan.DUMMY); + } + @Override public List getChildNodes() { return SimpleList.of(key, param); diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsThisType.java b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsThisType.java index 9376baa0..6368e4e2 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsThisType.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsThisType.java @@ -40,6 +40,10 @@ public Swc4jAstTsThisType( super(span); } + public static Swc4jAstTsThisType create() { + return new Swc4jAstTsThisType(Swc4jSpan.DUMMY); + } + @Override public List getChildNodes() { return EMPTY_CHILD_NODES; diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTplLitType.java b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTplLitType.java index 618f5fa4..d8df764c 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTplLitType.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTplLitType.java @@ -54,6 +54,14 @@ public Swc4jAstTsTplLitType( this.types.forEach(node -> node.setParent(this)); } + public static Swc4jAstTsTplLitType create(List types) { + return create(types, SimpleList.of()); + } + + public static Swc4jAstTsTplLitType create(List types, List quasis) { + return new Swc4jAstTsTplLitType(types, quasis, Swc4jSpan.DUMMY); + } + @Override public List getChildNodes() { List childNodes = SimpleList.copyOf(types); diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTupleElement.java b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTupleElement.java index 7fbf256c..1fcdbc55 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTupleElement.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTupleElement.java @@ -48,6 +48,14 @@ public Swc4jAstTsTupleElement( setTy(ty); } + public static Swc4jAstTsTupleElement create(ISwc4jAstTsType ty) { + return create(null, ty); + } + + public static Swc4jAstTsTupleElement create(ISwc4jAstPat label, ISwc4jAstTsType ty) { + return new Swc4jAstTsTupleElement(label, ty, Swc4jSpan.DUMMY); + } + @Override public List getChildNodes() { List childNodes = SimpleList.of(ty); diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTupleType.java b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTupleType.java index 5bc49461..e5fcec7a 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTupleType.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTupleType.java @@ -19,7 +19,6 @@ import com.caoccao.javet.swc4j.ast.Swc4jAst; import com.caoccao.javet.swc4j.ast.enums.Swc4jAstType; import com.caoccao.javet.swc4j.ast.interfaces.ISwc4jAst; -import com.caoccao.javet.swc4j.ast.interfaces.ISwc4jAstTsFnParam; import com.caoccao.javet.swc4j.ast.interfaces.ISwc4jAstTsType; import com.caoccao.javet.swc4j.ast.visitors.ISwc4jAstVisitor; import com.caoccao.javet.swc4j.ast.visitors.Swc4jAstVisitorResponse; @@ -47,6 +46,14 @@ public Swc4jAstTsTupleType( this.elemTypes.forEach(node -> node.setParent(this)); } + public static Swc4jAstTsTupleType create() { + return create(SimpleList.of()); + } + + public static Swc4jAstTsTupleType create(List elemTypes) { + return new Swc4jAstTsTupleType(elemTypes, Swc4jSpan.DUMMY); + } + @Override public List getChildNodes() { return SimpleList.copyOf(elemTypes); diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTypeAnn.java b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTypeAnn.java index d663958e..39b1d1df 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTypeAnn.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTypeAnn.java @@ -46,6 +46,10 @@ public Swc4jAstTsTypeAnn( setTypeAnn(typeAnn); } + public static Swc4jAstTsTypeAnn create(ISwc4jAstTsType typeAnn) { + return new Swc4jAstTsTypeAnn(typeAnn, Swc4jSpan.DUMMY); + } + @Override public List getChildNodes() { return SimpleList.of(typeAnn); diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTypeLit.java b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTypeLit.java index c76ed3cd..bde4321e 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTypeLit.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTypeLit.java @@ -47,6 +47,14 @@ public Swc4jAstTsTypeLit( this.members.forEach(node -> node.setParent(this)); } + public static Swc4jAstTsTypeLit create() { + return create(SimpleList.of()); + } + + public static Swc4jAstTsTypeLit create(List members) { + return new Swc4jAstTsTypeLit(members, Swc4jSpan.DUMMY); + } + @Override public List getChildNodes() { return SimpleList.copyOf(members); diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTypeOperator.java b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTypeOperator.java index e5fb9387..0f9c827f 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTypeOperator.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTypeOperator.java @@ -51,6 +51,10 @@ public Swc4jAstTsTypeOperator( setTypeAnn(typeAnn); } + public static Swc4jAstTsTypeOperator create(Swc4jAstTsTypeOperatorOp op, ISwc4jAstTsType typeAnn) { + return new Swc4jAstTsTypeOperator(op, typeAnn, Swc4jSpan.DUMMY); + } + @Override public List getChildNodes() { return SimpleList.of(typeAnn); diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTypeParam.java b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTypeParam.java index 7753f18e..1f1e91c7 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTypeParam.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTypeParam.java @@ -64,6 +64,41 @@ public Swc4jAstTsTypeParam( setOut(out); } + public static Swc4jAstTsTypeParam create(Swc4jAstIdent name) { + return create(name, false); + } + + public static Swc4jAstTsTypeParam create(Swc4jAstIdent name, boolean in) { + return create(name, in, false); + } + + public static Swc4jAstTsTypeParam create(Swc4jAstIdent name, boolean in, boolean out) { + return create(name, in, out, false); + } + + public static Swc4jAstTsTypeParam create(Swc4jAstIdent name, boolean in, boolean out, boolean _const) { + return create(name, in, out, _const, null); + } + + public static Swc4jAstTsTypeParam create( + Swc4jAstIdent name, + boolean in, + boolean out, + boolean _const, + ISwc4jAstTsType constraint) { + return create(name, in, out, _const, constraint, null); + } + + public static Swc4jAstTsTypeParam create( + Swc4jAstIdent name, + boolean in, + boolean out, + boolean _const, + ISwc4jAstTsType constraint, + ISwc4jAstTsType _default) { + return new Swc4jAstTsTypeParam(name, in, out, _const, constraint, _default, Swc4jSpan.DUMMY); + } + @Override public List getChildNodes() { List childNodes = SimpleList.of(name); diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTypeParamDecl.java b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTypeParamDecl.java index df154e8d..fc769ba1 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTypeParamDecl.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTypeParamDecl.java @@ -44,6 +44,14 @@ public Swc4jAstTsTypeParamDecl( this.params.forEach(node -> node.setParent(this)); } + public static Swc4jAstTsTypeParamDecl create() { + return create(SimpleList.of()); + } + + public static Swc4jAstTsTypeParamDecl create(List params) { + return new Swc4jAstTsTypeParamDecl(params, Swc4jSpan.DUMMY); + } + @Override public List getChildNodes() { return SimpleList.copyOf(params); diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTypeParamInstantiation.java b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTypeParamInstantiation.java index 826a336f..44a9dec7 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTypeParamInstantiation.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTypeParamInstantiation.java @@ -47,6 +47,14 @@ public Swc4jAstTsTypeParamInstantiation( this.params.forEach(node -> node.setParent(this)); } + public static Swc4jAstTsTypeParamInstantiation create() { + return create(SimpleList.of()); + } + + public static Swc4jAstTsTypeParamInstantiation create(List params) { + return new Swc4jAstTsTypeParamInstantiation(params, Swc4jSpan.DUMMY); + } + @Override public List getChildNodes() { return SimpleList.copyOf(params); diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTypePredicate.java b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTypePredicate.java index 9999d22c..05727ecd 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTypePredicate.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTypePredicate.java @@ -52,6 +52,21 @@ public Swc4jAstTsTypePredicate( setTypeAnn(typeAnn); } + public static Swc4jAstTsTypePredicate create(ISwc4jAstTsThisTypeOrIdent paramName) { + return create(false, paramName); + } + + public static Swc4jAstTsTypePredicate create(boolean asserts, ISwc4jAstTsThisTypeOrIdent paramName) { + return create(asserts, paramName, null); + } + + public static Swc4jAstTsTypePredicate create( + boolean asserts, + ISwc4jAstTsThisTypeOrIdent paramName, + Swc4jAstTsTypeAnn typeAnn) { + return new Swc4jAstTsTypePredicate(asserts, paramName, typeAnn, Swc4jSpan.DUMMY); + } + @Override public List getChildNodes() { List childNodes = SimpleList.of(paramName); diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTypeQuery.java b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTypeQuery.java index baf97666..816d4ef7 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTypeQuery.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTypeQuery.java @@ -49,6 +49,16 @@ public Swc4jAstTsTypeQuery( setTypeArgs(typeArgs); } + public static Swc4jAstTsTypeQuery create(ISwc4jAstTsTypeQueryExpr exprName) { + return create(exprName, null); + } + + public static Swc4jAstTsTypeQuery create( + ISwc4jAstTsTypeQueryExpr exprName, + Swc4jAstTsTypeParamInstantiation typeArgs) { + return new Swc4jAstTsTypeQuery(exprName, typeArgs, Swc4jSpan.DUMMY); + } + @Override public List getChildNodes() { List childNodes = SimpleList.of(exprName); diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTypeRef.java b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTypeRef.java index d3a46e5c..95a14bf3 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTypeRef.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsTypeRef.java @@ -49,6 +49,16 @@ public Swc4jAstTsTypeRef( setTypeParams(typeParams); } + public static Swc4jAstTsTypeRef create(ISwc4jAstTsEntityName typeName) { + return create(typeName, null); + } + + public static Swc4jAstTsTypeRef create( + ISwc4jAstTsEntityName typeName, + Swc4jAstTsTypeParamInstantiation typeParams) { + return new Swc4jAstTsTypeRef(typeName, typeParams, Swc4jSpan.DUMMY); + } + @Override public List getChildNodes() { List childNodes = SimpleList.of(typeName); diff --git a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsUnionType.java b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsUnionType.java index 81dea8d7..b79e84d2 100644 --- a/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsUnionType.java +++ b/src/main/java/com/caoccao/javet/swc4j/ast/ts/Swc4jAstTsUnionType.java @@ -49,6 +49,14 @@ public Swc4jAstTsUnionType( this.types.forEach(node -> node.setParent(this)); } + public static Swc4jAstTsUnionType create() { + return create(SimpleList.of()); + } + + public static Swc4jAstTsUnionType create(List types) { + return new Swc4jAstTsUnionType(types, Swc4jSpan.DUMMY); + } + @Override public List getChildNodes() { return SimpleList.copyOf(types);