Skip to content

Commit

Permalink
✨ feat: Remove ident, ident name
Browse files Browse the repository at this point in the history
  • Loading branch information
caoccao committed Oct 26, 2024
1 parent fe59f33 commit cd8fff2
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void manipulate(JavaFunctionContext functionContext, Swc4jAstBinExpr ast)
for (ISwc4jAstExpr expr : new ISwc4jAstExpr[]{ast.getLeft(), ast.getRight()}) {
switch (expr.getType()) {
case Ident:
String name = Ts2JavaAstIdent.getSym(expr.as(Swc4jAstIdent.class));
String name = expr.as(Swc4jAstIdent.class).getSym();
stackSize += JavaByteCodeOpLoad.generate(functionContext, name, methodVisitor);
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,4 @@ public static Class<?> getClass(Swc4jAstBindingIdent ast) {
.map(Ts2JavaAstTsTypeAnn::getClass)
.orElse((Class) Object.class);
}

public static String getIdent(Swc4jAstBindingIdent ast) {
return Ts2JavaAstIdent.getSym(ast.getId());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public DynamicType.Builder<?> transpile(
DynamicType.Builder<?> builder,
Swc4jAstClassDecl ast) {
String className = StringUtils.isEmpty(packageName)
? Ts2JavaAstIdent.getSym(ast.getIdent())
: packageName + "." + Ts2JavaAstIdent.getSym(ast.getIdent());
? ast.getIdent().getSym()
: packageName + "." + ast.getIdent().getSym();
builder = builder.name(className);
builder = new Ts2JavaAstClass().transpile(builder, ast.getClazz());
return builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public DynamicType.Builder<?> transpile(
SimpleMap.of("keyType", ast.getKey().getClass().getSimpleName())));

}
String name = Ts2JavaAstIdentName.getSym(ast.getKey().as(Swc4jAstIdentName.class));
String name = ast.getKey().as(Swc4jAstIdentName.class).getSym();
Swc4jAstAccessibility accessibility = ast.getAccessibility().orElse(Swc4jAstAccessibility.Public);
builder = new Ts2JavaAstClassFunction(name, accessibility).transpile(builder, ast.getFunction());
return builder;
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static JavaStackObject getStackObject(int index, Swc4jAstParam ast) {
ISwc4jAstPat pat = ast.getPat();
switch (pat.getType()) {
case BindingIdent:
String ident = Ts2JavaAstBindingIdent.getIdent(pat.as(Swc4jAstBindingIdent.class));
String ident = pat.as(Swc4jAstBindingIdent.class).getId().getSym();
Class<?> type = Ts2JavaAstBindingIdent.getClass(pat.as(Swc4jAstBindingIdent.class));
return new JavaStackObject(index, ident, type);
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private Ts2JavaAstTsEntityName() {
public static String getName(ISwc4jAstTsEntityName ast) {
switch (ast.getType()) {
case Ident:
return Ts2JavaAstIdent.getSym(ast.as(Swc4jAstIdent.class));
return ast.as(Swc4jAstIdent.class).getSym();
default:
return null;
}
Expand Down

0 comments on commit cd8fff2

Please sign in to comment.