diff --git a/chapi-ast-typescript/src/main/antlr/TypeScriptParser.g4 b/chapi-ast-typescript/src/main/antlr/TypeScriptParser.g4 index b6dcab2c..0e0146b5 100644 --- a/chapi-ast-typescript/src/main/antlr/TypeScriptParser.g4 +++ b/chapi-ast-typescript/src/main/antlr/TypeScriptParser.g4 @@ -922,7 +922,7 @@ singleExpression | This # ThisExpression | Super # SuperExpression - | typeArguments? identifierName singleExpression? # IdentifierExpression + | typeArguments? identifierName singleExpression? # IdentifierExpression | literal # LiteralExpression | arrayLiteral # ArrayLiteralExpression | objectLiteral # ObjectLiteralExpression diff --git a/chapi-ast-typescript/src/main/kotlin/chapi/ast/typescriptast/TypeScriptFullIdentListener.kt b/chapi-ast-typescript/src/main/kotlin/chapi/ast/typescriptast/TypeScriptFullIdentListener.kt index 80f0be61..496b5f07 100644 --- a/chapi-ast-typescript/src/main/kotlin/chapi/ast/typescriptast/TypeScriptFullIdentListener.kt +++ b/chapi-ast-typescript/src/main/kotlin/chapi/ast/typescriptast/TypeScriptFullIdentListener.kt @@ -882,34 +882,38 @@ class TypeScriptFullIdentListener(node: TSIdentify) : TypeScriptAstListener() { localVars[varName] = newSingleExpr.singleExpression().text } - - is IdentifierExpressionContext -> { - when (newSingleExpr.identifierName().text) { -// "await" -> { -// parseSingleExpression(singleExprCtx.singleExpression()) -// } -// "Number" -> { -// parseSingleExpression(singleExprCtx.singleExpression()) -// } - else -> { - println("IdentifierExpressionContext -> ${newSingleExpr.text}") - } - } + else -> { +// println("enterVariableDeclaration : $singleCtxType === ${ctx.text}") } + } + } - is TypeScriptParser.AwaitExpressionContext -> { - parseSingleExpression(newSingleExpr.singleExpression()) + is IdentifierExpressionContext -> { + when (singleExprCtx.identifierName().text) { + "await" -> { + parseSingleExpression(singleExprCtx.singleExpression()) } - - is ParenthesizedExpressionContext -> { - parseParenthesizedExpression(newSingleExpr) + "Number" -> { + parseSingleExpression(singleExprCtx.singleExpression()) } - else -> { -// println("enterVariableDeclaration : $singleCtxType === ${ctx.text}") + println("IdentifierExpressionContext -> ${singleExprCtx.text}") } } } + + is TypeScriptParser.AwaitExpressionContext -> { + parseSingleExpression(singleExprCtx.singleExpression()) + } + is TypeScriptParser.ArrowFunctionExpressionLContext -> { + // will recall by ArrowFunctionDeclaration + } + is TypeScriptParser.ArgumentsExpressionContext -> { + argumentsExpressionToCall(singleExprCtx, varName) + } + is ParenthesizedExpressionContext -> { + parseParenthesizedExpression(singleExprCtx) + } } } diff --git a/chapi-ast-typescript/src/test/kotlin/chapi/ast/typescriptast/TypeScriptAnalyserTest.kt b/chapi-ast-typescript/src/test/kotlin/chapi/ast/typescriptast/TypeScriptAnalyserTest.kt index cf6ab18d..5d15acaf 100644 --- a/chapi-ast-typescript/src/test/kotlin/chapi/ast/typescriptast/TypeScriptAnalyserTest.kt +++ b/chapi-ast-typescript/src/test/kotlin/chapi/ast/typescriptast/TypeScriptAnalyserTest.kt @@ -47,8 +47,6 @@ class TypeScriptAnalyserTest { val content = this::class.java.getResource("/grammar/Function.ts")!!.readText() val codeFile = TypeScriptAnalyser().analysis(content, "") - println(Json.encodeToString(codeFile)) - assertEquals(codeFile.DataStructures.size, 1) assertEquals(codeFile.DataStructures[0].NodeName, "default") val functions = codeFile.DataStructures[0].Functions diff --git a/chapi-ast-typescript/src/test/kotlin/chapi/ast/typescriptast/TypeScriptFullIdentListenerTest.kt b/chapi-ast-typescript/src/test/kotlin/chapi/ast/typescriptast/TypeScriptFullIdentListenerTest.kt index 5233a211..f7896eb4 100644 --- a/chapi-ast-typescript/src/test/kotlin/chapi/ast/typescriptast/TypeScriptFullIdentListenerTest.kt +++ b/chapi-ast-typescript/src/test/kotlin/chapi/ast/typescriptast/TypeScriptFullIdentListenerTest.kt @@ -840,7 +840,6 @@ function reload() { val defaultStruct = codeFile.DataStructures[0] assertEquals(1, defaultStruct.Functions.size) - println(Json.encodeToString(defaultStruct.Functions[0])) assertEquals(1, defaultStruct.Functions[0].FunctionCalls.size) assertEquals("storage->getSystemId", defaultStruct.Functions[0].FunctionCalls[0].FunctionName)