Skip to content

Commit

Permalink
refactor(goast): improve handling of receiver name in method decl
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Nov 9, 2024
1 parent 3fb7c27 commit 96aad92
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,13 @@ class GoFullIdentListener(var fileName: String) : GoAstListener() {
override fun enterMethodDecl(ctx: GoParser.MethodDeclContext?) {
val receiverName = this.getStructNameFromReceiver(ctx!!.receiver()?.parameters())
if (ctx.receiver() != null) {
val text = ctx.receiver().parameters().parameterDecl()[0].identifierList().text
val parameterDecl = ctx.receiver().parameters().parameterDecl()
val text = parameterDecl.getOrNull(0)?.identifierList()?.text ?: ""
receiverForCall[text] = receiverName
}

currentFunction = CodeFunction(
Name = ctx!!.IDENTIFIER().text,
Name = ctx.IDENTIFIER().text,
MultipleReturns = buildReturnTypeFromSignature(ctx.signature()),
Parameters = buildParameters(ctx.signature().parameters())
)
Expand Down

0 comments on commit 96aad92

Please sign in to comment.