Skip to content

Commit

Permalink
feat(rust): fix for crash
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Jan 1, 2024
1 parent ca96312 commit 28d0078
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,10 @@ open class RustAstBaseListener(private val fileName: String) : RustParserBaseLis
it.identifier().text
}?.joinToString(".") ?: ""

val keyValues = attributeContext.attr().attrInput().delimTokenTree().tokenTree()
.mapNotNull {
val keyValues = attributeContext.attr()
?.attrInput()
?.delimTokenTree()?.tokenTree()
?.mapNotNull {
it.tokenTreeToken()
.mapNotNull { token -> token.macroIdentifierLikeToken() }
.map { tokenContext ->
Expand All @@ -187,7 +189,7 @@ open class RustAstBaseListener(private val fileName: String) : RustParserBaseLis
Value = tokenContext.identifier().text
)
}
}.flatten()
}?.flatten() ?: listOf()

CodeAnnotation(
Name = annotationName,
Expand Down Expand Up @@ -227,9 +229,9 @@ open class RustAstBaseListener(private val fileName: String) : RustParserBaseLis
}

localVars += ctx.functionParameters()?.functionParam()?.map {
val functionParamPattern = it.functionParamPattern()
val varName = functionParamPattern.pattern()?.text ?: ""
val varType = functionParamPattern.type_()?.text ?: ""
val pattern = it.functionParamPattern()
val varName = pattern?.pattern()?.text ?: ""
val varType = pattern?.type_()?.text ?: ""
varName to varType
}?.toMap() ?: mapOf()
}
Expand All @@ -244,8 +246,8 @@ open class RustAstBaseListener(private val fileName: String) : RustParserBaseLis
return functionParameters.functionParam().map {
val functionParamPattern = it.functionParamPattern()
CodeProperty(
TypeValue = functionParamPattern.pattern()?.text ?: "",
TypeType = functionParamPattern.type_()?.text ?: "",
TypeValue = functionParamPattern?.pattern()?.text ?: "",
TypeType = functionParamPattern?.type_()?.text ?: "",
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ internal class RustAnalyserTest {
}

@Test
@Disabled
fun allGrammarUnderResources() {
val content = this::class.java.getResource("/grammar")!!
File(content.toURI()).walkTopDown().forEach {
Expand Down

0 comments on commit 28d0078

Please # to comment.