Skip to content

Commit

Permalink
fix(ts): fix call issues
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Nov 17, 2022
1 parent 7474189 commit 1dd814b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 24 deletions.
2 changes: 1 addition & 1 deletion chapi-ast-typescript/src/main/antlr/TypeScriptParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ singleExpression

| This # ThisExpression
| Super # SuperExpression
| typeArguments? identifierName singleExpression? # IdentifierExpression
| typeArguments? identifierName singleExpression? # IdentifierExpression
| literal # LiteralExpression
| arrayLiteral # ArrayLiteralExpression
| objectLiteral # ObjectLiteralExpression
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1dd814b

Please sign in to comment.