Skip to content

Commit 04bf39b

Browse files
committed
fix(ts): fix of keywordS
1 parent d16dac7 commit 04bf39b

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

chapi-ast-typescript/src/main/antlr/TypeScriptParser.g4

+1
Original file line numberDiff line numberDiff line change
@@ -983,6 +983,7 @@ keyword
983983
| Namespace
984984
| Number
985985
| Boolean
986+
| Of
986987
;
987988

988989
getter

chapi-ast-typescript/src/main/kotlin/chapi/ast/typescriptast/TypeScriptFullIdentListener.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ class TypeScriptFullIdentListener(node: TSIdentify) : TypeScriptAstListener() {
589589
}
590590

591591
private fun parseStatement(context: TypeScriptParser.SourceElementContext) {
592-
val stmtChild = context.statement().getChild(0)
592+
val stmtChild = context.statement()?.getChild(0) ?: return
593593
when (val childType = stmtChild::class.java.simpleName) {
594594
"ReturnStatementContext" -> {
595595
val returnStmt = stmtChild as TypeScriptParser.ReturnStatementContext

chapi-ast-typescript/src/test/kotlin/chapi/ast/typescriptast/TypeScriptAnalyserTest.kt

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
package chapi.ast.typescriptast
22

33
import chapi.domain.core.DataStructType
4-
import org.junit.jupiter.api.Assertions.*
5-
import org.junit.jupiter.api.Disabled
4+
import org.junit.jupiter.api.Assertions.assertEquals
65
import org.junit.jupiter.api.Test
7-
import java.io.File
86

97
internal class TypeScriptAnalyserTest {
108
@Test

chapi-ast-typescript/src/test/kotlin/chapi/ast/typescriptast/TypeScriptBugTest.kt

+9
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ function test() {
1414
alert("test");
1515
}
1616
exports.test = test;
17+
"""
18+
19+
TypeScriptAnalyser().analysis(code, "index.tsx")
20+
}
21+
22+
@Test
23+
fun backend_arrow_function2() {
24+
val code = """
25+
import {EMPTY, Observable, of} from 'rxjs';
1726
"""
1827

1928
TypeScriptAnalyser().analysis(code, "index.tsx")

0 commit comments

Comments
 (0)