Skip to content

Commit 6003a54

Browse files
committed
fix(goast): swap TypeValue and TypeType assignment
Update the `CodeProperty` object creation by correctly assigning `TypeValue` and `TypeType` from the localVars map and the processed type, respectively. This fixes the order of the properties in the `CodeProperty` instance. Additionally, the test case for `GoFullIdentListenerTest` has been updated to reflect the corrected `TypeValue` with a proper string literal.
1 parent 185a305 commit 6003a54

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ class GoFullIdentListener(var fileName: String) : GoAstListener() {
263263
return child.expressionList()?.expression()?.map {
264264
val (value, typetype) = processingStringType(it.text, "")
265265
if (localVars.containsKey(value)) {
266-
return@map CodeProperty(TypeValue = value, TypeType = localVars[value]!!)
266+
return@map CodeProperty(TypeValue = localVars[value]!!, TypeType = typetype)
267267
}
268268

269269
CodeProperty(TypeValue = value, TypeType = typetype)

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ func (d *Dao) QueryBuglyProjectList() (projectList []string, err error) {
325325
assertEquals(functionCalls[0].NodeName, "Dao")
326326
assertEquals(functionCalls[0].FunctionName, "Raw")
327327
assertEquals(functionCalls[0].Parameters.size, 1)
328-
assertEquals(functionCalls[0].Parameters[0].TypeValue, "sql")
328+
assertEquals(functionCalls[0].Parameters[0].TypeValue, "\"select DISTINCT project_name from bugly_projects\"")
329329

330330
assertEquals(functionCalls[1].NodeName, "Dao")
331331
assertEquals(functionCalls[1].FunctionName, "Rows")

0 commit comments

Comments
 (0)