From 55532e64fa8c382f54cf5bb6d38700f92a2c0797 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Fabianski?= Date: Mon, 12 Feb 2024 15:23:38 +0100 Subject: [PATCH] feat(golang): handle method_declaration the same as function_declaration (#1494) --- internal/languages/golang/pattern/pattern.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/languages/golang/pattern/pattern.go b/internal/languages/golang/pattern/pattern.go index 3c1175bb5..5a98c8621 100644 --- a/internal/languages/golang/pattern/pattern.go +++ b/internal/languages/golang/pattern/pattern.go @@ -138,7 +138,7 @@ func (*Pattern) IsAnchored(node *tree.Node) (bool, bool) { } } - if parent.Type() == "function_declaration" { + if slices.Contains([]string{"function_declaration", "method_declaration"}, parent.Type()) { // parameters if node == parent.ChildByFieldName("parameters") { return true, false @@ -150,6 +150,7 @@ func (*Pattern) IsAnchored(node *tree.Node) (bool, bool) { // function declaration_list unAnchored := []string{ "function_declaration", + "method_declaration", "var_declaration", "literal_value", }