diff --git a/chapi-ast-rust/src/main/kotlin/chapi/ast/rustast/RustAstBaseListener.kt b/chapi-ast-rust/src/main/kotlin/chapi/ast/rustast/RustAstBaseListener.kt index a66bd361..4d94cbda 100644 --- a/chapi-ast-rust/src/main/kotlin/chapi/ast/rustast/RustAstBaseListener.kt +++ b/chapi-ast-rust/src/main/kotlin/chapi/ast/rustast/RustAstBaseListener.kt @@ -82,7 +82,8 @@ open class RustAstBaseListener(private val fileName: String) : RustParserBaseLis CodeImport( Source = path.joinToString("::"), UsageName = path, - Scope = "" + Scope = if (path.first() == "crate") "crate" else "cargo", + AsName = path.last() ) ) } @@ -154,7 +155,12 @@ open class RustAstBaseListener(private val fileName: String) : RustParserBaseLis } private fun lookupType(type_: Type_Context?): String { - return type_?.text ?: "" + val typeText = type_?.text + imports.filter { it.AsName == typeText }.forEach { + return it.Source + } + + return typeText ?: "" } private fun buildAttribute(outerAttribute: List): MutableList { diff --git a/chapi-ast-rust/src/test/kotlin/chapi/ast/rustast/RustFullIdentListenerTest.kt b/chapi-ast-rust/src/test/kotlin/chapi/ast/rustast/RustFullIdentListenerTest.kt index 4f5f3db7..ca6eace6 100644 --- a/chapi-ast-rust/src/test/kotlin/chapi/ast/rustast/RustFullIdentListenerTest.kt +++ b/chapi-ast-rust/src/test/kotlin/chapi/ast/rustast/RustFullIdentListenerTest.kt @@ -185,6 +185,7 @@ class RustFullIdentListenerTest { assertEquals(4, codeDataStruct.Fields.size) assertEquals("score", codeDataStruct.Fields[0].TypeValue) assertEquals("f32", codeDataStruct.Fields[0].TypeType) -// assertEquals("crate::Embedding", codeDataStruct.Fields[2].TypeType) + assertEquals("crate::Embedding", codeDataStruct.Fields[2].TypeType) + assertEquals("crate::Document", codeDataStruct.Fields[3].TypeType) } }