@codingame/monaco-vscode-treesitter-service-override 17.2.1 → 18.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.
Files changed (28) hide show
  1. package/index.js +6 -12
  2. package/package.json +4 -5
  3. package/vscode/src/vs/amdX.d.ts +3 -0
  4. package/vscode/src/vs/amdX.js +188 -0
  5. package/vscode/src/vs/workbench/services/treeSitter/browser/treeSitterLibraryService.d.ts +28 -0
  6. package/vscode/src/vs/workbench/services/treeSitter/browser/treeSitterLibraryService.js +136 -0
  7. package/vscode/src/vs/workbench/services/treeSitter/browser/treeSitterThemeService.d.ts +11 -0
  8. package/vscode/src/vs/workbench/services/treeSitter/browser/treeSitterThemeService.js +26 -0
  9. package/vscode/src/vs/editor/common/model/tokenStore.d.ts +0 -65
  10. package/vscode/src/vs/editor/common/model/tokenStore.js +0 -412
  11. package/vscode/src/vs/editor/common/model/treeSitterTokenStoreService.d.ts +0 -32
  12. package/vscode/src/vs/editor/common/model/treeSitterTokenStoreService.js +0 -135
  13. package/vscode/src/vs/editor/common/services/treeSitter/cursorUtils.d.ts +0 -6
  14. package/vscode/src/vs/editor/common/services/treeSitter/cursorUtils.js +0 -76
  15. package/vscode/src/vs/editor/common/services/treeSitter/textModelTreeSitter.d.ts +0 -88
  16. package/vscode/src/vs/editor/common/services/treeSitter/textModelTreeSitter.js +0 -684
  17. package/vscode/src/vs/editor/common/services/treeSitter/treeSitterLanguages.d.ts +0 -31
  18. package/vscode/src/vs/editor/common/services/treeSitter/treeSitterLanguages.js +0 -120
  19. package/vscode/src/vs/editor/common/services/treeSitter/treeSitterParserService.d.ts +0 -48
  20. package/vscode/src/vs/editor/common/services/treeSitter/treeSitterParserService.js +0 -179
  21. package/vscode/src/vs/editor/common/services/treeSitterParserService.d.ts +0 -61
  22. package/vscode/src/vs/editor/common/services/treeSitterParserService.js +0 -36
  23. package/vscode/src/vs/workbench/services/treeSitter/browser/treeSitterCodeEditors.d.ts +0 -32
  24. package/vscode/src/vs/workbench/services/treeSitter/browser/treeSitterCodeEditors.js +0 -119
  25. package/vscode/src/vs/workbench/services/treeSitter/browser/treeSitterTokenizationFeature.contribution.d.ts +0 -1
  26. package/vscode/src/vs/workbench/services/treeSitter/browser/treeSitterTokenizationFeature.contribution.js +0 -54
  27. package/vscode/src/vs/workbench/services/treeSitter/browser/treeSitterTokenizationFeature.d.ts +0 -96
  28. package/vscode/src/vs/workbench/services/treeSitter/browser/treeSitterTokenizationFeature.js +0 -719
package/index.js CHANGED
@@ -1,14 +1,10 @@
1
1
 
2
2
  import { SyncDescriptor } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/descriptors';
3
- import { TreeSitterImporter } from './vscode/src/vs/editor/common/services/treeSitterParserService.js';
4
- import { ITreeSitterParserService, ITreeSitterImporter } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/treeSitterParserService.service';
5
- import { TreeSitterTextModelService } from './vscode/src/vs/editor/common/services/treeSitter/treeSitterParserService.js';
6
- import { ITreeSitterTokenizationFeature } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/treeSitter/browser/treeSitterTokenizationFeature.service';
7
- import { TreeSitterTokenizationFeature } from './vscode/src/vs/workbench/services/treeSitter/browser/treeSitterTokenizationFeature.js';
8
3
  import { registerAssets } from '@codingame/monaco-vscode-api/assets';
9
- import { ITreeSitterTokenizationStoreService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/model/treeSitterTokenStoreService.service';
10
- import { TreeSitterTokenizationStoreService } from './vscode/src/vs/editor/common/model/treeSitterTokenStoreService.js';
11
- import './vscode/src/vs/workbench/services/treeSitter/browser/treeSitterTokenizationFeature.contribution.js';
4
+ import { ITreeSitterThemeService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/treeSitter/treeSitterThemeService.service';
5
+ import { TreeSitterThemeService } from './vscode/src/vs/workbench/services/treeSitter/browser/treeSitterThemeService.js';
6
+ import { ITreeSitterLibraryService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/treeSitter/treeSitterLibraryService.service';
7
+ import { TreeSitterLibraryService } from './vscode/src/vs/workbench/services/treeSitter/browser/treeSitterLibraryService.js';
12
8
 
13
9
  registerAssets({
14
10
  'vs/../../node_modules/@vscode/tree-sitter-wasm/wasm/tree-sitter.wasm': new URL('@vscode/tree-sitter-wasm/wasm/tree-sitter.wasm', import.meta.url).href,
@@ -17,10 +13,8 @@ registerAssets({
17
13
  });
18
14
  function getServiceOverride() {
19
15
  return {
20
- [ITreeSitterImporter.toString()]: new SyncDescriptor(TreeSitterImporter, [], false),
21
- [ITreeSitterParserService.toString()]: new SyncDescriptor(TreeSitterTextModelService, [], false),
22
- [ITreeSitterTokenizationFeature.toString()]: new SyncDescriptor(TreeSitterTokenizationFeature, [], false),
23
- [ITreeSitterTokenizationStoreService.toString()]: new SyncDescriptor(TreeSitterTokenizationStoreService, [], false)
16
+ [ITreeSitterThemeService.toString()]: new SyncDescriptor(TreeSitterThemeService, [], false),
17
+ [ITreeSitterLibraryService.toString()]: new SyncDescriptor(TreeSitterLibraryService, [], false)
24
18
  };
25
19
  }
26
20
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codingame/monaco-vscode-treesitter-service-override",
3
- "version": "17.2.1",
3
+ "version": "18.0.0",
4
4
  "private": false,
5
5
  "description": "VSCode public API plugged on the monaco editor - treesitter service-override",
6
6
  "keywords": [],
@@ -15,10 +15,9 @@
15
15
  },
16
16
  "type": "module",
17
17
  "dependencies": {
18
- "@codingame/monaco-vscode-7443a901-21f6-577a-9674-42893b997ee0-common": "17.2.1",
19
- "@codingame/monaco-vscode-9d0168a3-519b-57f3-9bcc-89efc41f951a-common": "17.2.1",
20
- "@codingame/monaco-vscode-api": "17.2.1",
21
- "@vscode/tree-sitter-wasm": "0.1.4"
18
+ "@codingame/monaco-vscode-93784a59-b4cf-520c-8339-f8104d3a4f3e-common": "18.0.0",
19
+ "@codingame/monaco-vscode-9d0168a3-519b-57f3-9bcc-89efc41f951a-common": "18.0.0",
20
+ "@codingame/monaco-vscode-api": "18.0.0"
22
21
  },
23
22
  "main": "index.js",
24
23
  "module": "index.js",
@@ -0,0 +1,3 @@
1
+ export declare const canASAR = false;
2
+ export declare function importAMDNodeModule<T>(nodeModuleName: string, pathInsideNodeModule: string, isBuilt?: boolean): Promise<T>;
3
+ export declare function resolveAmdNodeModulePath(nodeModuleName: string, pathInsideNodeModule: string): string;
@@ -0,0 +1,188 @@
1
+
2
+ import { Schemas, VSCODE_AUTHORITY, nodeModulesPath, FileAccess } from '@codingame/monaco-vscode-api/vscode/vs/base/common/network';
3
+ import '@codingame/monaco-vscode-api/vscode/vs/base/common/platform';
4
+ import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
5
+ import { generateUuid } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uuid';
6
+
7
+ class DefineCall {
8
+ constructor(id, dependencies, callback) {
9
+ this.id = id;
10
+ this.dependencies = dependencies;
11
+ this.callback = callback;
12
+ }
13
+ }
14
+ var AMDModuleImporterState;
15
+ (function (AMDModuleImporterState) {
16
+ AMDModuleImporterState[AMDModuleImporterState["Uninitialized"] = 1] = "Uninitialized";
17
+ AMDModuleImporterState[AMDModuleImporterState["InitializedInternal"] = 2] = "InitializedInternal";
18
+ AMDModuleImporterState[AMDModuleImporterState["InitializedExternal"] = 3] = "InitializedExternal";
19
+ })(AMDModuleImporterState || (AMDModuleImporterState = {}));
20
+ class AMDModuleImporter {
21
+ static { this.INSTANCE = ( new AMDModuleImporter()); }
22
+ constructor() {
23
+ this._isWebWorker = (typeof self === 'object' && self.constructor && self.constructor.name === 'DedicatedWorkerGlobalScope');
24
+ this._isRenderer = typeof document === 'object';
25
+ this._defineCalls = [];
26
+ this._state = AMDModuleImporterState.Uninitialized;
27
+ }
28
+ _initialize() {
29
+ if (this._state === AMDModuleImporterState.Uninitialized) {
30
+ if (globalThis.define) {
31
+ this._state = AMDModuleImporterState.InitializedExternal;
32
+ return;
33
+ }
34
+ }
35
+ else {
36
+ return;
37
+ }
38
+ this._state = AMDModuleImporterState.InitializedInternal;
39
+ globalThis.define = (id, dependencies, callback) => {
40
+ if (typeof id !== 'string') {
41
+ callback = dependencies;
42
+ dependencies = id;
43
+ id = null;
44
+ }
45
+ if (typeof dependencies !== 'object' || !Array.isArray(dependencies)) {
46
+ callback = dependencies;
47
+ dependencies = null;
48
+ }
49
+ this._defineCalls.push(( new DefineCall(id, dependencies, callback)));
50
+ };
51
+ globalThis.define.amd = true;
52
+ if (this._isRenderer) {
53
+ this._amdPolicy = globalThis._VSCODE_WEB_PACKAGE_TTP ?? window.trustedTypes?.createPolicy('amdLoader', {
54
+ createScriptURL(value) {
55
+ if (value.startsWith(window.location.origin)) {
56
+ return value;
57
+ }
58
+ if (value.startsWith(`${Schemas.vscodeFileResource}://${VSCODE_AUTHORITY}`)) {
59
+ return value;
60
+ }
61
+ throw ( new Error(`[trusted_script_src] Invalid script url: ${value}`));
62
+ }
63
+ });
64
+ }
65
+ else if (this._isWebWorker) {
66
+ this._amdPolicy = globalThis._VSCODE_WEB_PACKAGE_TTP ?? globalThis.trustedTypes?.createPolicy('amdLoader', {
67
+ createScriptURL(value) {
68
+ return value;
69
+ }
70
+ });
71
+ }
72
+ }
73
+ async load(scriptSrc) {
74
+ this._initialize();
75
+ if (this._state === AMDModuleImporterState.InitializedExternal) {
76
+ return ( new Promise(resolve => {
77
+ const tmpModuleId = generateUuid();
78
+ globalThis.define(tmpModuleId, [scriptSrc], function (moduleResult) {
79
+ resolve(moduleResult);
80
+ });
81
+ }));
82
+ }
83
+ const defineCall = await (this._isWebWorker ? this._workerLoadScript(scriptSrc) : this._isRenderer ? this._rendererLoadScript(scriptSrc) : this._nodeJSLoadScript(scriptSrc));
84
+ if (!defineCall) {
85
+ console.warn(`Did not receive a define call from script ${scriptSrc}`);
86
+ return undefined;
87
+ }
88
+ const exports = {};
89
+ const dependencyObjs = [];
90
+ const dependencyModules = [];
91
+ if (Array.isArray(defineCall.dependencies)) {
92
+ for (const mod of defineCall.dependencies) {
93
+ if (mod === 'exports') {
94
+ dependencyObjs.push(exports);
95
+ }
96
+ else {
97
+ dependencyModules.push(mod);
98
+ }
99
+ }
100
+ }
101
+ if (dependencyModules.length > 0) {
102
+ throw ( new Error(
103
+ `Cannot resolve dependencies for script ${scriptSrc}. The dependencies are: ${dependencyModules.join(', ')}`
104
+ ));
105
+ }
106
+ if (typeof defineCall.callback === 'function') {
107
+ return defineCall.callback(...dependencyObjs) ?? exports;
108
+ }
109
+ else {
110
+ return defineCall.callback;
111
+ }
112
+ }
113
+ _rendererLoadScript(scriptSrc) {
114
+ return ( new Promise((resolve, reject) => {
115
+ const scriptElement = document.createElement('script');
116
+ scriptElement.setAttribute('async', 'async');
117
+ scriptElement.setAttribute('type', 'text/javascript');
118
+ const unbind = () => {
119
+ scriptElement.removeEventListener('load', loadEventListener);
120
+ scriptElement.removeEventListener('error', errorEventListener);
121
+ };
122
+ const loadEventListener = (e) => {
123
+ unbind();
124
+ resolve(this._defineCalls.pop());
125
+ };
126
+ const errorEventListener = (e) => {
127
+ unbind();
128
+ reject(e);
129
+ };
130
+ scriptElement.addEventListener('load', loadEventListener);
131
+ scriptElement.addEventListener('error', errorEventListener);
132
+ if (this._amdPolicy) {
133
+ scriptSrc = this._amdPolicy.createScriptURL(scriptSrc);
134
+ }
135
+ scriptElement.setAttribute('src', scriptSrc);
136
+ window.document.getElementsByTagName('head')[0].appendChild(scriptElement);
137
+ }));
138
+ }
139
+ async _workerLoadScript(scriptSrc) {
140
+ if (this._amdPolicy) {
141
+ scriptSrc = this._amdPolicy.createScriptURL(scriptSrc);
142
+ }
143
+ await import(scriptSrc).then(module => module.default ?? module);
144
+ return this._defineCalls.pop();
145
+ }
146
+ async _nodeJSLoadScript(scriptSrc) {
147
+ try {
148
+ const fs = (await import(`${'fs'}`).then(module => module.default ?? module)).default;
149
+ const vm = (await import(`${'vm'}`).then(module => module.default ?? module)).default;
150
+ const module = (await import(`${'module'}`).then(module => module.default ?? module)).default;
151
+ const filePath = ( URI.parse(scriptSrc)).fsPath;
152
+ const content = ( fs.readFileSync(filePath).toString());
153
+ const scriptSource = module.wrap(content.replace(/^#!.*/, ''));
154
+ const script = new vm.Script(scriptSource);
155
+ const compileWrapper = script.runInThisContext();
156
+ compileWrapper.apply();
157
+ return this._defineCalls.pop();
158
+ }
159
+ catch (error) {
160
+ throw error;
161
+ }
162
+ }
163
+ }
164
+ const cache = ( new Map());
165
+ async function importAMDNodeModule(nodeModuleName, pathInsideNodeModule, isBuilt) {
166
+ if (isBuilt === undefined) {
167
+ const product = globalThis._VSCODE_PRODUCT_JSON;
168
+ isBuilt = Boolean((product ?? globalThis.vscode?.context?.configuration()?.product)?.commit);
169
+ }
170
+ const nodeModulePath = `${nodeModuleName}/${pathInsideNodeModule}` ;
171
+ if (( cache.has(nodeModulePath))) {
172
+ return cache.get(nodeModulePath);
173
+ }
174
+ let scriptSrc;
175
+ if (/^\w[\w\d+.-]*:\/\//.test(nodeModulePath)) {
176
+ scriptSrc = nodeModulePath;
177
+ }
178
+ else {
179
+ const actualNodeModulesPath = (nodeModulesPath);
180
+ const resourcePath = `${actualNodeModulesPath}/${nodeModulePath}`;
181
+ scriptSrc = ( ( FileAccess.asBrowserUri(resourcePath)).toString(true));
182
+ }
183
+ const result = AMDModuleImporter.INSTANCE.load(scriptSrc);
184
+ cache.set(nodeModulePath, result);
185
+ return result;
186
+ }
187
+
188
+ export { importAMDNodeModule };
@@ -0,0 +1,28 @@
1
+ import type { Parser, Language, Query } from "@vscode/tree-sitter-wasm";
2
+ import { IReader } from "@codingame/monaco-vscode-api/vscode/vs/base/common/observable";
3
+ import { ITreeSitterLibraryService } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/services/treeSitter/treeSitterLibraryService.service";
4
+ import { IConfigurationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service";
5
+ import { IFileService } from "@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service";
6
+ import { IEnvironmentService } from "@codingame/monaco-vscode-api/vscode/vs/platform/environment/common/environment.service";
7
+ import { AppResourcePath } from "@codingame/monaco-vscode-api/vscode/vs/base/common/network";
8
+ import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
9
+ export declare const EDITOR_EXPERIMENTAL_PREFER_TREESITTER = "editor.experimental.preferTreeSitter";
10
+ export declare const TREESITTER_ALLOWED_SUPPORT: string[];
11
+ export declare function getModuleLocation(environmentService: IEnvironmentService): AppResourcePath;
12
+ export declare class TreeSitterLibraryService extends Disposable implements ITreeSitterLibraryService {
13
+ private readonly _configurationService;
14
+ private readonly _fileService;
15
+ private readonly _environmentService;
16
+ _serviceBrand: undefined;
17
+ isTest: boolean;
18
+ private readonly _treeSitterImport;
19
+ private readonly _supportsLanguage;
20
+ private readonly _languagesCache;
21
+ private readonly _injectionQueries;
22
+ constructor(_configurationService: IConfigurationService, _fileService: IFileService, _environmentService: IEnvironmentService);
23
+ supportsLanguage(languageId: string, reader: IReader | undefined): boolean;
24
+ getParserClass(): Promise<typeof Parser>;
25
+ getLanguage(languageId: string, reader: IReader | undefined): Language | undefined;
26
+ getInjectionQueries(languageId: string, reader: IReader | undefined): Query | null | undefined;
27
+ getHighlightingQueries(languageId: string, reader: IReader | undefined): Query | null | undefined;
28
+ }
@@ -0,0 +1,136 @@
1
+
2
+ import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
3
+ import '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/index';
4
+ import { importAMDNodeModule } from '../../../../amdX.js';
5
+ import { Lazy } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lazy';
6
+ import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
7
+ import { toFileOperationResult, FileOperationResult } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files';
8
+ import { IFileService } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service';
9
+ import { observableConfigValue } from '@codingame/monaco-vscode-api/vscode/vs/platform/observable/common/platformObservableUtils';
10
+ import { CachedFunction } from '@codingame/monaco-vscode-api/vscode/vs/base/common/cache';
11
+ import { IEnvironmentService } from '@codingame/monaco-vscode-api/vscode/vs/platform/environment/common/environment.service';
12
+ import { nodeModulesPath, FileAccess } from '@codingame/monaco-vscode-api/vscode/vs/base/common/network';
13
+ import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
14
+ import { ObservablePromise } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/utils/promise';
15
+
16
+ const EDITOR_EXPERIMENTAL_PREFER_TREESITTER = 'editor.experimental.preferTreeSitter';
17
+ const MODULE_LOCATION_SUBPATH = `@vscode/tree-sitter-wasm/wasm`;
18
+ const FILENAME_TREESITTER_WASM = `tree-sitter.wasm`;
19
+ function getModuleLocation(environmentService) {
20
+ return `${nodeModulesPath}/${MODULE_LOCATION_SUBPATH}`;
21
+ }
22
+ let TreeSitterLibraryService = class TreeSitterLibraryService extends Disposable {
23
+ constructor(_configurationService, _fileService, _environmentService) {
24
+ super();
25
+ this._configurationService = _configurationService;
26
+ this._fileService = _fileService;
27
+ this._environmentService = _environmentService;
28
+ this.isTest = false;
29
+ this._treeSitterImport = ( new Lazy(async () => {
30
+ const TreeSitter = await importAMDNodeModule('@vscode/tree-sitter-wasm', 'wasm/tree-sitter.js');
31
+ const isTest = this.isTest;
32
+ await TreeSitter.Parser.init({
33
+ locateFile(_file, _folder) {
34
+ const location = `${getModuleLocation()}/${FILENAME_TREESITTER_WASM}`;
35
+ if (isTest) {
36
+ return ( ( FileAccess.asFileUri(location)).toString(true));
37
+ }
38
+ else {
39
+ return ( ( FileAccess.asBrowserUri(location)).toString(true));
40
+ }
41
+ }
42
+ });
43
+ return TreeSitter;
44
+ }));
45
+ this._supportsLanguage = ( new CachedFunction((languageId) => {
46
+ return observableConfigValue(`${EDITOR_EXPERIMENTAL_PREFER_TREESITTER}.${languageId}`, false, this._configurationService);
47
+ }));
48
+ this._languagesCache = ( new CachedFunction((languageId) => {
49
+ return ObservablePromise.fromFn(async () => {
50
+ const languageLocation = getModuleLocation();
51
+ const grammarName = `tree-sitter-${languageId}`;
52
+ const wasmPath = `${languageLocation}/${grammarName}.wasm`;
53
+ const [treeSitter, languageFile] = await Promise.all([
54
+ this._treeSitterImport.value,
55
+ this._fileService.readFile(( FileAccess.asFileUri(wasmPath)))
56
+ ]);
57
+ const Language = treeSitter.Language;
58
+ const language = await Language.load(languageFile.value.buffer);
59
+ return language;
60
+ });
61
+ }));
62
+ this._injectionQueries = ( new CachedFunction({ getCacheKey: JSON.stringify }, (arg) => {
63
+ const loadQuerySource = async () => {
64
+ const injectionsQueriesLocation = `vs/editor/common/languages/${arg.kind}/${arg.languageId}.scm`;
65
+ const uri = ( FileAccess.asFileUri(injectionsQueriesLocation));
66
+ if (!this._fileService.hasProvider(uri)) {
67
+ return undefined;
68
+ }
69
+ const query = await tryReadFile(this._fileService, uri);
70
+ if (query === undefined) {
71
+ return undefined;
72
+ }
73
+ return ( query.value.toString());
74
+ };
75
+ return ObservablePromise.fromFn(async () => {
76
+ const [querySource, language, treeSitter] = await Promise.all([
77
+ loadQuerySource(),
78
+ this._languagesCache.get(arg.languageId).promise,
79
+ this._treeSitterImport.value,
80
+ ]);
81
+ if (querySource === undefined) {
82
+ return null;
83
+ }
84
+ const Query = treeSitter.Query;
85
+ return ( new Query(language, querySource));
86
+ }).resolvedValue;
87
+ }));
88
+ }
89
+ supportsLanguage(languageId, reader) {
90
+ return this._supportsLanguage.get(languageId).read(reader);
91
+ }
92
+ async getParserClass() {
93
+ const treeSitter = await this._treeSitterImport.value;
94
+ return treeSitter.Parser;
95
+ }
96
+ getLanguage(languageId, reader) {
97
+ if (!this.supportsLanguage(languageId, reader)) {
98
+ return undefined;
99
+ }
100
+ const lang = this._languagesCache.get(languageId).resolvedValue.read(reader);
101
+ return lang;
102
+ }
103
+ getInjectionQueries(languageId, reader) {
104
+ if (!this.supportsLanguage(languageId, reader)) {
105
+ return undefined;
106
+ }
107
+ const query = this._injectionQueries.get({ languageId, kind: 'injections' }).read(reader);
108
+ return query;
109
+ }
110
+ getHighlightingQueries(languageId, reader) {
111
+ if (!this.supportsLanguage(languageId, reader)) {
112
+ return undefined;
113
+ }
114
+ const query = this._injectionQueries.get({ languageId, kind: 'highlights' }).read(reader);
115
+ return query;
116
+ }
117
+ };
118
+ TreeSitterLibraryService = ( __decorate([
119
+ ( __param(0, IConfigurationService)),
120
+ ( __param(1, IFileService)),
121
+ ( __param(2, IEnvironmentService))
122
+ ], TreeSitterLibraryService));
123
+ async function tryReadFile(fileService, uri) {
124
+ try {
125
+ const result = await fileService.readFile(uri);
126
+ return result;
127
+ }
128
+ catch (e) {
129
+ if (toFileOperationResult(e) === FileOperationResult.FILE_NOT_FOUND) {
130
+ return undefined;
131
+ }
132
+ throw e;
133
+ }
134
+ }
135
+
136
+ export { EDITOR_EXPERIMENTAL_PREFER_TREESITTER, TreeSitterLibraryService, getModuleLocation };
@@ -0,0 +1,11 @@
1
+ import { IObservable, IReader } from "@codingame/monaco-vscode-api/vscode/vs/base/common/observable";
2
+ import { ITreeSitterThemeService } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/services/treeSitter/treeSitterThemeService.service";
3
+ import { IWorkbenchThemeService } from "@codingame/monaco-vscode-93784a59-b4cf-520c-8339-f8104d3a4f3e-common/vscode/vs/workbench/services/themes/common/workbenchThemeService.service";
4
+ export declare class TreeSitterThemeService implements ITreeSitterThemeService {
5
+ private readonly _themeService;
6
+ _serviceBrand: undefined;
7
+ readonly onChange: IObservable<void>;
8
+ private readonly _colorTheme;
9
+ constructor(_themeService: IWorkbenchThemeService);
10
+ findMetadata(captureNames: string[], languageId: number, bracket: boolean, reader: IReader | undefined): number;
11
+ }
@@ -0,0 +1,26 @@
1
+
2
+ import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
3
+ import '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/index';
4
+ import { findMetadata } from '@codingame/monaco-vscode-9d0168a3-519b-57f3-9bcc-89efc41f951a-common/vscode/vs/workbench/services/themes/common/colorThemeData';
5
+ import { IWorkbenchThemeService } from '@codingame/monaco-vscode-93784a59-b4cf-520c-8339-f8104d3a4f3e-common/vscode/vs/workbench/services/themes/common/workbenchThemeService.service';
6
+ import { observableFromEvent } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/observables/observableFromEvent';
7
+ import { derived } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/observables/derived';
8
+
9
+ let TreeSitterThemeService = class TreeSitterThemeService {
10
+ constructor(_themeService) {
11
+ this._themeService = _themeService;
12
+ this._colorTheme = observableFromEvent(this._themeService.onDidColorThemeChange, () => this._themeService.getColorTheme());
13
+ this.onChange = derived(this, (reader) => {
14
+ this._colorTheme.read(reader);
15
+ reader.reportChange(void 0);
16
+ });
17
+ }
18
+ findMetadata(captureNames, languageId, bracket, reader) {
19
+ return findMetadata(this._colorTheme.read(reader), captureNames, languageId, bracket);
20
+ }
21
+ };
22
+ TreeSitterThemeService = ( __decorate([
23
+ ( __param(0, IWorkbenchThemeService))
24
+ ], TreeSitterThemeService));
25
+
26
+ export { TreeSitterThemeService };
@@ -1,65 +0,0 @@
1
- import { IDisposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
2
- import { ITextModel } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/model";
3
- declare class ListNode implements IDisposable {
4
- readonly height: number;
5
- parent?: ListNode;
6
- private readonly _children;
7
- get children(): ReadonlyArray<Node>;
8
- private _length;
9
- get length(): number;
10
- constructor(height: number);
11
- static create(node1: Node, node2: Node): ListNode;
12
- canAppendChild(): boolean;
13
- appendChild(node: Node): void;
14
- private _updateParentLength;
15
- unappendChild(): Node;
16
- prependChild(node: Node): void;
17
- unprependChild(): Node;
18
- lastChild(): Node;
19
- dispose(): void;
20
- }
21
- export declare enum TokenQuality {
22
- None = 0,
23
- ViewportGuess = 1,
24
- EditGuess = 2,
25
- Accurate = 3
26
- }
27
- type Node = ListNode | LeafNode;
28
- interface LeafNode {
29
- readonly length: number;
30
- token: number;
31
- tokenQuality: TokenQuality;
32
- height: 0;
33
- }
34
- export interface TokenUpdate {
35
- readonly startOffsetInclusive: number;
36
- readonly length: number;
37
- readonly token: number;
38
- }
39
- export declare class TokenStore implements IDisposable {
40
- private readonly _textModel;
41
- private _root;
42
- get root(): Node;
43
- constructor(_textModel: ITextModel);
44
- private createEmptyRoot;
45
- buildStore(tokens: TokenUpdate[], tokenQuality: TokenQuality): void;
46
- private createFromUpdates;
47
- update(length: number, tokens: TokenUpdate[], tokenQuality: TokenQuality): void;
48
- delete(length: number, startOffset: number): void;
49
- private replace;
50
- private traverseInOrderInRange;
51
- getTokenAt(offset: number): TokenUpdate | undefined;
52
- getTokensInRange(startOffsetInclusive: number, endOffsetExclusive: number): TokenUpdate[];
53
- markForRefresh(startOffsetInclusive: number, endOffsetExclusive: number): void;
54
- rangeHasTokens(startOffsetInclusive: number, endOffsetExclusive: number, minimumTokenQuality: TokenQuality): boolean;
55
- rangeNeedsRefresh(startOffsetInclusive: number, endOffsetExclusive: number): boolean;
56
- getNeedsRefresh(): {
57
- startOffset: number;
58
- endOffset: number;
59
- }[];
60
- deepCopy(): TokenStore;
61
- private _copyNodeIterative;
62
- printTree(root?: Node): string;
63
- dispose(): void;
64
- }
65
- export {};