@codingame/monaco-vscode-treesitter-service-override 25.1.2 → 26.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/external/@vscode/tree-sitter-wasm/wasm/tree-sitter-all.wasm.js +20 -0
- package/external/@vscode/tree-sitter-wasm/wasm/tree-sitter.wasm +0 -0
- package/index.js +10 -3
- package/package.json +2 -3
- package/vscode/src/@vscode/tree-sitter-wasm/wasm/tree-sitter-bash.wasm +0 -0
- package/vscode/src/@vscode/tree-sitter-wasm/wasm/tree-sitter-c-sharp.wasm +0 -0
- package/vscode/src/@vscode/tree-sitter-wasm/wasm/tree-sitter-cpp.wasm +0 -0
- package/vscode/src/@vscode/tree-sitter-wasm/wasm/tree-sitter-css.wasm +0 -0
- package/vscode/src/@vscode/tree-sitter-wasm/wasm/tree-sitter-go.wasm +0 -0
- package/vscode/src/@vscode/tree-sitter-wasm/wasm/tree-sitter-ini.wasm +0 -0
- package/vscode/src/@vscode/tree-sitter-wasm/wasm/tree-sitter-java.wasm +0 -0
- package/vscode/src/@vscode/tree-sitter-wasm/wasm/tree-sitter-javascript.wasm +0 -0
- package/vscode/src/@vscode/tree-sitter-wasm/wasm/tree-sitter-php.wasm +0 -0
- package/vscode/src/@vscode/tree-sitter-wasm/wasm/tree-sitter-powershell.wasm +0 -0
- package/vscode/src/@vscode/tree-sitter-wasm/wasm/tree-sitter-python.wasm +0 -0
- package/vscode/src/@vscode/tree-sitter-wasm/wasm/tree-sitter-regex.wasm +0 -0
- package/vscode/src/@vscode/tree-sitter-wasm/wasm/tree-sitter-ruby.wasm +0 -0
- package/vscode/src/@vscode/tree-sitter-wasm/wasm/tree-sitter-rust.wasm +0 -0
- package/vscode/src/@vscode/tree-sitter-wasm/wasm/tree-sitter-tsx.wasm +0 -0
- package/vscode/src/@vscode/tree-sitter-wasm/wasm/tree-sitter-typescript.wasm +0 -0
- package/vscode/src/vs/editor/common/languages/all_/_.scm.js +9 -0
- package/vscode/src/vs/editor/common/languages/highlights/css.scm +114 -0
- package/vscode/src/vs/editor/common/languages/highlights/ini.scm +12 -0
- package/vscode/src/vs/editor/common/languages/highlights/regex.scm +126 -0
- package/vscode/src/vs/editor/common/languages/injections/typescript.scm +2 -0
- package/vscode/src/vs/workbench/services/treeSitter/browser/treeSitterLibraryService.d.ts +1 -1
- package/vscode/src/vs/workbench/services/treeSitter/browser/treeSitterLibraryService.js +25 -22
- package/vscode/src/vs/workbench/services/treeSitter/browser/treeSitterThemeService.js +6 -5
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
var treeSitterAssets = {
|
|
2
|
+
'@vscode/tree-sitter-wasm/wasm/tree-sitter-bash.wasm': new URL('../../../../vscode/src/@vscode/tree-sitter-wasm/wasm/tree-sitter-bash.wasm', import.meta.url).href,
|
|
3
|
+
'@vscode/tree-sitter-wasm/wasm/tree-sitter-c-sharp.wasm': new URL('../../../../vscode/src/@vscode/tree-sitter-wasm/wasm/tree-sitter-c-sharp.wasm', import.meta.url).href,
|
|
4
|
+
'@vscode/tree-sitter-wasm/wasm/tree-sitter-cpp.wasm': new URL('../../../../vscode/src/@vscode/tree-sitter-wasm/wasm/tree-sitter-cpp.wasm', import.meta.url).href,
|
|
5
|
+
'@vscode/tree-sitter-wasm/wasm/tree-sitter-css.wasm': new URL('../../../../vscode/src/@vscode/tree-sitter-wasm/wasm/tree-sitter-css.wasm', import.meta.url).href,
|
|
6
|
+
'@vscode/tree-sitter-wasm/wasm/tree-sitter-go.wasm': new URL('../../../../vscode/src/@vscode/tree-sitter-wasm/wasm/tree-sitter-go.wasm', import.meta.url).href,
|
|
7
|
+
'@vscode/tree-sitter-wasm/wasm/tree-sitter-ini.wasm': new URL('../../../../vscode/src/@vscode/tree-sitter-wasm/wasm/tree-sitter-ini.wasm', import.meta.url).href,
|
|
8
|
+
'@vscode/tree-sitter-wasm/wasm/tree-sitter-java.wasm': new URL('../../../../vscode/src/@vscode/tree-sitter-wasm/wasm/tree-sitter-java.wasm', import.meta.url).href,
|
|
9
|
+
'@vscode/tree-sitter-wasm/wasm/tree-sitter-javascript.wasm': new URL('../../../../vscode/src/@vscode/tree-sitter-wasm/wasm/tree-sitter-javascript.wasm', import.meta.url).href,
|
|
10
|
+
'@vscode/tree-sitter-wasm/wasm/tree-sitter-php.wasm': new URL('../../../../vscode/src/@vscode/tree-sitter-wasm/wasm/tree-sitter-php.wasm', import.meta.url).href,
|
|
11
|
+
'@vscode/tree-sitter-wasm/wasm/tree-sitter-powershell.wasm': new URL('../../../../vscode/src/@vscode/tree-sitter-wasm/wasm/tree-sitter-powershell.wasm', import.meta.url).href,
|
|
12
|
+
'@vscode/tree-sitter-wasm/wasm/tree-sitter-python.wasm': new URL('../../../../vscode/src/@vscode/tree-sitter-wasm/wasm/tree-sitter-python.wasm', import.meta.url).href,
|
|
13
|
+
'@vscode/tree-sitter-wasm/wasm/tree-sitter-regex.wasm': new URL('../../../../vscode/src/@vscode/tree-sitter-wasm/wasm/tree-sitter-regex.wasm', import.meta.url).href,
|
|
14
|
+
'@vscode/tree-sitter-wasm/wasm/tree-sitter-ruby.wasm': new URL('../../../../vscode/src/@vscode/tree-sitter-wasm/wasm/tree-sitter-ruby.wasm', import.meta.url).href,
|
|
15
|
+
'@vscode/tree-sitter-wasm/wasm/tree-sitter-rust.wasm': new URL('../../../../vscode/src/@vscode/tree-sitter-wasm/wasm/tree-sitter-rust.wasm', import.meta.url).href,
|
|
16
|
+
'@vscode/tree-sitter-wasm/wasm/tree-sitter-tsx.wasm': new URL('../../../../vscode/src/@vscode/tree-sitter-wasm/wasm/tree-sitter-tsx.wasm', import.meta.url).href,
|
|
17
|
+
'@vscode/tree-sitter-wasm/wasm/tree-sitter-typescript.wasm': new URL('../../../../vscode/src/@vscode/tree-sitter-wasm/wasm/tree-sitter-typescript.wasm', import.meta.url).href
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { treeSitterAssets as default };
|
|
Binary file
|
package/index.js
CHANGED
|
@@ -5,11 +5,18 @@ import { ITreeSitterThemeService } from '@codingame/monaco-vscode-api/vscode/vs/
|
|
|
5
5
|
import { TreeSitterThemeService } from './vscode/src/vs/workbench/services/treeSitter/browser/treeSitterThemeService.js';
|
|
6
6
|
import { ITreeSitterLibraryService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/treeSitter/treeSitterLibraryService.service';
|
|
7
7
|
import { TreeSitterLibraryService } from './vscode/src/vs/workbench/services/treeSitter/browser/treeSitterLibraryService.js';
|
|
8
|
+
import treeSitterAssets from './external/@vscode/tree-sitter-wasm/wasm/tree-sitter-all.wasm.js';
|
|
9
|
+
import treeSitterScmAssets from './vscode/src/vs/editor/common/languages/all_/_.scm.js';
|
|
10
|
+
import { FileAccess, nodeModulesPath } from '@codingame/monaco-vscode-api/vscode/vs/base/common/network';
|
|
8
11
|
|
|
12
|
+
FileAccess.registerAppResourceLoader((moduleId) => {
|
|
13
|
+
if (moduleId.startsWith('vs/editor/common/languages/') && moduleId.endsWith('.scm')) {
|
|
14
|
+
return treeSitterScmAssets[moduleId] ?? `not-found:///${moduleId}`;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
9
17
|
registerAssets({
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
'vs/editor/common/languages/highlights/typescript.scm': new URL('./vscode/src/vs/editor/common/languages/highlights/typescript.scm', import.meta.url).href
|
|
18
|
+
[`${nodeModulesPath}/@vscode/tree-sitter-wasm/wasm/tree-sitter.wasm`]: new URL('./external/@vscode/tree-sitter-wasm/wasm/tree-sitter.wasm', import.meta.url).href,
|
|
19
|
+
...Object.fromEntries(Object.entries(treeSitterAssets).map(([key, value]) => [`${nodeModulesPath}/${key}`, value]))
|
|
13
20
|
});
|
|
14
21
|
function getServiceOverride() {
|
|
15
22
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-treesitter-service-override",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "26.0.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "VSCode public API plugged on the monaco editor - treesitter service-override",
|
|
6
6
|
"keywords": [],
|
|
@@ -15,8 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"type": "module",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@codingame/monaco-vscode-api": "
|
|
19
|
-
"@vscode/tree-sitter-wasm": "0.3.0"
|
|
18
|
+
"@codingame/monaco-vscode-api": "26.0.1"
|
|
20
19
|
},
|
|
21
20
|
"main": "index.js",
|
|
22
21
|
"module": "index.js",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
var treeSitterScmAssets = {
|
|
2
|
+
'vs/editor/common/languages/highlights/css.scm': new URL('../highlights/css.scm', import.meta.url).href,
|
|
3
|
+
'vs/editor/common/languages/highlights/ini.scm': new URL('../highlights/ini.scm', import.meta.url).href,
|
|
4
|
+
'vs/editor/common/languages/highlights/regex.scm': new URL('../highlights/regex.scm', import.meta.url).href,
|
|
5
|
+
'vs/editor/common/languages/highlights/typescript.scm': new URL('../highlights/typescript.scm', import.meta.url).href,
|
|
6
|
+
'vs/editor/common/languages/injections/typescript.scm': new URL('../injections/typescript.scm', import.meta.url).href
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export { treeSitterScmAssets as default };
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
; Order matters! Place lower precedence first.
|
|
2
|
+
|
|
3
|
+
[
|
|
4
|
+
"{"
|
|
5
|
+
"}"
|
|
6
|
+
"("
|
|
7
|
+
")"
|
|
8
|
+
"["
|
|
9
|
+
"]"
|
|
10
|
+
] @punctuation.css
|
|
11
|
+
|
|
12
|
+
[
|
|
13
|
+
"*="
|
|
14
|
+
] @keyword.operator.css
|
|
15
|
+
|
|
16
|
+
[
|
|
17
|
+
"+"
|
|
18
|
+
">"
|
|
19
|
+
] @keyword.operator.combinator.css
|
|
20
|
+
|
|
21
|
+
(comment) @comment.block.css
|
|
22
|
+
|
|
23
|
+
; Selectors
|
|
24
|
+
|
|
25
|
+
(selectors) @meta.selector.css
|
|
26
|
+
|
|
27
|
+
(class_selector) @entity.other.attribute-name.class.css
|
|
28
|
+
|
|
29
|
+
(id_selector) @entity.other.attribute-name.id.css
|
|
30
|
+
|
|
31
|
+
(tag_name) @entity.name.tag.css
|
|
32
|
+
|
|
33
|
+
(universal_selector) @entity.name.tag.wildcard.css
|
|
34
|
+
|
|
35
|
+
(pseudo_class_selector) @entity.other.attribute-name.pseudo-class.css
|
|
36
|
+
|
|
37
|
+
(pseudo_element_selector
|
|
38
|
+
"::" @entity.other.attribute-name.pseudo-element.css
|
|
39
|
+
.
|
|
40
|
+
(tag_name) @entity.other.attribute-name.pseudo-element.css)
|
|
41
|
+
|
|
42
|
+
(attribute_name) @entity.other.attribute-name.css
|
|
43
|
+
|
|
44
|
+
; @ Rules
|
|
45
|
+
|
|
46
|
+
[
|
|
47
|
+
("@import")
|
|
48
|
+
("@charset")
|
|
49
|
+
("@namespace")
|
|
50
|
+
("@media")
|
|
51
|
+
("@supports")
|
|
52
|
+
("@keyframes")
|
|
53
|
+
(at_keyword)
|
|
54
|
+
] @keyword.control.at-rule.css
|
|
55
|
+
|
|
56
|
+
(keyword_query) @support.constant.media.css
|
|
57
|
+
|
|
58
|
+
(keyframes_name) @variable.parameter.keyframe-list.css
|
|
59
|
+
|
|
60
|
+
; Functions
|
|
61
|
+
|
|
62
|
+
(function_name) @support.function.css
|
|
63
|
+
|
|
64
|
+
; Properties
|
|
65
|
+
|
|
66
|
+
(property_name) @support.type.property-name.css
|
|
67
|
+
|
|
68
|
+
; Other values
|
|
69
|
+
|
|
70
|
+
(plain_value) @support.constant.property-value.css
|
|
71
|
+
|
|
72
|
+
; Strings
|
|
73
|
+
|
|
74
|
+
((string_value) @string.quoted.single.css
|
|
75
|
+
(#match? @string.quoted.single.css "^'.*'$"))
|
|
76
|
+
|
|
77
|
+
((string_value) @string.quoted.double.css
|
|
78
|
+
(#match? @string.quoted.double.css "^\".*\"$"))
|
|
79
|
+
|
|
80
|
+
; Numbers
|
|
81
|
+
|
|
82
|
+
([
|
|
83
|
+
(integer_value)
|
|
84
|
+
(float_value)
|
|
85
|
+
]) @constant.numeric.css
|
|
86
|
+
|
|
87
|
+
(unit) @keyword.other.unit.css
|
|
88
|
+
|
|
89
|
+
; Special values
|
|
90
|
+
|
|
91
|
+
(declaration
|
|
92
|
+
((property_name) @support.type.property-name.css
|
|
93
|
+
(#eq? @support.type.property-name.css "font"))
|
|
94
|
+
(plain_value) @support.constant.font-name.css)
|
|
95
|
+
|
|
96
|
+
((color_value) @constant.other.color.rgb-value.hex.css
|
|
97
|
+
(#match? @constant.other.color.rgb-value.hex.css "^#.*"))
|
|
98
|
+
|
|
99
|
+
(call_expression
|
|
100
|
+
(function_name) @meta.function.variable.css (#eq? @meta.function.variable.css "var")
|
|
101
|
+
(arguments
|
|
102
|
+
(plain_value) @variable.argument.css))
|
|
103
|
+
|
|
104
|
+
; Special Functions
|
|
105
|
+
|
|
106
|
+
(call_expression
|
|
107
|
+
((function_name) @support.function.url.css
|
|
108
|
+
(#eq? @support.function.url.css "url"))
|
|
109
|
+
(arguments
|
|
110
|
+
(plain_value) @variable.parameter.url.css))
|
|
111
|
+
|
|
112
|
+
; Keywords
|
|
113
|
+
|
|
114
|
+
(important) @keyword.other.important.css
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
; Order matters! Place lower precedence first.
|
|
2
|
+
|
|
3
|
+
(section_name (text) @entity.name.section.group-title)
|
|
4
|
+
|
|
5
|
+
(setting_name) @keyword.other.definition
|
|
6
|
+
|
|
7
|
+
(setting ("=") @punctuation.separator.key-value)
|
|
8
|
+
|
|
9
|
+
(comment) @comment.line.semicolon
|
|
10
|
+
|
|
11
|
+
((setting_value) @string.quoted.double
|
|
12
|
+
(#match? @string.quoted.double "^\".*\""))
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
; Order matters! Place lower precedence first.
|
|
2
|
+
[
|
|
3
|
+
"?"
|
|
4
|
+
"="
|
|
5
|
+
"!"
|
|
6
|
+
] @keyword.operator.regexp
|
|
7
|
+
|
|
8
|
+
[
|
|
9
|
+
"("
|
|
10
|
+
")"
|
|
11
|
+
] @punctuation.definition.group.regexp
|
|
12
|
+
|
|
13
|
+
[
|
|
14
|
+
">"
|
|
15
|
+
"{"
|
|
16
|
+
"}"
|
|
17
|
+
] @punctuation.regexp
|
|
18
|
+
|
|
19
|
+
[
|
|
20
|
+
"["
|
|
21
|
+
"]"
|
|
22
|
+
] @punctuation.definition.character-class.regexp
|
|
23
|
+
|
|
24
|
+
(
|
|
25
|
+
([
|
|
26
|
+
"(?<"
|
|
27
|
+
] @punctuation.definition.group.assertion.regexp)
|
|
28
|
+
.
|
|
29
|
+
[
|
|
30
|
+
"="
|
|
31
|
+
"!"
|
|
32
|
+
] @punctuation.definition.group.assertion.regexp
|
|
33
|
+
) @meta.assertion.look-behind.regexp
|
|
34
|
+
|
|
35
|
+
(
|
|
36
|
+
([
|
|
37
|
+
"(?"
|
|
38
|
+
] @punctuation.definition.group.assertion.regexp)
|
|
39
|
+
.
|
|
40
|
+
[
|
|
41
|
+
"="
|
|
42
|
+
"!"
|
|
43
|
+
] @punctuation.definition.group.assertion.regexp
|
|
44
|
+
) @meta.assertion.look-ahead.regexp
|
|
45
|
+
|
|
46
|
+
"(?:" @punctuation.definition.group.regexp @punctuation.definition.group.no-capture.regexp
|
|
47
|
+
|
|
48
|
+
(lookaround_assertion ("!") @punctuation.definition.group.assertion.regexp)
|
|
49
|
+
|
|
50
|
+
(named_capturing_group) @punctuation.definition.group.regexp
|
|
51
|
+
|
|
52
|
+
(group_name) @variable.other.regexp
|
|
53
|
+
|
|
54
|
+
[
|
|
55
|
+
(control_letter_escape)
|
|
56
|
+
(non_boundary_assertion)
|
|
57
|
+
] @string.escape.regexp
|
|
58
|
+
|
|
59
|
+
[
|
|
60
|
+
(start_assertion)
|
|
61
|
+
(end_assertion)
|
|
62
|
+
(boundary_assertion)
|
|
63
|
+
] @keyword.control.anchor.regexp
|
|
64
|
+
|
|
65
|
+
(class_character) @constant.character-class.regexp
|
|
66
|
+
|
|
67
|
+
(identity_escape) @constant.character.escape.regexp
|
|
68
|
+
|
|
69
|
+
[
|
|
70
|
+
((identity_escape) @internal.regexp (#match? @internal.regexp "\\[^ux]"))
|
|
71
|
+
] @constant.character.escape.regexp
|
|
72
|
+
|
|
73
|
+
(
|
|
74
|
+
((identity_escape) @internal.regexp (#eq? @internal.regexp "\\u"))
|
|
75
|
+
.
|
|
76
|
+
(pattern_character) @constant.character.numeric.regexp
|
|
77
|
+
.
|
|
78
|
+
(pattern_character) @constant.character.numeric.regexp
|
|
79
|
+
.
|
|
80
|
+
(pattern_character) @constant.character.numeric.regexp
|
|
81
|
+
.
|
|
82
|
+
(pattern_character) @constant.character.numeric.regexp
|
|
83
|
+
) @constant.character.numeric.regexp
|
|
84
|
+
|
|
85
|
+
(
|
|
86
|
+
((identity_escape) @internal.regexp (#eq? @internal.regexp "\\x"))
|
|
87
|
+
.
|
|
88
|
+
(pattern_character) @constant.character.numeric.regexp
|
|
89
|
+
.
|
|
90
|
+
(pattern_character) @constant.character.numeric.regexp
|
|
91
|
+
) @constant.character.numeric.regexp
|
|
92
|
+
|
|
93
|
+
(
|
|
94
|
+
((identity_escape) @internal.regexp (#eq? @internal.regexp "\\x"))
|
|
95
|
+
.
|
|
96
|
+
(class_character) @constant.character.numeric.regexp
|
|
97
|
+
.
|
|
98
|
+
(class_character) @constant.character.numeric.regexp
|
|
99
|
+
) @constant.character.numeric.regexp
|
|
100
|
+
|
|
101
|
+
(control_escape) @constant.other.character-class.regexp
|
|
102
|
+
|
|
103
|
+
(character_class_escape) @constant.character.escape.regexp
|
|
104
|
+
|
|
105
|
+
(decimal_escape) @keyword.other.back-reference.regexp
|
|
106
|
+
|
|
107
|
+
("|") @keyword.operator.or.regexp
|
|
108
|
+
|
|
109
|
+
[
|
|
110
|
+
"*"
|
|
111
|
+
"+"
|
|
112
|
+
] @keyword.operator.quantifier.regexp
|
|
113
|
+
|
|
114
|
+
(count_quantifier) @keyword.operator.quantifier.regexp
|
|
115
|
+
|
|
116
|
+
[
|
|
117
|
+
(lazy)
|
|
118
|
+
] @keyword.operator.quantifier.regexp
|
|
119
|
+
|
|
120
|
+
(optional ("?") @keyword.operator.quantifier.regexp)
|
|
121
|
+
|
|
122
|
+
(character_class
|
|
123
|
+
[
|
|
124
|
+
"^" @keyword.operator.negation.regexp
|
|
125
|
+
(class_range "-" @constant.other.character-class.range.regexp)
|
|
126
|
+
])
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Parser, Language, Query } from "@vscode/tree-sitter-wasm";
|
|
1
|
+
import type { Parser, Language, Query } from "@codingame/monaco-vscode-api/external/@vscode/tree-sitter-wasm/wasm/tree-sitter";
|
|
2
2
|
import { IReader } from "@codingame/monaco-vscode-api/vscode/vs/base/common/observable";
|
|
3
3
|
import { ITreeSitterLibraryService } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/services/treeSitter/treeSitterLibraryService.service";
|
|
4
4
|
import { IConfigurationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service";
|
|
@@ -12,7 +12,7 @@ import { nodeModulesPath, FileAccess } from '@codingame/monaco-vscode-api/vscode
|
|
|
12
12
|
import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
13
13
|
import { ObservablePromise } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/utils/promise';
|
|
14
14
|
|
|
15
|
-
const EDITOR_EXPERIMENTAL_PREFER_TREESITTER =
|
|
15
|
+
const EDITOR_EXPERIMENTAL_PREFER_TREESITTER = "editor.experimental.preferTreeSitter";
|
|
16
16
|
const MODULE_LOCATION_SUBPATH = `@vscode/tree-sitter-wasm/wasm`;
|
|
17
17
|
const FILENAME_TREESITTER_WASM = `tree-sitter.wasm`;
|
|
18
18
|
function getModuleLocation(environmentService) {
|
|
@@ -26,39 +26,41 @@ let TreeSitterLibraryService = class TreeSitterLibraryService extends Disposable
|
|
|
26
26
|
this._environmentService = _environmentService;
|
|
27
27
|
this.isTest = false;
|
|
28
28
|
this._treeSitterImport = ( new Lazy(async () => {
|
|
29
|
-
const TreeSitter = await import('@vscode/tree-sitter-wasm')
|
|
29
|
+
const TreeSitter = await import('@codingame/monaco-vscode-api/external/@vscode/tree-sitter-wasm/wasm/tree-sitter');
|
|
30
30
|
const isTest = this.isTest;
|
|
31
31
|
await TreeSitter.Parser.init({
|
|
32
32
|
locateFile(_file, _folder) {
|
|
33
33
|
const location = `${getModuleLocation()}/${FILENAME_TREESITTER_WASM}`;
|
|
34
34
|
if (isTest) {
|
|
35
35
|
return ( ( FileAccess.asFileUri(location)).toString(true));
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
36
|
+
} else {
|
|
38
37
|
return ( ( FileAccess.asBrowserUri(location)).toString(true));
|
|
39
38
|
}
|
|
40
39
|
}
|
|
41
40
|
});
|
|
42
41
|
return TreeSitter;
|
|
43
42
|
}));
|
|
44
|
-
this._supportsLanguage = ( new CachedFunction(
|
|
45
|
-
return observableConfigValue(
|
|
43
|
+
this._supportsLanguage = ( new CachedFunction(languageId => {
|
|
44
|
+
return observableConfigValue(
|
|
45
|
+
`${EDITOR_EXPERIMENTAL_PREFER_TREESITTER}.${languageId}`,
|
|
46
|
+
false,
|
|
47
|
+
this._configurationService
|
|
48
|
+
);
|
|
46
49
|
}));
|
|
47
|
-
this._languagesCache = ( new CachedFunction(
|
|
50
|
+
this._languagesCache = ( new CachedFunction(languageId => {
|
|
48
51
|
return ObservablePromise.fromFn(async () => {
|
|
49
52
|
const languageLocation = getModuleLocation();
|
|
50
53
|
const grammarName = `tree-sitter-${languageId}`;
|
|
51
54
|
const wasmPath = `${languageLocation}/${grammarName}.wasm`;
|
|
52
|
-
const [treeSitter, languageFile] = await Promise.all([
|
|
53
|
-
this._treeSitterImport.value,
|
|
54
|
-
this._fileService.readFile(( FileAccess.asFileUri(wasmPath)))
|
|
55
|
-
]);
|
|
55
|
+
const [treeSitter, languageFile] = await Promise.all([this._treeSitterImport.value, this._fileService.readFile(( FileAccess.asFileUri(wasmPath)))]);
|
|
56
56
|
const Language = treeSitter.Language;
|
|
57
57
|
const language = await Language.load(languageFile.value.buffer);
|
|
58
58
|
return language;
|
|
59
59
|
});
|
|
60
60
|
}));
|
|
61
|
-
this._injectionQueries = ( new CachedFunction({
|
|
61
|
+
this._injectionQueries = ( new CachedFunction({
|
|
62
|
+
getCacheKey: JSON.stringify
|
|
63
|
+
}, arg => {
|
|
62
64
|
const loadQuerySource = async () => {
|
|
63
65
|
const injectionsQueriesLocation = `vs/editor/common/languages/${arg.kind}/${arg.languageId}.scm`;
|
|
64
66
|
const uri = ( FileAccess.asFileUri(injectionsQueriesLocation));
|
|
@@ -75,7 +77,7 @@ let TreeSitterLibraryService = class TreeSitterLibraryService extends Disposable
|
|
|
75
77
|
const [querySource, language, treeSitter] = await Promise.all([
|
|
76
78
|
loadQuerySource(),
|
|
77
79
|
this._languagesCache.get(arg.languageId).promise,
|
|
78
|
-
this._treeSitterImport.value
|
|
80
|
+
this._treeSitterImport.value
|
|
79
81
|
]);
|
|
80
82
|
if (querySource === undefined) {
|
|
81
83
|
return null;
|
|
@@ -106,14 +108,20 @@ let TreeSitterLibraryService = class TreeSitterLibraryService extends Disposable
|
|
|
106
108
|
if (!this.supportsLanguage(languageId, reader)) {
|
|
107
109
|
return undefined;
|
|
108
110
|
}
|
|
109
|
-
const query = this._injectionQueries.get({
|
|
111
|
+
const query = this._injectionQueries.get({
|
|
112
|
+
languageId,
|
|
113
|
+
kind: "injections"
|
|
114
|
+
}).read(reader);
|
|
110
115
|
return query;
|
|
111
116
|
}
|
|
112
117
|
getHighlightingQueries(languageId, reader) {
|
|
113
118
|
if (!this.supportsLanguage(languageId, reader)) {
|
|
114
119
|
return undefined;
|
|
115
120
|
}
|
|
116
|
-
const query = this._injectionQueries.get({
|
|
121
|
+
const query = this._injectionQueries.get({
|
|
122
|
+
languageId,
|
|
123
|
+
kind: "highlights"
|
|
124
|
+
}).read(reader);
|
|
117
125
|
return query;
|
|
118
126
|
}
|
|
119
127
|
async createQuery(language, querySource) {
|
|
@@ -121,17 +129,12 @@ let TreeSitterLibraryService = class TreeSitterLibraryService extends Disposable
|
|
|
121
129
|
return new treeSitter.Query(language, querySource);
|
|
122
130
|
}
|
|
123
131
|
};
|
|
124
|
-
TreeSitterLibraryService = ( __decorate([
|
|
125
|
-
( __param(0, IConfigurationService)),
|
|
126
|
-
( __param(1, IFileService)),
|
|
127
|
-
( __param(2, IEnvironmentService))
|
|
128
|
-
], TreeSitterLibraryService));
|
|
132
|
+
TreeSitterLibraryService = ( __decorate([( __param(0, IConfigurationService)), ( __param(1, IFileService)), ( __param(2, IEnvironmentService))], TreeSitterLibraryService));
|
|
129
133
|
async function tryReadFile(fileService, uri) {
|
|
130
134
|
try {
|
|
131
135
|
const result = await fileService.readFile(uri);
|
|
132
136
|
return result;
|
|
133
|
-
}
|
|
134
|
-
catch (e) {
|
|
137
|
+
} catch (e) {
|
|
135
138
|
if (toFileOperationResult(e) === FileOperationResult.FILE_NOT_FOUND) {
|
|
136
139
|
return undefined;
|
|
137
140
|
}
|
|
@@ -9,8 +9,11 @@ import { derived } from '@codingame/monaco-vscode-api/vscode/vs/base/common/obse
|
|
|
9
9
|
let TreeSitterThemeService = class TreeSitterThemeService {
|
|
10
10
|
constructor(_themeService) {
|
|
11
11
|
this._themeService = _themeService;
|
|
12
|
-
this._colorTheme = observableFromEvent(
|
|
13
|
-
|
|
12
|
+
this._colorTheme = observableFromEvent(
|
|
13
|
+
this._themeService.onDidColorThemeChange,
|
|
14
|
+
() => this._themeService.getColorTheme()
|
|
15
|
+
);
|
|
16
|
+
this.onChange = derived(this, reader => {
|
|
14
17
|
this._colorTheme.read(reader);
|
|
15
18
|
reader.reportChange(void 0);
|
|
16
19
|
});
|
|
@@ -19,8 +22,6 @@ let TreeSitterThemeService = class TreeSitterThemeService {
|
|
|
19
22
|
return findMetadata(this._colorTheme.read(reader), captureNames, languageId, bracket);
|
|
20
23
|
}
|
|
21
24
|
};
|
|
22
|
-
TreeSitterThemeService = ( __decorate([
|
|
23
|
-
( __param(0, IWorkbenchThemeService))
|
|
24
|
-
], TreeSitterThemeService));
|
|
25
|
+
TreeSitterThemeService = ( __decorate([( __param(0, IWorkbenchThemeService))], TreeSitterThemeService));
|
|
25
26
|
|
|
26
27
|
export { TreeSitterThemeService };
|