Skip to content

Commit ebeb903

Browse files
committed
Revert "refactor(rust): simplify logic"
This reverts commit 1486098.
1 parent 1486098 commit ebeb903

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import chapi.ast.antlr.RustParser
44
import chapi.ast.antlr.RustParser.ItemContext
55
import chapi.ast.antlr.RustParser.SimplePathContext
66
import chapi.ast.antlr.RustParser.TypePathSegmentContext
7+
import chapi.ast.antlr.RustParser.Type_Context
78
import chapi.ast.antlr.RustParserBaseListener
89
import chapi.domain.core.*
910
import org.antlr.v4.runtime.ParserRuleContext
@@ -161,13 +162,18 @@ open class RustAstBaseListener(private val fileName: String) : RustParserBaseLis
161162
private fun buildFields(structFields: RustParser.StructFieldsContext?): List<CodeField> {
162163
return structFields?.structField()?.map {
163164
CodeField(
164-
TypeType = lookupByType(it.type_()?.text),
165+
TypeType = lookupType(it.type_()),
165166
Annotations = buildAttribute(it.outerAttribute()),
166167
TypeValue = it.identifier()?.text ?: "",
167168
)
168169
} ?: emptyList()
169170
}
170171

172+
private fun lookupType(type_: Type_Context?): String {
173+
val typeText = type_?.text
174+
return lookupByType(typeText)
175+
}
176+
171177
open fun lookupByType(typeText: String?): String {
172178
if (typeText == null) return ""
173179
val text = if (typeText.contains("::")) {

0 commit comments

Comments
 (0)