@repometry/language-swift 0.0.0 → 0.1.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@repometry/language-swift",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Standalone experimental Swift support for Repometry, with its tree-sitter grammar",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"prepack": "npm run build"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@repometry/core": "0.
|
|
43
|
-
"@repometry/tree-sitter": "0.
|
|
42
|
+
"@repometry/core": "0.7.0",
|
|
43
|
+
"@repometry/tree-sitter": "0.5.1"
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const swiftSyntax = {
|
|
2
|
+
lineComments: ['//'],
|
|
3
|
+
blockComments: [['/*', '*/']],
|
|
4
|
+
nestedBlockComments: true,
|
|
5
|
+
strings: [
|
|
6
|
+
...['"', '"""'].flatMap(quote => Array.from({ length: 8 - quote.length }, (_, index) => {
|
|
7
|
+
const hashes = '#'.repeat(index + 1);
|
|
8
|
+
return { quote: hashes + quote, end: quote + hashes, raw: true, multiline: quote.length > 1 };
|
|
9
|
+
})),
|
|
10
|
+
{ quote: '"""', multiline: true },
|
|
11
|
+
{ quote: '"' },
|
|
12
|
+
{ quote: '`' },
|
|
13
|
+
],
|
|
14
|
+
keywords: ['associatedtype', 'class', 'deinit', 'enum', 'extension', 'fileprivate', 'func', 'import', 'init', 'inout',
|
|
15
|
+
'internal', 'let', 'open', 'operator', 'private', 'precedencegroup', 'protocol', 'public', 'rethrows', 'static',
|
|
16
|
+
'struct', 'subscript', 'typealias', 'var', 'break', 'case', 'catch', 'continue', 'default', 'defer', 'do', 'else',
|
|
17
|
+
'fallthrough', 'for', 'guard', 'if', 'in', 'repeat', 'return', 'throw', 'switch', 'where', 'while', 'Any', 'as',
|
|
18
|
+
'false', 'is', 'nil', 'self', 'Self', 'super', 'throws', 'true', 'try'],
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=swift-syntax.js.map
|
package/target/main/ts/swift.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { measures } from '@repometry/tree-sitter';
|
|
2
2
|
import manifest from '../resources/grammar.json' with { type: 'json' };
|
|
3
|
+
import { swiftSyntax } from './swift-syntax.js';
|
|
3
4
|
const typeKinds = new Set(['actor', 'class', 'enum', 'struct']);
|
|
4
5
|
const accessors = new Map([['computed_getter', 'get'], ['computed_setter', 'set'], ['computed_modify', '_modify']]);
|
|
5
6
|
const functions = ['function_declaration', 'init_declaration', 'deinit_declaration'];
|
|
@@ -134,7 +135,7 @@ const tokens = {
|
|
|
134
135
|
]),
|
|
135
136
|
};
|
|
136
137
|
export const swift = {
|
|
137
|
-
language: { id: 'swift', label: 'Swift', color: '#f05138', extensions: ['.swift'], measures: [...measures, 'classes'] },
|
|
138
|
+
language: { id: 'swift', label: 'Swift', color: '#f05138', extensions: ['.swift'], measures: [...measures, 'classes'], syntax: swiftSyntax },
|
|
138
139
|
tool: { package: manifest.package, version: manifest.version },
|
|
139
140
|
asset: new URL('../resources/tree-sitter.wasm', import.meta.url),
|
|
140
141
|
prepareSource: text => text,
|