@repometry/language-go 0.0.0-stage → 0.0.1

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 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-go",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.0.1",
4
+ "description": "Go 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
+ "go"
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.1.0",
42
+ "@repometry/tree-sitter": "0.0.1"
43
+ }
44
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "package": "tree-sitter-go",
3
+ "version": "0.25.0",
4
+ "license": "MIT",
5
+ "integrity": "sha512-APBc/Dq3xz/e35Xpkhb1blu5UgW+2E3RyGWawZSCNcbGwa7jhSQPS8KsUupuzBla8PCo8+lz9W/JDJjmfRa2tw==",
6
+ "sha256": "9504573f352b20be7f2f1911754d710622aedc15afff16d5ed8fb5645681aee7"
7
+ }
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Max Brunsfeld
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.
@@ -0,0 +1,2 @@
1
+ import type { LanguageSyntax } from '@repometry/core';
2
+ export declare const goSyntax: LanguageSyntax;
@@ -0,0 +1,7 @@
1
+ export const goSyntax = { lineComments: ['//'], blockComments: [['/*', '*/']],
2
+ strings: [{ quote: '"' }, { quote: "'" }, { quote: '`', multiline: true, raw: true }],
3
+ keywords: ['break', 'case', 'chan', 'const', 'continue', 'default', 'defer', 'else', 'fallthrough', 'for', 'func', 'go',
4
+ 'goto', 'if', 'import', 'interface', 'map', 'package', 'range', 'return', 'select', 'struct', 'switch', 'type', 'var',
5
+ 'true', 'false', 'nil', 'iota'],
6
+ };
7
+ //# sourceMappingURL=go-syntax.js.map
@@ -0,0 +1,2 @@
1
+ import type { LanguageUnit as Grammar } from '@repometry/tree-sitter';
2
+ export declare const go: Grammar;
@@ -0,0 +1,69 @@
1
+ import { measures } from '@repometry/tree-sitter';
2
+ import manifest from '../resources/grammar.json' with { type: 'json' };
3
+ import { goSyntax } from './go-syntax.js';
4
+ function receiver(type) {
5
+ let pointers = 0;
6
+ while (type) {
7
+ switch (type.type) {
8
+ case 'type_identifier': return '(*'.repeat(pointers) + type.text + ')'.repeat(pointers);
9
+ case 'pointer_type':
10
+ pointers++;
11
+ type = type.namedChild(0);
12
+ break;
13
+ case 'generic_type':
14
+ type = type.childForFieldName('type');
15
+ break;
16
+ case 'parenthesized_type':
17
+ type = type.namedChild(0);
18
+ break;
19
+ default: return undefined;
20
+ }
21
+ }
22
+ }
23
+ function name(node) {
24
+ const simple = node.childForFieldName('name')?.text;
25
+ const parameters = node.childForFieldName('receiver');
26
+ const type = receiver(parameters?.namedChild(0)?.childForFieldName('type'));
27
+ return type && simple ? `${type}.${simple}` : simple;
28
+ }
29
+ // Start with go/scanner tokens. Omit comments, whitespace and the semicolons whose literal is a newline.
30
+ // Preserve explicit semicolons, keywords and operators. Strip CR inside raw strings and retain the spelling of _.
31
+ // The similar kinds are identifier (including predeclared names), string (raw or interpreted), rune,
32
+ // integer, float and imaginary. Files under 12 code lines contribute no clone tokens.
33
+ // Each token is its UTF-16 code-unit length, a colon and the spelling. Similar fingerprints use !kind: for those kinds.
34
+ const tokens = {
35
+ candidates: new Set(['assignment_statement', 'block', 'break_statement', 'const_declaration', 'continue_statement',
36
+ 'dec_statement', 'defer_statement', 'expression_case', 'expression_statement', 'expression_switch_statement',
37
+ 'fallthrough_statement', 'for_statement', 'func_literal', 'function_declaration', 'go_statement', 'goto_statement',
38
+ 'if_statement', 'inc_statement', 'labeled_statement', 'method_declaration', 'receive_statement',
39
+ 'return_statement', 'select_statement', 'send_statement', 'short_var_declaration', 'type_case', 'communication_case',
40
+ 'default_case', 'type_declaration', 'type_switch_statement', 'var_declaration']),
41
+ kinds: new Map([
42
+ ...['identifier', 'field_identifier', 'type_identifier', 'package_identifier', 'label_name', 'true', 'false', 'nil', 'iota']
43
+ .map(kind => [kind, 'identifier']),
44
+ ['int_literal', 'integer'], ['float_literal', 'float'], ['imaginary_literal', 'imaginary'],
45
+ ['rune_literal', 'rune'], ['interpreted_string_literal', 'string'], ['raw_string_literal', 'string'],
46
+ ]),
47
+ normalize: (type, text, kind) => [type === 'raw_string_literal' ? text.replaceAll('\r', '') : text, text === '_' ? undefined : kind],
48
+ };
49
+ export const go = {
50
+ language: { id: 'go', label: 'Go', color: '#00add8', extensions: ['.go'], measures, syntax: goSyntax },
51
+ tool: { package: manifest.package, version: manifest.version },
52
+ asset: new URL('../resources/tree-sitter.wasm', import.meta.url),
53
+ prepareSource: text => text.endsWith('\n') ? text : text + '\n',
54
+ lineBreaks: /\r\n|[\n\r\u2028\u2029]/g,
55
+ columns: 'bytes', name,
56
+ rules: {
57
+ function_declaration: { flow: 'function' }, method_declaration: { flow: 'function' }, func_literal: { flow: 'function' },
58
+ if_statement: { flow: 'if', decision: true }, for_statement: { flow: 'nest', decision: true },
59
+ expression_switch_statement: { flow: 'nest' }, type_switch_statement: { flow: 'nest' }, select_statement: { flow: 'nest' },
60
+ expression_case: { decision: true }, type_case: { decision: true }, communication_case: { decision: true },
61
+ break_statement: { exit: 'label' }, continue_statement: { exit: 'label' }, goto_statement: { exit: 'label' },
62
+ return_statement: { exit: 'return' },
63
+ },
64
+ parens: new Set(['parenthesized_expression']), comments: new Set(['comment']), extras: new Set(),
65
+ logicalTypes: new Set(['binary_expression']), logicalOperators: new Set(['&&', '||']), logicalCognitive: 'parent',
66
+ parameterNames: 'name', requireFirst: 'package_clause', reportFileRange: true,
67
+ moduleDepthLabel: 'Module control-flow depth', tokens,
68
+ };
69
+ //# sourceMappingURL=go.js.map
@@ -0,0 +1 @@
1
+ export { go } from './go.js';
@@ -0,0 +1,2 @@
1
+ export { go } from './go.js';
2
+ //# sourceMappingURL=index.js.map
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.