Skip to content

Commit

Permalink
feat(java): add support for constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
dgian committed Dec 30, 2022
1 parent 7e2fef6 commit 8b8129e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
5 changes: 5 additions & 0 deletions queries/java/aerial.scm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
(#set! "kind" "Method")
) @type

(constructor_declaration
name: (identifier) @name
(#set! "kind" "Constructor")
) @type

(class_declaration
name: (identifier) @name
(#set! "kind" "Class")
Expand Down
15 changes: 12 additions & 3 deletions tests/treesitter/java_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe("treesitter java", function()
level = 0,
lnum = 5,
col = 0,
end_lnum = 9,
end_lnum = 10,
end_col = 1,
children = {
{
Expand Down Expand Up @@ -59,15 +59,24 @@ describe("treesitter java", function()
end_lnum = 8,
end_col = 24,
},
{
kind = "Constructor",
name = "Cl_1",
level = 1,
lnum = 9,
col = 2,
end_lnum = 9,
end_col = 12,
},
},
},
{
kind = "Enum",
name = "En_1",
level = 0,
lnum = 11,
lnum = 12,
col = 0,
end_lnum = 11,
end_lnum = 12,
end_col = 13,
},
})
Expand Down
1 change: 1 addition & 0 deletions tests/treesitter/java_test.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class Cl_1 {
void meth_2() { }
private int field_1;
public Object field_2;
Cl_1() { }
}

enum En_1 { }

0 comments on commit 8b8129e

Please sign in to comment.