@codingame/monaco-vscode-treesitter-service-override 11.1.1 → 12.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/index.d.ts CHANGED
@@ -1 +1,2 @@
1
- export { default } from 'vscode/service-override/treesitter';
1
+ import type { IEditorOverrideServices } from "vscode/vscode/vs/editor/standalone/browser/standaloneServices";
2
+ export default function getServiceOverride(): IEditorOverrideServices;
package/index.js CHANGED
@@ -1 +1,22 @@
1
- export { default } from './treesitter.js';
1
+
2
+ import { SyncDescriptor } from 'vscode/vscode/vs/platform/instantiation/common/descriptors';
3
+ import { ITreeSitterParserService } from 'vscode/vscode/vs/editor/common/services/treeSitterParserService';
4
+ import { TreeSitterTextModelService } from './vscode/src/vs/editor/browser/services/treeSitter/treeSitterParserService.js';
5
+ import { ITreeSitterTokenizationFeature } from 'vscode/vscode/vs/workbench/services/treeSitter/browser/treeSitterTokenizationFeature.service';
6
+ import { TreeSitterTokenizationFeature } from './vscode/src/vs/workbench/services/treeSitter/browser/treeSitterTokenizationFeature.js';
7
+ import { registerAssets } from 'vscode/assets';
8
+ import './vscode/src/vs/workbench/services/treeSitter/browser/treeSitterTokenizationFeature.contribution.js';
9
+
10
+ registerAssets({
11
+ '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,
12
+ 'vs/../../node_modules/@vscode/tree-sitter-wasm/wasm/tree-sitter-typescript.wasm': new URL('@vscode/tree-sitter-wasm/wasm/tree-sitter-typescript.wasm', import.meta.url).href,
13
+ 'vs/editor/common/languages/highlights/typescript.scm': new URL('./assets/typescript.scm', import.meta.url).href
14
+ });
15
+ function getServiceOverride() {
16
+ return {
17
+ [ITreeSitterParserService.toString()]: new SyncDescriptor(TreeSitterTextModelService, [], false),
18
+ [ITreeSitterTokenizationFeature.toString()]: new SyncDescriptor(TreeSitterTokenizationFeature, [], false)
19
+ };
20
+ }
21
+
22
+ export { getServiceOverride as default };
package/package.json CHANGED
@@ -1,6 +1,8 @@
1
1
  {
2
2
  "name": "@codingame/monaco-vscode-treesitter-service-override",
3
- "version": "11.1.1",
3
+ "version": "12.0.0",
4
+ "private": false,
5
+ "description": "VSCode public API plugged on the monaco editor - treesitter service-override",
4
6
  "keywords": [],
5
7
  "author": {
6
8
  "name": "CodinGame",
@@ -12,8 +14,14 @@
12
14
  "url": "git+ssh://git@github.com/CodinGame/monaco-vscode-api.git"
13
15
  },
14
16
  "type": "module",
15
- "private": false,
16
- "description": "VSCode public API plugged on the monaco editor - treesitter service-override",
17
+ "dependencies": {
18
+ "@codingame/monaco-vscode-9d0168a3-519b-57f3-9bcc-89efc41f951a-common": "12.0.0",
19
+ "@codingame/monaco-vscode-cb805e61-7d70-50d9-b937-bf6481ea0c17-common": "12.0.0",
20
+ "@vscode/tree-sitter-wasm": "12.0.0",
21
+ "vscode": "npm:@codingame/monaco-vscode-api@12.0.0"
22
+ },
23
+ "peerDependencies": {},
24
+ "peerDependenciesMeta": {},
17
25
  "main": "index.js",
18
26
  "module": "index.js",
19
27
  "types": "index.d.ts",
@@ -22,11 +30,12 @@
22
30
  "default": "./index.js"
23
31
  },
24
32
  "./vscode/*": {
25
- "default": "./vscode/src/*.js"
33
+ "default": "./vscode/src/*.js",
34
+ "types": "./vscode/src/*.d.ts"
35
+ },
36
+ "./*": {
37
+ "default": "./*.js",
38
+ "types": "./*.d.ts"
26
39
  }
27
- },
28
- "dependencies": {
29
- "vscode": "npm:@codingame/monaco-vscode-api@11.1.1",
30
- "@vscode/tree-sitter-wasm": "^0.0.4"
31
40
  }
32
41
  }
@@ -0,0 +1,115 @@
1
+ import type { Parser } from "@vscode/tree-sitter-wasm";
2
+ import { ITreeSitterParserService, ITreeSitterParseResult, ITextModelTreeSitter } from "vscode/vscode/vs/editor/common/services/treeSitterParserService";
3
+ import { IModelService } from "vscode/vscode/vs/editor/common/services/model";
4
+ import { Disposable, IDisposable } from "vscode/vscode/vs/base/common/lifecycle";
5
+ import { ITextModel } from "vscode/vscode/vs/editor/common/model";
6
+ import { IFileService } from "vscode/vscode/vs/platform/files/common/files.service";
7
+ import { IModelContentChange } from "vscode/vscode/vs/editor/common/textModelEvents";
8
+ import { ITelemetryService } from "vscode/vscode/vs/platform/telemetry/common/telemetry.service";
9
+ import { ILogService } from "vscode/vscode/vs/platform/log/common/log.service";
10
+ import { IConfigurationService } from "vscode/vscode/vs/platform/configuration/common/configuration.service";
11
+ import { Emitter, Event } from "vscode/vscode/vs/base/common/event";
12
+ import { IEnvironmentService } from "vscode/vscode/vs/platform/environment/common/environment.service";
13
+ import { Range } from "vscode/vscode/vs/editor/common/core/range";
14
+ export declare class TextModelTreeSitter extends Disposable implements ITextModelTreeSitter {
15
+ readonly model: ITextModel;
16
+ private readonly _treeSitterLanguages;
17
+ private readonly _treeSitterImporter;
18
+ private readonly _logService;
19
+ private readonly _telemetryService;
20
+ private _onDidChangeParseResult;
21
+ readonly onDidChangeParseResult: Event<Range[]>;
22
+ private _parseResult;
23
+ get parseResult(): ITreeSitterParseResult | undefined;
24
+ constructor(model: ITextModel, _treeSitterLanguages: TreeSitterLanguages, _treeSitterImporter: TreeSitterImporter, _logService: ILogService, _telemetryService: ITelemetryService, parseImmediately?: boolean);
25
+ private readonly _languageSessionDisposables;
26
+ private _onDidChangeLanguage;
27
+ parse(languageId?: string): Promise<ITreeSitterParseResult | undefined>;
28
+ private _getLanguage;
29
+ private _onDidChangeContent;
30
+ }
31
+ export declare class TreeSitterParseResult implements IDisposable, ITreeSitterParseResult {
32
+ readonly parser: Parser;
33
+ readonly language: Parser.Language;
34
+ private readonly _logService;
35
+ private readonly _telemetryService;
36
+ private _tree;
37
+ private _isDisposed;
38
+ constructor(parser: Parser, language: Parser.Language, _logService: ILogService, _telemetryService: ITelemetryService);
39
+ dispose(): void;
40
+ get tree(): Parser.Tree | undefined;
41
+ private set tree(value);
42
+ get isDisposed(): boolean;
43
+ private _onDidChangeContentQueue;
44
+ onDidChangeContent(model: ITextModel, changes: IModelContentChange[]): Promise<Parser.Range[] | undefined>;
45
+ private _newEdits;
46
+ private _applyEdits;
47
+ private _parseAndUpdateTree;
48
+ private _parse;
49
+ private _parseAndYield;
50
+ private _parseCallback;
51
+ private sendParseTimeTelemetry;
52
+ }
53
+ export declare class TreeSitterLanguages extends Disposable {
54
+ private readonly _treeSitterImporter;
55
+ private readonly _fileService;
56
+ private readonly _environmentService;
57
+ private readonly _registeredLanguages;
58
+ private _languages;
59
+ readonly _onDidAddLanguage: Emitter<{
60
+ id: string;
61
+ language: Parser.Language;
62
+ }>;
63
+ readonly onDidAddLanguage: Event<{
64
+ id: string;
65
+ language: Parser.Language;
66
+ }>;
67
+ constructor(_treeSitterImporter: TreeSitterImporter, _fileService: IFileService, _environmentService: IEnvironmentService, _registeredLanguages: Map<string, string>);
68
+ getOrInitLanguage(languageId: string): Parser.Language | undefined;
69
+ getLanguage(languageId: string): Promise<Parser.Language | undefined>;
70
+ private _addLanguage;
71
+ private _fetchLanguage;
72
+ private _getLanguageLocation;
73
+ }
74
+ export declare class TreeSitterImporter {
75
+ private _treeSitterImport;
76
+ private _getTreeSitterImport;
77
+ private _parserClass;
78
+ getParserClass(): Promise<typeof Parser>;
79
+ }
80
+ export declare class TreeSitterTextModelService extends Disposable implements ITreeSitterParserService {
81
+ private readonly _modelService;
82
+ private readonly _telemetryService;
83
+ private readonly _logService;
84
+ private readonly _configurationService;
85
+ private readonly _environmentService;
86
+ readonly _serviceBrand: undefined;
87
+ private _init;
88
+ private _textModelTreeSitters;
89
+ private readonly _registeredLanguages;
90
+ private readonly _treeSitterImporter;
91
+ private readonly _treeSitterLanguages;
92
+ readonly onDidAddLanguage: Event<{
93
+ id: string;
94
+ language: Parser.Language;
95
+ }>;
96
+ private _onDidUpdateTree;
97
+ readonly onDidUpdateTree: Event<{
98
+ textModel: ITextModel;
99
+ ranges: Range[];
100
+ }>;
101
+ constructor(_modelService: IModelService, fileService: IFileService, _telemetryService: ITelemetryService, _logService: ILogService, _configurationService: IConfigurationService, _environmentService: IEnvironmentService);
102
+ getOrInitLanguage(languageId: string): Parser.Language | undefined;
103
+ getParseResult(textModel: ITextModel): ITreeSitterParseResult | undefined;
104
+ getTree(content: string, languageId: string): Promise<Parser.Tree | undefined>;
105
+ private _doInitParser;
106
+ private _hasInit;
107
+ private _initParser;
108
+ private _supportedLanguagesChanged;
109
+ private _getSetting;
110
+ private _registerModelServiceListeners;
111
+ getTextModelTreeSitter(model: ITextModel): ITextModelTreeSitter;
112
+ private _createTextModelTreeSitter;
113
+ private _addGrammar;
114
+ private _removeGrammar;
115
+ }
@@ -1,4 +1,5 @@
1
- import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
1
+
2
+ import { __decorate, __param } from 'vscode/external/tslib/tslib.es6';
2
3
  import { nodeModulesPath, FileAccess } from 'vscode/vscode/vs/base/common/network';
3
4
  import { EDITOR_EXPERIMENTAL_PREFER_TREESITTER } from 'vscode/vscode/vs/editor/common/services/treeSitterParserService';
4
5
  import { IModelService } from 'vscode/vscode/vs/editor/common/services/model';
@@ -8,7 +9,7 @@ import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/te
8
9
  import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
9
10
  import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration.service';
10
11
  import { setTimeout0 } from 'vscode/vscode/vs/base/common/platform';
11
- import 'vscode/vscode/vs/amdX';
12
+ import '@codingame/monaco-vscode-cb805e61-7d70-50d9-b937-bf6481ea0c17-common/vscode/vs/amdX';
12
13
  import { Emitter, Event } from 'vscode/vscode/vs/base/common/event';
13
14
  import { cancelOnDispose } from 'vscode/vscode/vs/base/common/cancellation';
14
15
  import { IEnvironmentService } from 'vscode/vscode/vs/platform/environment/common/environment.service';
@@ -28,7 +29,7 @@ function getModuleLocation(environmentService) {
28
29
  }
29
30
  class TextModelTreeSitter extends Disposable {
30
31
  get parseResult() { return this._parseResult; }
31
- constructor(model, _treeSitterLanguages, _treeSitterImporter, _logService, _telemetryService) {
32
+ constructor(model, _treeSitterLanguages, _treeSitterImporter, _logService, _telemetryService, parseImmediately = true) {
32
33
  super();
33
34
  this.model = model;
34
35
  this._treeSitterLanguages = _treeSitterLanguages;
@@ -38,9 +39,17 @@ class TextModelTreeSitter extends Disposable {
38
39
  this._onDidChangeParseResult = this._register(( new Emitter()));
39
40
  this.onDidChangeParseResult = this._onDidChangeParseResult.event;
40
41
  this._languageSessionDisposables = this._register(( new DisposableStore()));
41
- this._register(Event.runAndSubscribe(this.model.onDidChangeLanguage, (e => this._onDidChangeLanguage(e ? e.newLanguage : this.model.getLanguageId()))));
42
+ if (parseImmediately) {
43
+ this._register(Event.runAndSubscribe(this.model.onDidChangeLanguage, (e => this._onDidChangeLanguage(e ? e.newLanguage : this.model.getLanguageId()))));
44
+ }
45
+ else {
46
+ this._register(this.model.onDidChangeLanguage(e => this._onDidChangeLanguage(e ? e.newLanguage : this.model.getLanguageId())));
47
+ }
42
48
  }
43
49
  async _onDidChangeLanguage(languageId) {
50
+ this.parse(languageId);
51
+ }
52
+ async parse(languageId = this.model.getLanguageId()) {
44
53
  this._languageSessionDisposables.clear();
45
54
  this._parseResult = undefined;
46
55
  const token = cancelOnDispose(this._languageSessionDisposables);
@@ -65,6 +74,7 @@ class TextModelTreeSitter extends Disposable {
65
74
  return;
66
75
  }
67
76
  this._parseResult = treeSitterTree;
77
+ return this._parseResult;
68
78
  }
69
79
  _getLanguage(languageId, token) {
70
80
  const language = this._treeSitterLanguages.getOrInitLanguage(languageId);
@@ -98,6 +108,11 @@ class TextModelTreeSitter extends Disposable {
98
108
  }
99
109
  }
100
110
  }
111
+ var TelemetryParseType;
112
+ (function (TelemetryParseType) {
113
+ TelemetryParseType["Full"] = "fullParse";
114
+ TelemetryParseType["Incremental"] = "incrementalParse";
115
+ })(TelemetryParseType || (TelemetryParseType = {}));
101
116
  class TreeSitterParseResult {
102
117
  constructor(parser, language, _logService, _telemetryService) {
103
118
  this.parser = parser;
@@ -158,9 +173,9 @@ class TreeSitterParseResult {
158
173
  }
159
174
  }
160
175
  _parse(model) {
161
- let parseType = "fullParse" ;
176
+ let parseType = TelemetryParseType.Full;
162
177
  if (this.tree) {
163
- parseType = "incrementalParse" ;
178
+ parseType = TelemetryParseType.Incremental;
164
179
  }
165
180
  return this._parseAndYield(model, parseType);
166
181
  }
@@ -200,7 +215,7 @@ class TreeSitterParseResult {
200
215
  }
201
216
  sendParseTimeTelemetry(parseType, languageId, time, passes) {
202
217
  this._logService.debug(`Tree parsing (${parseType}) took ${time} ms and ${passes} passes.`);
203
- if (parseType === "fullParse" ) {
218
+ if (parseType === TelemetryParseType.Full) {
204
219
  this._telemetryService.publicLog2(`treeSitter.fullParse`, { languageId, time, passes });
205
220
  }
206
221
  else {
@@ -386,6 +401,16 @@ let TreeSitterTextModelService = class TreeSitterTextModelService extends Dispos
386
401
  }));
387
402
  this._modelService.getModels().forEach(model => this._createTextModelTreeSitter(model));
388
403
  }
404
+ getTextModelTreeSitter(model) {
405
+ return ( new TextModelTreeSitter(
406
+ model,
407
+ this._treeSitterLanguages,
408
+ this._treeSitterImporter,
409
+ this._logService,
410
+ this._telemetryService,
411
+ false
412
+ ));
413
+ }
389
414
  _createTextModelTreeSitter(model) {
390
415
  const textModelTreeSitter = ( new TextModelTreeSitter(
391
416
  model,
@@ -1,8 +1,14 @@
1
- import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
- import { registerWorkbenchContribution2 } from 'vscode/vscode/vs/workbench/common/contributions';
1
+
2
+ import { __decorate, __param } from 'vscode/external/tslib/tslib.es6';
3
+ import 'vscode/vscode/vs/platform/instantiation/common/extensions';
4
+ import { registerWorkbenchContribution2, WorkbenchPhase } from 'vscode/vscode/vs/workbench/common/contributions';
3
5
  import '../../../../editor/browser/services/treeSitter/treeSitterParserService.js';
4
6
  import { ITreeSitterParserService } from 'vscode/vscode/vs/editor/common/services/treeSitterParserService';
5
7
  import { ITreeSitterTokenizationFeature } from 'vscode/vscode/vs/workbench/services/treeSitter/browser/treeSitterTokenizationFeature.service';
8
+ import { CommandsRegistry } from 'vscode/vscode/vs/platform/commands/common/commands';
9
+ import { TreeSitterTokenizationRegistry } from 'vscode/vscode/vs/editor/common/languages';
10
+ import { ITextFileService } from 'vscode/vscode/vs/workbench/services/textfile/common/textfiles.service';
11
+ import { StopWatch } from 'vscode/vscode/vs/base/common/stopwatch';
6
12
 
7
13
  let TreeSitterTokenizationInstantiator = class TreeSitterTokenizationInstantiator {
8
14
  static { this.ID = 'workbench.contrib.treeSitterTokenizationInstantiator'; }
@@ -12,4 +18,37 @@ TreeSitterTokenizationInstantiator = ( __decorate([
12
18
  ( __param(0, ITreeSitterParserService)),
13
19
  ( __param(1, ITreeSitterTokenizationFeature))
14
20
  ], TreeSitterTokenizationInstantiator));
15
- registerWorkbenchContribution2(TreeSitterTokenizationInstantiator.ID, TreeSitterTokenizationInstantiator, 2 );
21
+ registerWorkbenchContribution2(TreeSitterTokenizationInstantiator.ID, TreeSitterTokenizationInstantiator, WorkbenchPhase.BlockRestore);
22
+ CommandsRegistry.registerCommand('_workbench.colorizeTreeSitterTokens', async (accessor, resource) => {
23
+ const treeSitterParserService = accessor.get(ITreeSitterParserService);
24
+ const textModelService = accessor.get(ITextFileService);
25
+ const textModel = resource ? (await textModelService.files.resolve(resource)).textEditorModel : undefined;
26
+ if (!textModel) {
27
+ throw ( new Error(`Cannot resolve text model for resource ${resource}`));
28
+ }
29
+ const tokenizer = await TreeSitterTokenizationRegistry.getOrCreate(textModel.getLanguageId());
30
+ if (!tokenizer) {
31
+ throw ( new Error(`Cannot resolve tokenizer for language ${textModel.getLanguageId()}`));
32
+ }
33
+ const textModelTreeSitter = treeSitterParserService.getTextModelTreeSitter(textModel);
34
+ if (!textModelTreeSitter) {
35
+ throw ( new Error(
36
+ `Cannot resolve tree sitter parser for language ${textModel.getLanguageId()}`
37
+ ));
38
+ }
39
+ const stopwatch = ( new StopWatch());
40
+ await textModelTreeSitter.parse();
41
+ stopwatch.stop();
42
+ let captureTime = 0;
43
+ let metadataTime = 0;
44
+ for (let i = 1; i <= textModel.getLineCount(); i++) {
45
+ const result = tokenizer.tokenizeEncodedInstrumented(i, textModel);
46
+ if (result) {
47
+ captureTime += result.captureTime;
48
+ metadataTime += result.metadataTime;
49
+ }
50
+ }
51
+ textModelTreeSitter.dispose();
52
+ textModel.dispose();
53
+ return { parseTime: stopwatch.elapsed(), captureTime, metadataTime };
54
+ });
@@ -0,0 +1,19 @@
1
+ import { Disposable } from "vscode/vscode/vs/base/common/lifecycle";
2
+ import { IConfigurationService } from "vscode/vscode/vs/platform/configuration/common/configuration.service";
3
+ import { IFileService } from "vscode/vscode/vs/platform/files/common/files.service";
4
+ import { IInstantiationService } from "vscode/vscode/vs/platform/instantiation/common/instantiation";
5
+ import { ILanguageService } from "vscode/vscode/vs/editor/common/languages/language";
6
+ import { ITreeSitterTokenizationFeature } from "vscode/vscode/vs/workbench/services/treeSitter/browser/treeSitterTokenizationFeature.service";
7
+ export declare class TreeSitterTokenizationFeature extends Disposable implements ITreeSitterTokenizationFeature {
8
+ private readonly _languageService;
9
+ private readonly _configurationService;
10
+ private readonly _instantiationService;
11
+ private readonly _fileService;
12
+ _serviceBrand: undefined;
13
+ private readonly _tokenizersRegistrations;
14
+ constructor(_languageService: ILanguageService, _configurationService: IConfigurationService, _instantiationService: IInstantiationService, _fileService: IFileService);
15
+ private _getSetting;
16
+ private _handleGrammarsExtPoint;
17
+ private _fetchQueries;
18
+ private _createTokenizationSupport;
19
+ }
@@ -1,4 +1,5 @@
1
- import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
1
+
2
+ import { __decorate, __param } from 'vscode/external/tslib/tslib.es6';
2
3
  import { Emitter, Event } from 'vscode/vscode/vs/base/common/event';
3
4
  import { Disposable, DisposableMap, DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
4
5
  import { FileAccess } from 'vscode/vscode/vs/base/common/network';
@@ -7,10 +8,12 @@ import { EDITOR_EXPERIMENTAL_PREFER_TREESITTER, ITreeSitterParserService } from
7
8
  import { ColumnRange } from 'vscode/vscode/vs/editor/contrib/inlineCompletions/browser/utils';
8
9
  import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration.service';
9
10
  import { IFileService } from 'vscode/vscode/vs/platform/files/common/files.service';
11
+ import 'vscode/vscode/vs/platform/instantiation/common/extensions';
10
12
  import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
11
13
  import { IThemeService } from 'vscode/vscode/vs/platform/theme/common/themeService.service';
12
- import { findMetadata } from 'vscode/vscode/vs/workbench/services/themes/common/colorThemeData';
14
+ import { findMetadata } from '@codingame/monaco-vscode-9d0168a3-519b-57f3-9bcc-89efc41f951a-common/vscode/vs/workbench/services/themes/common/colorThemeData';
13
15
  import { ILanguageService } from 'vscode/vscode/vs/editor/common/languages/language';
16
+ import { StopWatch } from 'vscode/vscode/vs/base/common/stopwatch';
14
17
 
15
18
  const ALLOWED_SUPPORT = ['typescript'];
16
19
  let TreeSitterTokenizationFeature = class TreeSitterTokenizationFeature extends Disposable {
@@ -126,6 +129,13 @@ let TreeSitterTokenizationSupport = class TreeSitterTokenizationSupport extends
126
129
  return query.captures(tree.rootNode, { startPosition: { row: lineNumber - 1, column: columnRange.startColumn - 1 }, endPosition: { row: lineNumber - 1, column: columnRange.endColumnExclusive } });
127
130
  }
128
131
  tokenizeEncoded(lineNumber, textModel) {
132
+ return this._tokenizeEncoded(lineNumber, textModel)?.result;
133
+ }
134
+ tokenizeEncodedInstrumented(lineNumber, textModel) {
135
+ return this._tokenizeEncoded(lineNumber, textModel);
136
+ }
137
+ _tokenizeEncoded(lineNumber, textModel) {
138
+ const stopwatch = StopWatch.create();
129
139
  const lineLength = textModel.getLineMaxColumn(lineNumber);
130
140
  const tree = this._getTree(textModel);
131
141
  const captures = this._captureAtRange(lineNumber, ( new ColumnRange(1, lineLength)), tree?.tree);
@@ -187,6 +197,8 @@ let TreeSitterTokenizationSupport = class TreeSitterTokenizationSupport extends
187
197
  endOffsetsAndScopes[tokenIndex].endOffset = lineLength - 1;
188
198
  tokenIndex++;
189
199
  }
200
+ const captureTime = stopwatch.elapsed();
201
+ stopwatch.reset();
190
202
  const tokens = ( new Uint32Array((tokenIndex) * 2));
191
203
  for (let i = 0; i < tokenIndex; i++) {
192
204
  const token = endOffsetsAndScopes[i];
@@ -196,7 +208,8 @@ let TreeSitterTokenizationSupport = class TreeSitterTokenizationSupport extends
196
208
  tokens[i * 2] = token.endOffset;
197
209
  tokens[i * 2 + 1] = findMetadata(this._colorThemeData, token.scopes, encodedLanguageId);
198
210
  }
199
- return tokens;
211
+ const metadataTime = stopwatch.elapsed();
212
+ return { result: tokens, captureTime, metadataTime };
200
213
  }
201
214
  dispose() {
202
215
  super.dispose();
package/treesitter.js DELETED
@@ -1,21 +0,0 @@
1
- import { SyncDescriptor } from 'vscode/vscode/vs/platform/instantiation/common/descriptors';
2
- import { ITreeSitterParserService } from 'vscode/vscode/vs/editor/common/services/treeSitterParserService';
3
- import { TreeSitterTextModelService } from './vscode/src/vs/editor/browser/services/treeSitter/treeSitterParserService.js';
4
- import { ITreeSitterTokenizationFeature } from 'vscode/vscode/vs/workbench/services/treeSitter/browser/treeSitterTokenizationFeature.service';
5
- import { TreeSitterTokenizationFeature } from './vscode/src/vs/workbench/services/treeSitter/browser/treeSitterTokenizationFeature.js';
6
- import { registerAssets } from 'vscode/assets';
7
- import './vscode/src/vs/workbench/services/treeSitter/browser/treeSitterTokenizationFeature.contribution.js';
8
-
9
- registerAssets({
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,
11
- 'vs/../../node_modules/@vscode/tree-sitter-wasm/wasm/tree-sitter-typescript.wasm': new URL('@vscode/tree-sitter-wasm/wasm/tree-sitter-typescript.wasm', import.meta.url).href,
12
- 'vs/editor/common/languages/highlights/typescript.scm': new URL('./assets/typescript.scm', import.meta.url).href
13
- });
14
- function getServiceOverride() {
15
- return {
16
- [( ITreeSitterParserService.toString())]: new SyncDescriptor(TreeSitterTextModelService, [], false),
17
- [( ITreeSitterTokenizationFeature.toString())]: new SyncDescriptor(TreeSitterTokenizationFeature, [], false)
18
- };
19
- }
20
-
21
- export { getServiceOverride as default };