diff --git a/chapi-ast-typescript/src/main/antlr/TypeScriptParser.g4 b/chapi-ast-typescript/src/main/antlr/TypeScriptParser.g4 index 534b2f3f..494c72a3 100644 --- a/chapi-ast-typescript/src/main/antlr/TypeScriptParser.g4 +++ b/chapi-ast-typescript/src/main/antlr/TypeScriptParser.g4 @@ -983,6 +983,7 @@ keyword | Namespace | Number | Boolean + | Of ; getter 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 f12a2f8e..c29626c2 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 @@ -589,7 +589,7 @@ class TypeScriptFullIdentListener(node: TSIdentify) : TypeScriptAstListener() { } private fun parseStatement(context: TypeScriptParser.SourceElementContext) { - val stmtChild = context.statement().getChild(0) + val stmtChild = context.statement()?.getChild(0) ?: return when (val childType = stmtChild::class.java.simpleName) { "ReturnStatementContext" -> { val returnStmt = stmtChild as TypeScriptParser.ReturnStatementContext 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 a38a2f6e..cf1f818e 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 @@ -1,10 +1,8 @@ package chapi.ast.typescriptast import chapi.domain.core.DataStructType -import org.junit.jupiter.api.Assertions.* -import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test -import java.io.File internal class TypeScriptAnalyserTest { @Test diff --git a/chapi-ast-typescript/src/test/kotlin/chapi/ast/typescriptast/TypeScriptBugTest.kt b/chapi-ast-typescript/src/test/kotlin/chapi/ast/typescriptast/TypeScriptBugTest.kt index 034f9a10..dc9fa232 100644 --- a/chapi-ast-typescript/src/test/kotlin/chapi/ast/typescriptast/TypeScriptBugTest.kt +++ b/chapi-ast-typescript/src/test/kotlin/chapi/ast/typescriptast/TypeScriptBugTest.kt @@ -14,6 +14,15 @@ function test() { alert("test"); } exports.test = test; +""" + + TypeScriptAnalyser().analysis(code, "index.tsx") + } + + @Test + fun backend_arrow_function2() { + val code = """ +import {EMPTY, Observable, of} from 'rxjs'; """ TypeScriptAnalyser().analysis(code, "index.tsx")