diff --git a/internal/languages/java/.snapshots/TestPattern-catch_types_is_a_container_type b/internal/languages/java/.snapshots/TestPattern-catch_types_is_a_container_type index b4e75a0c9..87c9810b1 100644 --- a/internal/languages/java/.snapshots/TestPattern-catch_types_is_a_container_type +++ b/internal/languages/java/.snapshots/TestPattern-catch_types_is_a_container_type @@ -1,5 +1,5 @@ (*builder.Result)({ - Query: (string) (len=334) "([(class_declaration . name: (_) . [(class_body [(method_declaration . [ (void_type )] @param1 . [ (identifier )] @param2 . [ (formal_parameters )] . [(block [(try_statement [ (block )] [(catch_clause . [(catch_formal_parameter . [(catch_type (_) @match)] . [ (identifier )] @param3 .)] . [ (block )] .)])] )] .)] )] .)] @root)", + Query: (string) (len=328) "([(class_declaration name: (_) [(class_body [(method_declaration . [ (void_type )] @param1 . [ (identifier )] @param2 . [ (formal_parameters )] . [(block [(try_statement [ (block )] [(catch_clause . [(catch_formal_parameter . [(catch_type (_) @match)] . [ (identifier )] @param3 .)] . [ (block )] .)])] )] .)] )])] @root)", VariableNames: ([]string) (len=1) { (string) (len=1) "_" }, diff --git a/internal/languages/java/.snapshots/TestPattern-method_params_is_a_container_type b/internal/languages/java/.snapshots/TestPattern-method_params_is_a_container_type index b28c5b329..15080fda8 100644 --- a/internal/languages/java/.snapshots/TestPattern-method_params_is_a_container_type +++ b/internal/languages/java/.snapshots/TestPattern-method_params_is_a_container_type @@ -1,5 +1,5 @@ (*builder.Result)({ - Query: (string) (len=196) "([(class_declaration . name: (_) . [(class_body [(method_declaration . [ (void_type )] @param1 . [ (identifier )] @param2 . [(formal_parameters . (_) @match . )] . [ (block )] .)] )] .)] @root)", + Query: (string) (len=190) "([(class_declaration name: (_) [(class_body [(method_declaration . [ (void_type )] @param1 . [ (identifier )] @param2 . [(formal_parameters . (_) @match . )] . [ (block )] .)] )])] @root)", VariableNames: ([]string) (len=1) { (string) (len=1) "_" }, diff --git a/internal/languages/java/pattern/pattern.go b/internal/languages/java/pattern/pattern.go index 9e3f08446..65fca7f21 100644 --- a/internal/languages/java/pattern/pattern.go +++ b/internal/languages/java/pattern/pattern.go @@ -101,7 +101,7 @@ func (*Pattern) IsAnchored(node *tree.Node) (bool, bool) { // function block // lambda () -> {} block // try {} catch () {} - unAnchored := []string{"class_body", "block", "try_statement", "catch_type", "resource_specification"} + unAnchored := []string{"class_declaration", "class_body", "block", "try_statement", "catch_type", "resource_specification"} isAnchored := !slices.Contains(unAnchored, parent.Type()) return isAnchored, isAnchored