Skip to content

Commit

Permalink
Revert "refactor(rust): simplify logic"
Browse files Browse the repository at this point in the history
This reverts commit 1486098.
  • Loading branch information
phodal committed Jan 1, 2024
1 parent 1486098 commit ebeb903
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import chapi.ast.antlr.RustParser
import chapi.ast.antlr.RustParser.ItemContext
import chapi.ast.antlr.RustParser.SimplePathContext
import chapi.ast.antlr.RustParser.TypePathSegmentContext
import chapi.ast.antlr.RustParser.Type_Context
import chapi.ast.antlr.RustParserBaseListener
import chapi.domain.core.*
import org.antlr.v4.runtime.ParserRuleContext
Expand Down Expand Up @@ -161,13 +162,18 @@ open class RustAstBaseListener(private val fileName: String) : RustParserBaseLis
private fun buildFields(structFields: RustParser.StructFieldsContext?): List<CodeField> {
return structFields?.structField()?.map {
CodeField(
TypeType = lookupByType(it.type_()?.text),
TypeType = lookupType(it.type_()),
Annotations = buildAttribute(it.outerAttribute()),
TypeValue = it.identifier()?.text ?: "",
)
} ?: emptyList()
}

private fun lookupType(type_: Type_Context?): String {
val typeText = type_?.text
return lookupByType(typeText)
}

open fun lookupByType(typeText: String?): String {
if (typeText == null) return ""
val text = if (typeText.contains("::")) {
Expand Down

0 comments on commit ebeb903

Please # to comment.