@repometry/language-java 0.0.0-stage → 0.0.0
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/LICENSE +21 -0
- package/package.json +42 -4
- package/target/main/resources/grammar.json +7 -0
- package/target/main/resources/tree-sitter.LICENSE +21 -0
- package/target/main/resources/tree-sitter.wasm +0 -0
- package/target/main/ts/index.d.ts +7 -0
- package/target/main/ts/index.js +5 -0
- package/target/main/ts/java-syntax.d.ts +2 -0
- package/target/main/ts/java-syntax.js +14 -0
- package/target/main/ts/java.d.ts +2 -0
- package/target/main/ts/java.js +67 -0
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Idleware
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
CHANGED
|
@@ -1,6 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@repometry/language-java",
|
|
3
|
-
"version": "0.0.0
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Java for the Repometry tree-sitter plugin, with its grammar",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/idleware/repometry.git"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/idleware/repometry#readme",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/idleware/repometry/issues"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"repometry",
|
|
16
|
+
"tree-sitter",
|
|
17
|
+
"java"
|
|
18
|
+
],
|
|
19
|
+
"type": "module",
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=24"
|
|
22
|
+
},
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./target/main/ts/index.d.ts",
|
|
26
|
+
"default": "./target/main/ts/index.js"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"target/main",
|
|
31
|
+
"!target/main/**/*.map"
|
|
32
|
+
],
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "node -e \"require('node:fs').rmSync('target/main', { recursive: true, force: true })\" && tsc -p tsconfig.json && node -e \"const fs = require('node:fs'); fs.cpSync('src/main/resources', 'target/main/resources', { recursive: true }); fs.cpSync('../../LICENSE', 'LICENSE')\"",
|
|
38
|
+
"prepack": "npm run build"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@repometry/core": "0.2.0",
|
|
42
|
+
"@repometry/tree-sitter": "0.1.0"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"package": "tree-sitter-java",
|
|
3
|
+
"version": "0.23.5",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"integrity": "sha512-Yju7oQ0Xx7GcUT01mUglPP+bYfvqjNCGdxqigTnew9nLGoII42PNVP3bHrYeMxswiCRM0yubWmN5qk+zsg0zMA==",
|
|
6
|
+
"sha256": "4fdeac4ca6ca089f06c6f7e562abcac1733cd465728cc7031ebb73c2019122c4"
|
|
7
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 Ayman Nadeem
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
Binary file
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { java } from './java.js';
|
|
2
|
+
export { java };
|
|
3
|
+
declare const _default: import("@repometry/core").PluginManifest<import("@repometry/core/internal/model/plugin-data.js").JsonValue> & {
|
|
4
|
+
readonly version: string;
|
|
5
|
+
create(): Awaited<ReturnType<import("@repometry/core").PluginManifest['create']>>;
|
|
6
|
+
};
|
|
7
|
+
export default _default;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const javaSyntax = {
|
|
2
|
+
lineComments: ['//'],
|
|
3
|
+
blockComments: [['/*', '*/']],
|
|
4
|
+
strings: [{ quote: '"""', multiline: true }, { quote: '"' }, { quote: "'" }],
|
|
5
|
+
// JLS §3.9 reserved keywords, plus the boolean and null literals.
|
|
6
|
+
keywords: [
|
|
7
|
+
'abstract', 'assert', 'boolean', 'break', 'byte', 'case', 'catch', 'char', 'class', 'const', 'continue', 'default',
|
|
8
|
+
'do', 'double', 'else', 'enum', 'extends', 'final', 'finally', 'float', 'for', 'goto', 'if', 'implements', 'import',
|
|
9
|
+
'instanceof', 'int', 'interface', 'long', 'native', 'new', 'package', 'private', 'protected', 'public', 'return',
|
|
10
|
+
'short', 'static', 'strictfp', 'super', 'switch', 'synchronized', 'this', 'throw', 'throws', 'transient', 'try',
|
|
11
|
+
'void', 'volatile', 'while', '_', 'true', 'false', 'null',
|
|
12
|
+
],
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=java-syntax.js.map
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { measures } from '@repometry/tree-sitter';
|
|
2
|
+
import manifest from '../resources/grammar.json' with { type: 'json' };
|
|
3
|
+
import { javaSyntax } from './java-syntax.js';
|
|
4
|
+
const tokens = {
|
|
5
|
+
candidates: new Set([
|
|
6
|
+
'annotation_type_body', 'annotation_type_declaration', 'annotation_type_element_declaration', 'assert_statement',
|
|
7
|
+
'block', 'break_statement', 'catch_clause', 'class_body', 'class_declaration', 'compact_constructor_declaration',
|
|
8
|
+
'constant_declaration', 'constructor_body', 'constructor_declaration', 'continue_statement', 'do_statement',
|
|
9
|
+
'enhanced_for_statement', 'enum_body', 'enum_constant', 'enum_declaration', 'expression_statement',
|
|
10
|
+
'field_declaration', 'for_statement', 'if_statement', 'interface_body', 'interface_declaration', 'labeled_statement',
|
|
11
|
+
'lambda_expression', 'local_variable_declaration', 'method_declaration', 'module_declaration', 'record_declaration',
|
|
12
|
+
'return_statement', 'static_initializer', 'switch_block', 'switch_block_statement_group', 'switch_expression',
|
|
13
|
+
'switch_rule', 'synchronized_statement', 'throw_statement', 'try_statement', 'try_with_resources_statement',
|
|
14
|
+
'while_statement', 'yield_statement',
|
|
15
|
+
]),
|
|
16
|
+
kinds: new Map([
|
|
17
|
+
['identifier', 'identifier'], ['type_identifier', 'identifier'],
|
|
18
|
+
['binary_integer_literal', 'integer'], ['decimal_integer_literal', 'integer'], ['hex_integer_literal', 'integer'],
|
|
19
|
+
['octal_integer_literal', 'integer'], ['decimal_floating_point_literal', 'float'], ['hex_floating_point_literal', 'float'],
|
|
20
|
+
['character_literal', 'character'], ['string_literal', 'string'], ['true', 'boolean'], ['false', 'boolean'],
|
|
21
|
+
['null_literal', 'null'],
|
|
22
|
+
]),
|
|
23
|
+
};
|
|
24
|
+
export const java = {
|
|
25
|
+
language: { id: 'java', label: 'Java', color: '#b07219', extensions: ['.java'], measures: [...measures, 'classes'], syntax: javaSyntax },
|
|
26
|
+
tool: { package: manifest.package, version: manifest.version },
|
|
27
|
+
asset: new URL('../resources/tree-sitter.wasm', import.meta.url),
|
|
28
|
+
// The grammar ends // comments at LF. Normalizing lone CR preserves the source offsets.
|
|
29
|
+
prepareSource: text => text.replace(/\r(?!\n)/g, '\n'),
|
|
30
|
+
columns: 'codepoints',
|
|
31
|
+
name: node => node.childForFieldName('name')?.text,
|
|
32
|
+
rules: {
|
|
33
|
+
method_declaration: { flow: 'function', requiresBody: true },
|
|
34
|
+
constructor_declaration: { flow: 'function' },
|
|
35
|
+
compact_constructor_declaration: { flow: 'function' },
|
|
36
|
+
lambda_expression: { flow: 'function' },
|
|
37
|
+
class_declaration: { flow: 'class' },
|
|
38
|
+
interface_declaration: { flow: 'class' },
|
|
39
|
+
enum_declaration: { flow: 'class' },
|
|
40
|
+
record_declaration: { flow: 'class' },
|
|
41
|
+
annotation_type_declaration: { flow: 'class' },
|
|
42
|
+
if_statement: { flow: 'if', decision: true },
|
|
43
|
+
for_statement: { flow: 'nest', decision: true },
|
|
44
|
+
enhanced_for_statement: { flow: 'nest', decision: true },
|
|
45
|
+
while_statement: { flow: 'nest', decision: true },
|
|
46
|
+
do_statement: { flow: 'nest', decision: true },
|
|
47
|
+
catch_clause: { flow: 'nest', decision: true },
|
|
48
|
+
ternary_expression: { flow: 'nest', decision: true },
|
|
49
|
+
// The grammar uses switch_expression for both statement and expression forms.
|
|
50
|
+
switch_expression: { flow: 'nest' },
|
|
51
|
+
switch_label: { decision: node => Number(node.firstChild?.type === 'case') },
|
|
52
|
+
break_statement: { exit: 'label' },
|
|
53
|
+
continue_statement: { exit: 'label' },
|
|
54
|
+
return_statement: { exit: 'return' },
|
|
55
|
+
},
|
|
56
|
+
parens: new Set(['parenthesized_expression']),
|
|
57
|
+
comments: new Set(['line_comment', 'block_comment']),
|
|
58
|
+
extras: new Set(),
|
|
59
|
+
logicalTypes: new Set(['binary_expression']),
|
|
60
|
+
logicalOperators: new Set(['&&', '||']),
|
|
61
|
+
logicalCognitive: 'parent',
|
|
62
|
+
singleParameterTypes: new Set(['identifier']),
|
|
63
|
+
parameterSeparators: new Set(['receiver_parameter']),
|
|
64
|
+
moduleDepthLabel: 'Module · Control-flow depth',
|
|
65
|
+
tokens,
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=java.js.map
|
package/README.md
DELETED