Skip to content

Commit

Permalink
fix(ts): fix all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Nov 17, 2022
1 parent ec26282 commit e089ac6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
10 changes: 5 additions & 5 deletions chapi-ast-typescript/src/main/antlr/TypeScriptParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -947,17 +947,17 @@ functionExpression
;

arrowFunctionDeclaration
: Async? arrowFunctionParameters? typeAnnotation? '=>' arrowFunctionBody
: Async? arrowFunctionParameters typeAnnotation? '=>' arrowFunctionBody
;

arrowFunctionParameters
: identifierName
| typeRef? '(' formalParameterList? ','? ')'
: typeRef? '(' formalParameterList? ','? ')'
| identifierName
;

arrowFunctionBody
: singleExpression
| '{' statementList? '}'
: '{' statementList? '}'
| singleExpression
;

classExpression
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ class TypeScriptFullIdentListener(node: TSIdentify) : TypeScriptAstListener() {
}

else -> {
println("parseStmt childType -> :${child.javaClass.name}")
// println("parseStmt childType -> :${child.javaClass.name}")
}
}
}
Expand Down Expand Up @@ -826,7 +826,12 @@ class TypeScriptFullIdentListener(node: TSIdentify) : TypeScriptAstListener() {
}

is TypeScriptParser.IdentifierExpressionContext -> {
// println("enterExpressionStatement -> IdentifierExpressionContext: ${singleExprCtx.text}")
currentFunc.FunctionCalls += CodeCall(
Parameters = arrayOf(),
FunctionName = singleExprCtx.identifierName().text,
NodeName = "",
Position = buildPosition(ctx)
)
}

else -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,7 @@ class TypeScriptAnalyserTest {
assertEquals(codeFile.DataStructures.size, 1)
assertEquals(codeFile.DataStructures[0].NodeName, "default")
val functions = codeFile.DataStructures[0].Functions
assertEquals(functions.size, 3)

val fields = codeFile.DataStructures[0].Fields
assertEquals(fields.size, 6)
assertEquals(functions.size, 9)
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -708,13 +708,15 @@ const BadSmellThreshold = () => {

assertEquals(1, defaultStruct.Functions.size)

println(Json.encodeToString(defaultStruct))

val firstFunc = defaultStruct.Functions[0]
assertEquals("index.tsx", firstFunc.FilePath)
assertEquals("BadSmellThreshold", firstFunc.Name)

val innerFunc = firstFunc.InnerFunctions[0]
assertEquals("onFinish", innerFunc.Name)
assertEquals("updateSystemInfo->then", innerFunc.FunctionCalls[0].FunctionName)
assertEquals("updateSystemInfo", innerFunc.FunctionCalls[0].FunctionName)
}

@Test
Expand Down

0 comments on commit e089ac6

Please sign in to comment.