Skip to content

Commit de13d9d

Browse files
committed
feat(go): fix null issues
1 parent 455e747 commit de13d9d

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

chapi-ast-go/src/main/kotlin/chapi/ast/goast/GoFullIdentListener.kt

+10-7
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ class GoFullIdentListener(var fileName: String) : GoAstListener() {
105105
"StructTypeContext" -> {
106106
buildStruct(identifyName, typeChild)
107107
}
108+
108109
else -> {
109110

110111
}
@@ -171,14 +172,16 @@ class GoFullIdentListener(var fileName: String) : GoAstListener() {
171172
NodeName = primaryExprCtx.getChild(0).text
172173
)
173174
val argumentsContext = primaryExprCtx.getChild(1) as GoParser.ArgumentsContext
174-
for (expressionContext in argumentsContext.expressionList().expression()) {
175-
val codeProperty = CodeProperty(
176-
TypeValue = expressionContext.text,
177-
TypeType = ""
178-
)
179-
codeCall.Parameters += codeProperty
175+
176+
if (argumentsContext.expressionList() != null) {
177+
for (expressionContext in argumentsContext.expressionList().expression()) {
178+
codeCall.Parameters += CodeProperty(
179+
TypeValue = expressionContext.text,
180+
TypeType = ""
181+
)
182+
}
183+
currentFunction.FunctionCalls += codeCall
180184
}
181-
currentFunction.FunctionCalls += codeCall
182185
}
183186
}
184187
}

chapi-ast-go/src/test/kotlin/chapi/ast/goast/GoAnalyserTest.kt

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import org.junit.jupiter.api.Test
66
internal class GoAnalyserTest {
77
@Test
88
fun analysis() {
9-
var helloworld = """
9+
val helloworld = """
1010
package main
1111
import "fmt"
1212
func main() {
@@ -17,7 +17,6 @@ func main() {
1717
}
1818

1919
@Test
20-
@Ignore
2120
fun analysis2() {
2221
val helloworldApi = """package main
2322

0 commit comments

Comments
 (0)