Skip to content

Commit

Permalink
feat: unanchored class declaration (#1478)
Browse files Browse the repository at this point in the history
feat: unanchor class declaration by default
  • Loading branch information
cfabianski authored Jan 29, 2024
1 parent 1acfe03 commit 5fd994c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -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) "_"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -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) "_"
},
Expand Down
2 changes: 1 addition & 1 deletion internal/languages/java/pattern/pattern.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5fd994c

Please sign in to comment.