Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,26 @@ parser.setLanguage(await Language.load(java));

The package also ships `grammar.js`, the queries in `queries/`, and the node types in `src/node-types.json`.

Within a declaration's `modifiers`, access keywords are named `visibility` nodes and other modifier keywords are
named `modifier` nodes. Annotations retain their own nodes, and the keyword tokens remain available for highlighting.
For example, this query captures explicitly public static methods without matching annotation text:

```scheme
(method_declaration
(modifiers (visibility) @visibility (modifier) @modifier)
name: (identifier) @method
(#eq? @visibility "public")
(#eq? @modifier "static"))
```

In Rust, depend on the [crate](https://crates.io/crates/willbooster-tree-sitter-java) and on
[willbooster-tree-sitter](https://crates.io/crates/willbooster-tree-sitter), the runtime this package is tested and
fuzzed with:

```toml
[dependencies]
tree-sitter = { package = "willbooster-tree-sitter", version = "7.0.5" }
tree-sitter-java = { package = "willbooster-tree-sitter-java", version = "4" }
tree-sitter-java = { package = "willbooster-tree-sitter-java", version = "5" }
```

```rust
Expand Down
12 changes: 8 additions & 4 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -991,9 +991,13 @@ module.exports = grammar({

modifiers: $ => repeat1(choice(
$._annotation,
'public',
'protected',
'private',
$.visibility,
$.modifier,
)),

visibility: _ => choice('public', 'protected', 'private'),

modifier: _ => choice(
'abstract',
'static',
'final',
Expand All @@ -1005,7 +1009,7 @@ module.exports = grammar({
'volatile',
'sealed',
'non-sealed',
)),
),

type_parameters: $ => seq(
'<', commaSep1($.type_parameter), '>',
Expand Down
122 changes: 70 additions & 52 deletions src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 19 additions & 1 deletion src/node-types.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading