Skip to content

Commit 8132dc7

Browse files
committed
feat(rust): make return type works
1 parent ebeb903 commit 8132dc7

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

chapi-ast-rust/src/main/kotlin/chapi/ast/rustast/RustAstBaseListener.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,8 @@ open class RustAstBaseListener(private val fileName: String) : RustParserBaseLis
333333
}
334334

335335
open fun buildReturnType(functionReturnType: RustParser.FunctionReturnTypeContext?): String {
336-
return functionReturnType?.type_()?.text ?: ""
336+
val typeContext: Type_Context? = functionReturnType?.type_()
337+
return lookupType(typeContext)
337338
}
338339

339340
open fun buildParameters(functionParameters: RustParser.FunctionParametersContext?): List<CodeProperty> {

chapi-ast-rust/src/test/kotlin/chapi/ast/rustast/RustFullIdentListenerTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ class RustFullIdentListenerTest {
412412

413413
val secondFunction = codeDataStruct.Functions[1]
414414
assertEquals("main", secondFunction.Name)
415-
// assertEquals("std::io::Result", secondFunction.ReturnType)
415+
assertEquals("std::io::Result", secondFunction.ReturnType)
416416
assertEquals(9, secondFunction.FunctionCalls.size)
417417
secondFunction.FunctionCalls.map {
418418
println("${it.NodeName} -> ${it.FunctionName} -> ${it.OriginNodeName}")

0 commit comments

Comments
 (0)