tree-sitter-java-orchard 0.5.8 → 0.5.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -2
- package/bindings/node/binding_test.js +7 -5
- package/bindings/node/index.d.ts +36 -3
- package/bindings/node/index.js +34 -8
- package/grammar.js +1 -1
- package/package.json +8 -4
- package/src/parser.c +292 -230
- package/src/tree_sitter/array.h +118 -73
- package/tree-sitter-java_orchard.wasm +0 -0
- package/tree-sitter.json +3 -2
package/README.md
CHANGED
|
@@ -4,11 +4,28 @@
|
|
|
4
4
|
[![pypi][pypi]](https://pypi.org/project/tree-sitter-java-orchard)
|
|
5
5
|
[![npm][npm]](https://www.npmjs.com/package/tree-sitter-java-orchard)
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
This is a tree-sitter grammar for Java.
|
|
8
|
+
|
|
9
|
+
### Using it
|
|
10
|
+
|
|
11
|
+
You can obtain this parser in various formats:
|
|
12
|
+
* as an archive from [the Releases page](/grammar-orchard/tree-sitter-java-orchard/releases), which contains all the generated files (bindings, parser code)
|
|
13
|
+
* as a Rust crate: `cargo add tree-sitter-java-orchard`
|
|
14
|
+
* as a Python package: `pip install tree-sitter-java-orchard`
|
|
15
|
+
* as an NPM package: `npm install tree-sitter-java-orchard`
|
|
16
|
+
|
|
17
|
+
### Contributing
|
|
9
18
|
|
|
10
19
|
Contributions are welcome, so are co-maintainers.
|
|
11
20
|
|
|
21
|
+
Unlike many grammar repositories, this one does not track generated files.
|
|
22
|
+
After cloning this repository, you'll need to run `tree-sitter generate` to obtain the parser.
|
|
23
|
+
If you want to use it via bindings, you'll also need to run `tree-sitter init`.
|
|
24
|
+
|
|
25
|
+
### Origin
|
|
26
|
+
|
|
27
|
+
This project was forked from https://github.com/tree-sitter/tree-sitter-java, to [ease the use of and collaboration on this grammar](https://codeberg.org/grammar-orchard#for-contributors).
|
|
28
|
+
|
|
12
29
|
[crates]: https://img.shields.io/crates/v/tree-sitter-java-orchard?logo=rust
|
|
13
30
|
[pypi]: https://img.shields.io/pypi/v/tree-sitter-java-orchard?logo=pypi&logoColor=ffd242
|
|
14
31
|
[npm]: https://img.shields.io/npm/v/tree-sitter-java-orchard?logo=npm
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const Parser = require("tree-sitter");
|
|
1
|
+
import assert from "node:assert";
|
|
2
|
+
import { test } from "node:test";
|
|
3
|
+
import Parser from "tree-sitter";
|
|
5
4
|
|
|
6
5
|
test("can load grammar", () => {
|
|
7
6
|
const parser = new Parser();
|
|
8
|
-
assert.
|
|
7
|
+
assert.doesNotReject(async () => {
|
|
8
|
+
const { default: language } = await import("./index.js");
|
|
9
|
+
parser.setLanguage(language);
|
|
10
|
+
});
|
|
9
11
|
});
|
package/bindings/node/index.d.ts
CHANGED
|
@@ -18,10 +18,43 @@ type NodeInfo =
|
|
|
18
18
|
children: ChildNode[];
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
/**
|
|
22
|
+
* The tree-sitter language object for this grammar.
|
|
23
|
+
*
|
|
24
|
+
* @see {@linkcode https://tree-sitter.github.io/node-tree-sitter/interfaces/Parser.Language.html Parser.Language}
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* import Parser from "tree-sitter";
|
|
28
|
+
* import JavaOrchard from "tree-sitter-java-orchard";
|
|
29
|
+
*
|
|
30
|
+
* const parser = new Parser();
|
|
31
|
+
* parser.setLanguage(JavaOrchard);
|
|
32
|
+
*/
|
|
33
|
+
declare const binding: {
|
|
34
|
+
/**
|
|
35
|
+
* The inner language object.
|
|
36
|
+
* @private
|
|
37
|
+
*/
|
|
22
38
|
language: unknown;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The content of the `node-types.json` file for this grammar.
|
|
42
|
+
*
|
|
43
|
+
* @see {@linkplain https://tree-sitter.github.io/tree-sitter/using-parsers/6-static-node-types Static Node Types}
|
|
44
|
+
*/
|
|
23
45
|
nodeTypeInfo: NodeInfo[];
|
|
46
|
+
|
|
47
|
+
/** The syntax highlighting query for this grammar. */
|
|
48
|
+
HIGHLIGHTS_QUERY?: string;
|
|
49
|
+
|
|
50
|
+
/** The language injection query for this grammar. */
|
|
51
|
+
INJECTIONS_QUERY?: string;
|
|
52
|
+
|
|
53
|
+
/** The local variable query for this grammar. */
|
|
54
|
+
LOCALS_QUERY?: string;
|
|
55
|
+
|
|
56
|
+
/** The symbol tagging query for this grammar. */
|
|
57
|
+
TAGS_QUERY?: string;
|
|
24
58
|
};
|
|
25
59
|
|
|
26
|
-
|
|
27
|
-
export = language;
|
|
60
|
+
export default binding;
|
package/bindings/node/index.js
CHANGED
|
@@ -1,11 +1,37 @@
|
|
|
1
|
-
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
const root = fileURLToPath(new URL("../..", import.meta.url));
|
|
5
|
+
|
|
6
|
+
const binding = typeof process.versions.bun === "string"
|
|
7
|
+
// Support `bun build --compile` by being statically analyzable enough to find the .node file at build-time
|
|
8
|
+
? await import(`${root}/prebuilds/${process.platform}-${process.arch}/tree-sitter-java-orchard.node`)
|
|
9
|
+
: (await import("node-gyp-build")).default(root);
|
|
8
10
|
|
|
9
11
|
try {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
const nodeTypes = await import(`${root}/src/node-types.json`, { with: { type: "json" } });
|
|
13
|
+
binding.nodeTypeInfo = nodeTypes.default;
|
|
14
|
+
} catch { }
|
|
15
|
+
|
|
16
|
+
const queries = [
|
|
17
|
+
["HIGHLIGHTS_QUERY", `${root}/queries/highlights.scm`],
|
|
18
|
+
["INJECTIONS_QUERY", `${root}/queries/injections.scm`],
|
|
19
|
+
["LOCALS_QUERY", `${root}/queries/locals.scm`],
|
|
20
|
+
["TAGS_QUERY", `${root}/queries/tags.scm`],
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
for (const [prop, path] of queries) {
|
|
24
|
+
Object.defineProperty(binding, prop, {
|
|
25
|
+
configurable: true,
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get() {
|
|
28
|
+
delete binding[prop];
|
|
29
|
+
try {
|
|
30
|
+
binding[prop] = readFileSync(path, "utf8");
|
|
31
|
+
} catch { }
|
|
32
|
+
return binding[prop];
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default binding;
|
package/grammar.js
CHANGED
package/package.json
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tree-sitter-java-orchard",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.9",
|
|
4
4
|
"description": "Java grammar for tree-sitter",
|
|
5
|
-
"
|
|
5
|
+
"type": "module",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://codeberg.org/grammar-orchard/tree-sitter-java-orchard.git"
|
|
9
|
+
},
|
|
6
10
|
"license": "MIT",
|
|
7
11
|
"author": {
|
|
8
12
|
"name": "Ayman Nadeem",
|
|
@@ -27,13 +31,13 @@
|
|
|
27
31
|
"*.wasm"
|
|
28
32
|
],
|
|
29
33
|
"dependencies": {
|
|
30
|
-
"node-addon-api": "^8.
|
|
34
|
+
"node-addon-api": "^8.5.0",
|
|
31
35
|
"node-gyp-build": "^4.8.4"
|
|
32
36
|
},
|
|
33
37
|
"devDependencies": {
|
|
34
38
|
"prebuildify": "^6.0.1",
|
|
35
39
|
"tree-sitter": "^0.25.0",
|
|
36
|
-
"tree-sitter-cli": "^0.
|
|
40
|
+
"tree-sitter-cli": "^0.26.11"
|
|
37
41
|
},
|
|
38
42
|
"peerDependencies": {
|
|
39
43
|
"tree-sitter": "^0.25.0"
|