Skip to content

Commit

Permalink
refactor(kotlin): update null safety in GoFullIdentListener.kt
Browse files Browse the repository at this point in the history
Avoid potential null pointer exceptions by using safe call operator on typeDef references within the buildTypeSpec function. This change ensures the code is more robust when dealing with optional types.
  • Loading branch information
phodal committed Nov 15, 2024
1 parent 285c152 commit 23d7f29
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class GoFullIdentListener(var fileName: String) : GoAstListener() {
private fun buildTypeSpec(typeSpec: GoParser.TypeSpecContext) {
val typeDef = typeSpec.typeDef()
val identifyName = typeDef?.IDENTIFIER()?.text ?: ""
typeDef.type_().typeLit()?.let {
typeDef?.type_()?.typeLit()?.let {
when (val typeChild = it.getChild(0)) {
is GoParser.StructTypeContext -> {
buildStruct(identifyName, typeChild)
Expand Down

0 comments on commit 23d7f29

Please sign in to comment.