@codingame/monaco-languageclient-wrapper 3.0.3 → 3.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/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import { toSocket, WebSocketMessageReader, WebSocketMessageWriter } from '@codin
2
2
  import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
3
3
  import { Uri } from 'monaco-editor/esm/vs/editor/editor.api';
4
4
  import * as ls$1 from 'vscode-languageserver-protocol';
5
- import { ProtocolNotificationType, ProtocolRequestType, Emitter, TextDocumentSaveReason, DidSaveTextDocumentNotification, RegistrationRequest, UnregistrationRequest, InitializeRequest, LogMessageNotification } from 'vscode-languageserver-protocol';
5
+ import { ProtocolNotificationType, ProtocolRequestType, InlayHintRefreshRequest, InlayHintRequest, Emitter, TextDocumentSaveReason, RegistrationRequest, UnregistrationRequest, InitializeRequest, DidSaveTextDocumentNotification, LogMessageNotification } from 'vscode-languageserver-protocol';
6
6
  import { loadConfigurationForExtension } from '@codingame/monaco-editor-wrapper/dist/features/extensionConfigurations';
7
7
  import * as vscode$3 from 'vscode';
8
8
  import { EventEmitter } from 'vscode';
@@ -5258,7 +5258,7 @@ var protocolConverter = {};
5258
5258
  Object.defineProperty(protocolConverter, "__esModule", {
5259
5259
  value: true
5260
5260
  });
5261
- var createConverter_1 = protocolConverter.createConverter = void 0;
5261
+ protocolConverter.createConverter = void 0;
5262
5262
  const code$2 = require$$0$2;
5263
5263
  const ls = require$$0$1;
5264
5264
  const Is$5 = is;
@@ -6652,7 +6652,7 @@ function createConverter(uriConverter, trustMarkdown, supportHtml) {
6652
6652
  };
6653
6653
  }
6654
6654
 
6655
- createConverter_1 = protocolConverter.createConverter = createConverter;
6655
+ protocolConverter.createConverter = createConverter;
6656
6656
 
6657
6657
  var uuid = {};
6658
6658
 
@@ -17020,6 +17020,190 @@ var ProtocolInlayHint;
17020
17020
  ProtocolInlayHint.is = is;
17021
17021
  })(ProtocolInlayHint || (ProtocolInlayHint = {}));
17022
17022
 
17023
+ var api = {};
17024
+
17025
+ (function (exports) {
17026
+ /* --------------------------------------------------------------------------------------------
17027
+ * Copyright (c) Microsoft Corporation. All rights reserved.
17028
+ * Licensed under the MIT License. See License.txt in the project root for license information.
17029
+ * ------------------------------------------------------------------------------------------ */
17030
+
17031
+ var __createBinding = commonjsGlobal && commonjsGlobal.__createBinding || (Object.create ? function (o, m, k, k2) {
17032
+ if (k2 === undefined) k2 = k;
17033
+ var desc = Object.getOwnPropertyDescriptor(m, k);
17034
+
17035
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17036
+ desc = {
17037
+ enumerable: true,
17038
+ get: function () {
17039
+ return m[k];
17040
+ }
17041
+ };
17042
+ }
17043
+
17044
+ Object.defineProperty(o, k2, desc);
17045
+ } : function (o, m, k, k2) {
17046
+ if (k2 === undefined) k2 = k;
17047
+ o[k2] = m[k];
17048
+ });
17049
+
17050
+ var __exportStar = commonjsGlobal && commonjsGlobal.__exportStar || function (m, exports) {
17051
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
17052
+ };
17053
+
17054
+ Object.defineProperty(exports, "__esModule", {
17055
+ value: true
17056
+ });
17057
+ exports.DiagnosticPullMode = exports.vsdiag = void 0;
17058
+
17059
+ __exportStar(require$$0$1, exports);
17060
+
17061
+ __exportStar(features, exports);
17062
+
17063
+ var diagnostic_1 = diagnostic;
17064
+ Object.defineProperty(exports, "vsdiag", {
17065
+ enumerable: true,
17066
+ get: function () {
17067
+ return diagnostic_1.vsdiag;
17068
+ }
17069
+ });
17070
+ Object.defineProperty(exports, "DiagnosticPullMode", {
17071
+ enumerable: true,
17072
+ get: function () {
17073
+ return diagnostic_1.DiagnosticPullMode;
17074
+ }
17075
+ });
17076
+
17077
+ __exportStar(client, exports);
17078
+ })(api);
17079
+
17080
+ const ResolveCobolSubroutineRequestType = new api.ProtocolRequestType('cobol/resolveSubroutine');
17081
+ class CobolResolveSubroutineFeature {
17082
+ constructor(languageClient) {
17083
+ this.languageClient = languageClient;
17084
+
17085
+ _defineProperty(this, "onRequestDisposable", void 0);
17086
+ }
17087
+
17088
+ fillClientCapabilities() {}
17089
+
17090
+ initialize(capabilities, documentSelector) {
17091
+ this.onRequestDisposable = this.languageClient.onRequest(ResolveCobolSubroutineRequestType, routineName => {
17092
+ var _vscode$workspace$roo, _vscode$workspace$tex;
17093
+
17094
+ const constantRoutinePaths = {
17095
+ 'assert-equals': "file:".concat((_vscode$workspace$roo = vscode$3.workspace.rootPath) !== null && _vscode$workspace$roo !== void 0 ? _vscode$workspace$roo : '/tmp/project', "/deps/assert-equals.cbl")
17096
+ };
17097
+ const contantRoutinePath = constantRoutinePaths[routineName.toLowerCase()];
17098
+
17099
+ if (contantRoutinePath != null) {
17100
+ return contantRoutinePath;
17101
+ }
17102
+
17103
+ return (_vscode$workspace$tex = vscode$3.workspace.textDocuments.filter(textDocument => vscode$3.languages.match(documentSelector, textDocument)).filter(document => document.getText().match(new RegExp("PROGRAM-ID\\.\\W+".concat(routineName, "\\."), 'gi'))).sort((a, b) => a.uri.toString().localeCompare(b.uri.toString()))[0]) === null || _vscode$workspace$tex === void 0 ? void 0 : _vscode$workspace$tex.uri.toString();
17104
+ });
17105
+ }
17106
+
17107
+ getState() {
17108
+ return {
17109
+ kind: 'static'
17110
+ };
17111
+ }
17112
+
17113
+ dispose() {
17114
+ var _this$onRequestDispos;
17115
+
17116
+ (_this$onRequestDispos = this.onRequestDisposable) === null || _this$onRequestDispos === void 0 ? void 0 : _this$onRequestDispos.dispose();
17117
+ }
17118
+
17119
+ }
17120
+
17121
+ async function asInlayHints(values, client) {
17122
+ if (!Array.isArray(values)) {
17123
+ return undefined;
17124
+ }
17125
+
17126
+ return values.map(lsHint => asInlayHint(lsHint, client));
17127
+ }
17128
+
17129
+ function asInlayHint(value, client) {
17130
+ const label = value.label;
17131
+ const result = new vscode$3.InlayHint(client.protocol2CodeConverter.asPosition(value.position), label);
17132
+ result.paddingRight = true;
17133
+ result.kind = vscode$3.InlayHintKind.Parameter;
17134
+ return result;
17135
+ }
17136
+ /**
17137
+ * Comes from https://github.com/redhat-developer/vscode-java/blob/9b6046eecc65fd47507f309a3ccc9add45c6d3be/src/inlayHintsProvider.ts#L5
17138
+ */
17139
+
17140
+
17141
+ class JavaInlayHintsProvider {
17142
+ constructor(client) {
17143
+ this.client = client;
17144
+
17145
+ _defineProperty(this, "onDidChange", new vscode$3.EventEmitter());
17146
+
17147
+ _defineProperty(this, "onDidChangeInlayHints", this.onDidChange.event);
17148
+
17149
+ this.client.onRequest(InlayHintRefreshRequest.type, async () => {
17150
+ this.onDidChange.fire();
17151
+ });
17152
+ }
17153
+
17154
+ async provideInlayHints(document, range, token) {
17155
+ const requestParams = {
17156
+ textDocument: this.client.code2ProtocolConverter.asTextDocumentIdentifier(document),
17157
+ range: this.client.code2ProtocolConverter.asRange(range)
17158
+ };
17159
+
17160
+ try {
17161
+ const values = await this.client.sendRequest(InlayHintRequest.type, requestParams, token);
17162
+
17163
+ if (token.isCancellationRequested) {
17164
+ return [];
17165
+ }
17166
+
17167
+ return asInlayHints(values, this.client);
17168
+ } catch (error) {
17169
+ return this.client.handleFailedRequest(InlayHintRequest.type, token, error, []);
17170
+ }
17171
+ }
17172
+
17173
+ }
17174
+
17175
+ class JavaExtensionFeature {
17176
+ constructor(languageClient) {
17177
+ this.languageClient = languageClient;
17178
+
17179
+ _defineProperty(this, "disposables", void 0);
17180
+
17181
+ this.disposables = new DisposableCollection();
17182
+ }
17183
+
17184
+ fillClientCapabilities() {}
17185
+
17186
+ initialize() {
17187
+ // Comes from https://github.com/redhat-developer/vscode-java/blob/9b6046eecc65fd47507f309a3ccc9add45c6d3be/src/standardLanguageClient.ts#L321
17188
+ this.disposables.push(vscode$3.commands.registerCommand('java.apply.workspaceEdit', async obj => {
17189
+ const edit = await this.languageClient.protocol2CodeConverter.asWorkspaceEdit(obj);
17190
+ return vscode$3.workspace.applyEdit(edit);
17191
+ }));
17192
+ this.disposables.push(vscode$3.languages.registerInlayHintsProvider(this.languageClient.clientOptions.documentSelector, new JavaInlayHintsProvider(this.languageClient)));
17193
+ }
17194
+
17195
+ getState() {
17196
+ return {
17197
+ kind: 'static'
17198
+ };
17199
+ }
17200
+
17201
+ dispose() {
17202
+ this.disposables.dispose();
17203
+ }
17204
+
17205
+ }
17206
+
17023
17207
  const asLanguageClientOptionsById = options => options;
17024
17208
 
17025
17209
  const staticOptions = asLanguageClientOptionsById({
@@ -17087,7 +17271,12 @@ const staticOptions = asLanguageClientOptionsById({
17087
17271
  configurationSection: 'cobol-lsp'
17088
17272
  },
17089
17273
  mutualizable: false,
17090
- vscodeExtensionIds: ['cobol']
17274
+ vscodeExtensionIds: ['cobol'],
17275
+
17276
+ createAdditionalFeatures(client) {
17277
+ return [new CobolResolveSubroutineFeature(client)];
17278
+ }
17279
+
17091
17280
  },
17092
17281
  dart: {
17093
17282
  documentSelector: [{
@@ -17143,7 +17332,12 @@ const staticOptions = asLanguageClientOptionsById({
17143
17332
  configurationSection: ['java', 'editor.insertSpaces', 'editor.tabSize']
17144
17333
  },
17145
17334
  mutualizable: true,
17146
- vscodeExtensionIds: ['java']
17335
+ vscodeExtensionIds: ['java'],
17336
+
17337
+ createAdditionalFeatures(client) {
17338
+ return [new JavaExtensionFeature(client)];
17339
+ }
17340
+
17147
17341
  },
17148
17342
  javascript: {
17149
17343
  documentSelector: [{
@@ -17417,63 +17611,6 @@ monaco.editor.onWillDisposeModel(model => {
17417
17611
 
17418
17612
  var main = {};
17419
17613
 
17420
- var api = {};
17421
-
17422
- (function (exports) {
17423
- /* --------------------------------------------------------------------------------------------
17424
- * Copyright (c) Microsoft Corporation. All rights reserved.
17425
- * Licensed under the MIT License. See License.txt in the project root for license information.
17426
- * ------------------------------------------------------------------------------------------ */
17427
-
17428
- var __createBinding = commonjsGlobal && commonjsGlobal.__createBinding || (Object.create ? function (o, m, k, k2) {
17429
- if (k2 === undefined) k2 = k;
17430
- var desc = Object.getOwnPropertyDescriptor(m, k);
17431
-
17432
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17433
- desc = {
17434
- enumerable: true,
17435
- get: function () {
17436
- return m[k];
17437
- }
17438
- };
17439
- }
17440
-
17441
- Object.defineProperty(o, k2, desc);
17442
- } : function (o, m, k, k2) {
17443
- if (k2 === undefined) k2 = k;
17444
- o[k2] = m[k];
17445
- });
17446
-
17447
- var __exportStar = commonjsGlobal && commonjsGlobal.__exportStar || function (m, exports) {
17448
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
17449
- };
17450
-
17451
- Object.defineProperty(exports, "__esModule", {
17452
- value: true
17453
- });
17454
- exports.DiagnosticPullMode = exports.vsdiag = void 0;
17455
-
17456
- __exportStar(require$$0$1, exports);
17457
-
17458
- __exportStar(features, exports);
17459
-
17460
- var diagnostic_1 = diagnostic;
17461
- Object.defineProperty(exports, "vsdiag", {
17462
- enumerable: true,
17463
- get: function () {
17464
- return diagnostic_1.vsdiag;
17465
- }
17466
- });
17467
- Object.defineProperty(exports, "DiagnosticPullMode", {
17468
- enumerable: true,
17469
- get: function () {
17470
- return diagnostic_1.DiagnosticPullMode;
17471
- }
17472
- });
17473
-
17474
- __exportStar(client, exports);
17475
- })(api);
17476
-
17477
17614
  var require$$1 = /*@__PURE__*/getAugmentedNamespace(browser);
17478
17615
 
17479
17616
  (function (exports) {
@@ -17665,6 +17802,15 @@ class WatchableOutputChannel {
17665
17802
  this.onWillCloseEmitter.fire();
17666
17803
  }
17667
17804
 
17805
+ } // eslint-disable-next-line @typescript-eslint/no-explicit-any
17806
+
17807
+
17808
+ function isMessageItem(item) {
17809
+ return item != null && item.title;
17810
+ }
17811
+
17812
+ function getMessage(item) {
17813
+ return isMessageItem(item) ? item.title : item;
17668
17814
  }
17669
17815
 
17670
17816
  class WatchableConsoleWindow {
@@ -17706,11 +17852,28 @@ class WatchableConsoleWindow {
17706
17852
  }
17707
17853
 
17708
17854
  async showMessage(type, message) {
17855
+ var _ref;
17856
+
17709
17857
  for (var _len = arguments.length, actions = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
17710
17858
  actions[_key - 2] = arguments[_key];
17711
17859
  }
17712
17860
 
17713
- const displayedMessage = message + '\n' + actions.map(action => "- ".concat(action.title)).join('\n');
17861
+ const optionsOrFirstItem = actions[0];
17862
+ let items;
17863
+ let options;
17864
+
17865
+ if (typeof optionsOrFirstItem === 'string' || isMessageItem(optionsOrFirstItem)) {
17866
+ items = actions;
17867
+ } else {
17868
+ options = optionsOrFirstItem;
17869
+ items = actions.slice(1);
17870
+ }
17871
+
17872
+ let displayedMessage = message;
17873
+
17874
+ if (items.length > 0) {
17875
+ displayedMessage = "".concat(displayedMessage, "\nActions:\n").concat(items.map(action => "- ".concat(getMessage(action))).join('\n'));
17876
+ }
17714
17877
 
17715
17878
  if (type === Severity.Error) {
17716
17879
  console.error('[LSP]', displayedMessage);
@@ -17724,19 +17887,30 @@ class WatchableConsoleWindow {
17724
17887
  console.info('[LSP]', displayedMessage);
17725
17888
  }
17726
17889
 
17727
- if (actions.length > 1) {
17728
- return swal({
17729
- text: message,
17730
- buttons: actions.reduce((acc, action, index) => _objectSpread2(_objectSpread2({}, acc), {}, {
17890
+ const defaultAction = (_ref = items.find(item => {
17891
+ var _item$isCloseAffordan;
17892
+
17893
+ return isMessageItem(item) && ((_item$isCloseAffordan = item.isCloseAffordance) !== null && _item$isCloseAffordan !== void 0 ? _item$isCloseAffordan : false);
17894
+ })) !== null && _ref !== void 0 ? _ref : actions[0];
17895
+
17896
+ if (items.length > 1) {
17897
+ var _await$swal, _options;
17898
+
17899
+ return (_await$swal = await swal({
17900
+ title: message,
17901
+ text: (_options = options) === null || _options === void 0 ? void 0 : _options.detail,
17902
+ closeOnEsc: true,
17903
+ closeOnClickOutside: true,
17904
+ buttons: items.reduce((acc, action, index) => _objectSpread2(_objectSpread2({}, acc), {}, {
17731
17905
  ["option-".concat(index)]: {
17732
- text: action.title,
17906
+ text: getMessage(action),
17733
17907
  value: action
17734
17908
  }
17735
17909
  }), {})
17736
- });
17910
+ })) !== null && _await$swal !== void 0 ? _await$swal : defaultAction;
17737
17911
  }
17738
17912
 
17739
- return actions[0];
17913
+ return defaultAction;
17740
17914
  }
17741
17915
 
17742
17916
  createOutputChannel(name) {
@@ -18007,24 +18181,12 @@ class CodinGameMonacoEnv {
18007
18181
 
18008
18182
  }
18009
18183
 
18010
- function installCommands() {
18011
- // Comes from https://github.com/redhat-developer/vscode-java/blob/9b0f0aca80cbefabad4c034fb5dd365d029f6170/src/extension.ts#L155-L160
18012
- // Other commands needs to be implemented as well?
18013
- // (https://github.com/eclipse/eclipse.jdt.ls/issues/376#issuecomment-333923685)
18014
- const protocolConverter = createConverter_1(undefined, true, true);
18015
- return vscode$3.commands.registerCommand('java.apply.workspaceEdit', async obj => {
18016
- const edit = await protocolConverter.asWorkspaceEdit(obj);
18017
- return vscode$3.workspace.applyEdit(edit);
18018
- });
18019
- }
18020
-
18021
18184
  const services = {
18022
18185
  workspace: new CodinGameMonacoWorkspace('file:///tmp/project'),
18023
18186
  window: new WatchableConsoleWindow(),
18024
18187
  env: new CodinGameMonacoEnv()
18025
18188
  };
18026
18189
  Services.install(services);
18027
- installCommands();
18028
18190
 
18029
18191
  function updateServices(infrastructure) {
18030
18192
  services.workspace.initialize(infrastructure.rootUri, infrastructure.workspaceFolders, !infrastructure.automaticTextDocumentUpdate);
@@ -18034,197 +18196,23 @@ function getServices() {
18034
18196
  return Services.get();
18035
18197
  }
18036
18198
 
18037
- // Initialize the file content into the lsp server for implementations that don't support open/close notifications
18038
- class InitializeTextDocumentFeature {
18039
- constructor(languageClient) {
18040
- this.languageClient = languageClient;
18199
+ class MiddlewareMessageWriter {
18200
+ constructor(delegate, middleware) {
18201
+ this.delegate = delegate;
18202
+ this.middleware = middleware;
18041
18203
 
18042
- _defineProperty(this, "didOpenTextDocumentDisposable", void 0);
18204
+ _defineProperty(this, "onError", cb => {
18205
+ return this.delegate.onError(cb);
18206
+ });
18207
+
18208
+ _defineProperty(this, "onClose", cb => {
18209
+ return this.delegate.onClose(cb);
18210
+ });
18043
18211
  }
18044
18212
 
18045
- fillClientCapabilities() {}
18046
-
18047
- initialize(capabilities, documentSelector) {
18048
- var _textDocumentSyncOpti;
18049
-
18050
- const textDocumentSyncOptions = capabilities.resolvedTextDocumentSync;
18051
-
18052
- if (documentSelector == null || ((_textDocumentSyncOpti = textDocumentSyncOptions === null || textDocumentSyncOptions === void 0 ? void 0 : textDocumentSyncOptions.openClose) !== null && _textDocumentSyncOpti !== void 0 ? _textDocumentSyncOpti : false)) {
18053
- return;
18054
- }
18055
-
18056
- const languageClient = this.languageClient;
18057
-
18058
- async function saveFile(textDocument) {
18059
- if (documentSelector != null && vscode$3.languages.match(documentSelector, textDocument) > 0) {
18060
- await updateFile(textDocument.uri.toString(), textDocument.getText(), languageClient); // Always send notification even if the server doesn't support it (because csharp register the didSave feature too late)
18061
-
18062
- await languageClient.sendNotification(DidSaveTextDocumentNotification.type, {
18063
- textDocument: {
18064
- uri: textDocument.uri.toString()
18065
- },
18066
- text: textDocument.getText()
18067
- });
18068
- }
18069
- }
18070
-
18071
- this.didOpenTextDocumentDisposable = vscode$3.workspace.onDidOpenTextDocument(saveFile);
18072
- vscode$3.workspace.textDocuments.forEach(saveFile);
18073
- }
18074
-
18075
- getState() {
18076
- return {
18077
- kind: 'static'
18078
- };
18079
- }
18080
-
18081
- dispose() {
18082
- var _this$didOpenTextDocu;
18083
-
18084
- (_this$didOpenTextDocu = this.didOpenTextDocumentDisposable) === null || _this$didOpenTextDocu === void 0 ? void 0 : _this$didOpenTextDocu.dispose();
18085
- }
18086
-
18087
- }
18088
- const ResolveCobolSubroutineRequestType = new api.ProtocolRequestType('cobol/resolveSubroutine');
18089
-
18090
- class CobolResolveSubroutineFeature {
18091
- constructor(languageClient) {
18092
- this.languageClient = languageClient;
18093
-
18094
- _defineProperty(this, "onRequestDisposable", void 0);
18095
- }
18096
-
18097
- fillClientCapabilities() {}
18098
-
18099
- initialize(capabilities, documentSelector) {
18100
- this.onRequestDisposable = this.languageClient.onRequest(ResolveCobolSubroutineRequestType, routineName => {
18101
- var _vscode$workspace$roo, _vscode$workspace$tex;
18102
-
18103
- const constantRoutinePaths = {
18104
- 'assert-equals': "file:".concat((_vscode$workspace$roo = vscode$3.workspace.rootPath) !== null && _vscode$workspace$roo !== void 0 ? _vscode$workspace$roo : '/tmp/project', "/deps/assert-equals.cbl")
18105
- };
18106
- const contantRoutinePath = constantRoutinePaths[routineName.toLowerCase()];
18107
-
18108
- if (contantRoutinePath != null) {
18109
- return contantRoutinePath;
18110
- }
18111
-
18112
- return (_vscode$workspace$tex = vscode$3.workspace.textDocuments.filter(textDocument => vscode$3.languages.match(documentSelector, textDocument)).filter(document => document.getText().match(new RegExp("PROGRAM-ID\\.\\W+".concat(routineName, "\\."), 'gi'))).sort((a, b) => a.uri.toString().localeCompare(b.uri.toString()))[0]) === null || _vscode$workspace$tex === void 0 ? void 0 : _vscode$workspace$tex.uri.toString();
18113
- });
18114
- }
18115
-
18116
- getState() {
18117
- return {
18118
- kind: 'static'
18119
- };
18120
- }
18121
-
18122
- dispose() {
18123
- var _this$onRequestDispos;
18124
-
18125
- (_this$onRequestDispos = this.onRequestDisposable) === null || _this$onRequestDispos === void 0 ? void 0 : _this$onRequestDispos.dispose();
18126
- }
18127
-
18128
- }
18129
-
18130
- function registerExtensionFeatures(client, language) {
18131
- if (language === 'cobol') {
18132
- client.registerFeature(new CobolResolveSubroutineFeature(client));
18133
- }
18134
- }
18135
- class WillDisposeFeature {
18136
- constructor(languageClient, onWillShutdownEmitter) {
18137
- this.languageClient = languageClient;
18138
- this.onWillShutdownEmitter = onWillShutdownEmitter;
18139
- }
18140
-
18141
- fillClientCapabilities() {}
18142
-
18143
- initialize() {
18144
- this.languageClient.onNotification(willShutdownNotificationType, params => {
18145
- this.onWillShutdownEmitter.fire(params);
18146
- });
18147
- }
18148
-
18149
- getState() {
18150
- return {
18151
- kind: 'static'
18152
- };
18153
- }
18154
-
18155
- dispose() {}
18156
-
18157
- }
18158
- class FileSystemFeature {
18159
- constructor(infrastructure, languageClientManager) {
18160
- this.infrastructure = infrastructure;
18161
- this.languageClientManager = languageClientManager;
18162
-
18163
- _defineProperty(this, "disposable", void 0);
18164
- }
18165
-
18166
- registerFileHandlers() {
18167
- const disposableCollection = new DisposableCollection();
18168
- const infrastructure = this.infrastructure;
18169
- const languageClientManager = this.languageClientManager;
18170
- disposableCollection.push(registerTextModelContentProvider('file', {
18171
- async provideTextContent(resource) {
18172
- return await infrastructure.getFileContent(resource, languageClientManager);
18173
- }
18174
-
18175
- }));
18176
- disposableCollection.push(getServices().workspace.registerSaveDocumentHandler({
18177
- async saveTextContent(document, reason) {
18178
- if (languageClientManager.isModelManaged(document)) {
18179
- var _infrastructure$saveF;
18180
-
18181
- await ((_infrastructure$saveF = infrastructure.saveFileContent) === null || _infrastructure$saveF === void 0 ? void 0 : _infrastructure$saveF.call(infrastructure, document, reason, languageClientManager));
18182
- }
18183
- }
18184
-
18185
- }));
18186
- return disposableCollection;
18187
- }
18188
-
18189
- fillClientCapabilities() {}
18190
-
18191
- initialize() {
18192
- this.dispose();
18193
- this.disposable = this.registerFileHandlers();
18194
- }
18195
-
18196
- getState() {
18197
- return {
18198
- kind: 'static'
18199
- };
18200
- }
18201
-
18202
- dispose() {
18203
- var _this$disposable;
18204
-
18205
- (_this$disposable = this.disposable) === null || _this$disposable === void 0 ? void 0 : _this$disposable.dispose();
18206
- this.disposable = undefined;
18207
- }
18208
-
18209
- }
18210
-
18211
- class MiddlewareMessageWriter {
18212
- constructor(delegate, middleware) {
18213
- this.delegate = delegate;
18214
- this.middleware = middleware;
18215
-
18216
- _defineProperty(this, "onError", cb => {
18217
- return this.delegate.onError(cb);
18218
- });
18219
-
18220
- _defineProperty(this, "onClose", cb => {
18221
- return this.delegate.onClose(cb);
18222
- });
18223
- }
18224
-
18225
- dispose() {
18226
- this.delegate.dispose();
18227
- }
18213
+ dispose() {
18214
+ this.delegate.dispose();
18215
+ }
18228
18216
 
18229
18217
  write(msg) {
18230
18218
  return this.delegate.write(this.middleware(msg));
@@ -18356,7 +18344,8 @@ function createLanguageClient(id, infrastructure, _ref, errorHandler, middleware
18356
18344
  let {
18357
18345
  documentSelector,
18358
18346
  synchronize,
18359
- initializationOptions
18347
+ initializationOptions,
18348
+ createAdditionalFeatures
18360
18349
  } = _ref;
18361
18350
  const client = new MonacoLanguageClient({
18362
18351
  id: "".concat(id, "-languageclient"),
@@ -18375,10 +18364,141 @@ function createLanguageClient(id, infrastructure, _ref, errorHandler, middleware
18375
18364
  client.registerConfigurationFeatures();
18376
18365
  client.registerProgressFeatures();
18377
18366
  client.registerTextDocumentSaveFeatures();
18378
- registerExtensionFeatures(client, id);
18367
+
18368
+ if (createAdditionalFeatures != null) {
18369
+ client.registerFeatures(createAdditionalFeatures(client));
18370
+ }
18371
+
18379
18372
  return client;
18380
18373
  }
18381
18374
 
18375
+ // Initialize the file content into the lsp server for implementations that don't support open/close notifications
18376
+ class InitializeTextDocumentFeature {
18377
+ constructor(languageClient) {
18378
+ this.languageClient = languageClient;
18379
+
18380
+ _defineProperty(this, "didOpenTextDocumentDisposable", void 0);
18381
+ }
18382
+
18383
+ fillClientCapabilities() {}
18384
+
18385
+ initialize(capabilities, documentSelector) {
18386
+ var _textDocumentSyncOpti;
18387
+
18388
+ const textDocumentSyncOptions = capabilities.resolvedTextDocumentSync;
18389
+
18390
+ if (documentSelector == null || ((_textDocumentSyncOpti = textDocumentSyncOptions === null || textDocumentSyncOptions === void 0 ? void 0 : textDocumentSyncOptions.openClose) !== null && _textDocumentSyncOpti !== void 0 ? _textDocumentSyncOpti : false)) {
18391
+ return;
18392
+ }
18393
+
18394
+ const languageClient = this.languageClient;
18395
+
18396
+ async function saveFile(textDocument) {
18397
+ if (documentSelector != null && vscode$3.languages.match(documentSelector, textDocument) > 0) {
18398
+ await updateFile(textDocument.uri.toString(), textDocument.getText(), languageClient); // Always send notification even if the server doesn't support it (because csharp register the didSave feature too late)
18399
+
18400
+ await languageClient.sendNotification(DidSaveTextDocumentNotification.type, {
18401
+ textDocument: {
18402
+ uri: textDocument.uri.toString()
18403
+ },
18404
+ text: textDocument.getText()
18405
+ });
18406
+ }
18407
+ }
18408
+
18409
+ this.didOpenTextDocumentDisposable = vscode$3.workspace.onDidOpenTextDocument(saveFile);
18410
+ vscode$3.workspace.textDocuments.forEach(saveFile);
18411
+ }
18412
+
18413
+ getState() {
18414
+ return {
18415
+ kind: 'static'
18416
+ };
18417
+ }
18418
+
18419
+ dispose() {
18420
+ var _this$didOpenTextDocu;
18421
+
18422
+ (_this$didOpenTextDocu = this.didOpenTextDocumentDisposable) === null || _this$didOpenTextDocu === void 0 ? void 0 : _this$didOpenTextDocu.dispose();
18423
+ }
18424
+
18425
+ }
18426
+ class WillDisposeFeature {
18427
+ constructor(languageClient, onWillShutdownEmitter) {
18428
+ this.languageClient = languageClient;
18429
+ this.onWillShutdownEmitter = onWillShutdownEmitter;
18430
+ }
18431
+
18432
+ fillClientCapabilities() {}
18433
+
18434
+ initialize() {
18435
+ this.languageClient.onNotification(willShutdownNotificationType, params => {
18436
+ this.onWillShutdownEmitter.fire(params);
18437
+ });
18438
+ }
18439
+
18440
+ getState() {
18441
+ return {
18442
+ kind: 'static'
18443
+ };
18444
+ }
18445
+
18446
+ dispose() {}
18447
+
18448
+ }
18449
+ class FileSystemFeature {
18450
+ constructor(infrastructure, languageClientManager) {
18451
+ this.infrastructure = infrastructure;
18452
+ this.languageClientManager = languageClientManager;
18453
+
18454
+ _defineProperty(this, "disposable", void 0);
18455
+ }
18456
+
18457
+ registerFileHandlers() {
18458
+ const disposableCollection = new DisposableCollection();
18459
+ const infrastructure = this.infrastructure;
18460
+ const languageClientManager = this.languageClientManager;
18461
+ disposableCollection.push(registerTextModelContentProvider('file', {
18462
+ async provideTextContent(resource) {
18463
+ return await infrastructure.getFileContent(resource, languageClientManager);
18464
+ }
18465
+
18466
+ }));
18467
+ disposableCollection.push(getServices().workspace.registerSaveDocumentHandler({
18468
+ async saveTextContent(document, reason) {
18469
+ if (languageClientManager.isModelManaged(document)) {
18470
+ var _infrastructure$saveF;
18471
+
18472
+ await ((_infrastructure$saveF = infrastructure.saveFileContent) === null || _infrastructure$saveF === void 0 ? void 0 : _infrastructure$saveF.call(infrastructure, document, reason, languageClientManager));
18473
+ }
18474
+ }
18475
+
18476
+ }));
18477
+ return disposableCollection;
18478
+ }
18479
+
18480
+ fillClientCapabilities() {}
18481
+
18482
+ initialize() {
18483
+ this.dispose();
18484
+ this.disposable = this.registerFileHandlers();
18485
+ }
18486
+
18487
+ getState() {
18488
+ return {
18489
+ kind: 'static'
18490
+ };
18491
+ }
18492
+
18493
+ dispose() {
18494
+ var _this$disposable;
18495
+
18496
+ (_this$disposable = this.disposable) === null || _this$disposable === void 0 ? void 0 : _this$disposable.dispose();
18497
+ this.disposable = undefined;
18498
+ }
18499
+
18500
+ }
18501
+
18382
18502
  const RETRY_CONNECTION_DELAY = 3000;
18383
18503
  class LanguageClientManager {
18384
18504
  constructor(id, clientOptions, infrastructure, managerOptions) {
@@ -18703,4 +18823,4 @@ function createLanguageClientManager(id, infrastructure) {
18703
18823
  return new LanguageClientManager(id, clientOptions, infrastructure, managerOptions);
18704
18824
  }
18705
18825
 
18706
- export { CodinGameInfrastructure, LanguageClientManager, createLanguageClientManager, loadExtensionConfigurations, registerLanguageClient };
18826
+ export { CodinGameInfrastructure, LanguageClientManager, createLanguageClientManager, getLanguageClientOptions, loadExtensionConfigurations, registerLanguageClient };