@codingame/monaco-languageclient-wrapper 3.0.3 → 3.1.2

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
@@ -1,8 +1,8 @@
1
- import { toSocket, WebSocketMessageReader, WebSocketMessageWriter } from '@codingame/monaco-jsonrpc';
1
+ import { toSocket, WebSocketMessageReader, WebSocketMessageWriter } from 'vscode-ws-jsonrpc';
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
 
@@ -16782,16 +16782,18 @@ class MonacoLanguageClient extends client.BaseLanguageClient {
16782
16782
  super(id || name.toLowerCase(), name, clientOptions);
16783
16783
  this.connectionProvider = connectionProvider; // Hack because vscode-language client rejects the whole registration block if one capability registration has no associated client feature registered
16784
16784
  // Some language servers still send the registration even though the client says it doesn't support it
16785
+ // eslint-disable-next-line @typescript-eslint/dot-notation
16785
16786
 
16786
- const originalHandleRegistrationRequest = this['handleRegistrationRequest'].bind(this);
16787
+ const originalHandleRegistrationRequest = this['handleRegistrationRequest'].bind(this); // eslint-disable-next-line @typescript-eslint/dot-notation
16787
16788
 
16788
16789
  this['handleRegistrationRequest'] = params => {
16789
16790
  originalHandleRegistrationRequest(_objectSpread2(_objectSpread2({}, params), {}, {
16790
16791
  registrations: params.registrations.filter(registration => this.getFeature(registration.method) != null)
16791
16792
  }));
16792
- };
16793
+ }; // eslint-disable-next-line @typescript-eslint/dot-notation
16794
+
16793
16795
 
16794
- const originalHandleUnregistrationRequest = this['handleUnregistrationRequest'].bind(this);
16796
+ const originalHandleUnregistrationRequest = this['handleUnregistrationRequest'].bind(this); // eslint-disable-next-line @typescript-eslint/dot-notation
16795
16797
 
16796
16798
  this['handleUnregistrationRequest'] = params => {
16797
16799
  originalHandleUnregistrationRequest(_objectSpread2(_objectSpread2({}, params), {}, {
@@ -16809,8 +16811,10 @@ class MonacoLanguageClient extends client.BaseLanguageClient {
16809
16811
  }
16810
16812
 
16811
16813
  registerBuiltinFeatures() {
16814
+ // eslint-disable-next-line @typescript-eslint/dot-notation
16812
16815
  this.registerFeature(new DidOpenTextDocumentFeature_1(this, this['_syncedDocuments']));
16813
- this.registerFeature(new DidChangeTextDocumentFeature_1(this));
16816
+ this.registerFeature(new DidChangeTextDocumentFeature_1(this)); // eslint-disable-next-line @typescript-eslint/dot-notation
16817
+
16814
16818
  this.registerFeature(new DidCloseTextDocumentFeature_1(this, this['_syncedDocuments']));
16815
16819
  this.registerFeature(new CompletionItemFeature_1(this));
16816
16820
  this.registerFeature(new HoverFeature_1(this));
@@ -17020,6 +17024,190 @@ var ProtocolInlayHint;
17020
17024
  ProtocolInlayHint.is = is;
17021
17025
  })(ProtocolInlayHint || (ProtocolInlayHint = {}));
17022
17026
 
17027
+ var api = {};
17028
+
17029
+ (function (exports) {
17030
+ /* --------------------------------------------------------------------------------------------
17031
+ * Copyright (c) Microsoft Corporation. All rights reserved.
17032
+ * Licensed under the MIT License. See License.txt in the project root for license information.
17033
+ * ------------------------------------------------------------------------------------------ */
17034
+
17035
+ var __createBinding = commonjsGlobal && commonjsGlobal.__createBinding || (Object.create ? function (o, m, k, k2) {
17036
+ if (k2 === undefined) k2 = k;
17037
+ var desc = Object.getOwnPropertyDescriptor(m, k);
17038
+
17039
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17040
+ desc = {
17041
+ enumerable: true,
17042
+ get: function () {
17043
+ return m[k];
17044
+ }
17045
+ };
17046
+ }
17047
+
17048
+ Object.defineProperty(o, k2, desc);
17049
+ } : function (o, m, k, k2) {
17050
+ if (k2 === undefined) k2 = k;
17051
+ o[k2] = m[k];
17052
+ });
17053
+
17054
+ var __exportStar = commonjsGlobal && commonjsGlobal.__exportStar || function (m, exports) {
17055
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
17056
+ };
17057
+
17058
+ Object.defineProperty(exports, "__esModule", {
17059
+ value: true
17060
+ });
17061
+ exports.DiagnosticPullMode = exports.vsdiag = void 0;
17062
+
17063
+ __exportStar(require$$0$1, exports);
17064
+
17065
+ __exportStar(features, exports);
17066
+
17067
+ var diagnostic_1 = diagnostic;
17068
+ Object.defineProperty(exports, "vsdiag", {
17069
+ enumerable: true,
17070
+ get: function () {
17071
+ return diagnostic_1.vsdiag;
17072
+ }
17073
+ });
17074
+ Object.defineProperty(exports, "DiagnosticPullMode", {
17075
+ enumerable: true,
17076
+ get: function () {
17077
+ return diagnostic_1.DiagnosticPullMode;
17078
+ }
17079
+ });
17080
+
17081
+ __exportStar(client, exports);
17082
+ })(api);
17083
+
17084
+ const ResolveCobolSubroutineRequestType = new api.ProtocolRequestType('cobol/resolveSubroutine');
17085
+ class CobolResolveSubroutineFeature {
17086
+ constructor(languageClient) {
17087
+ this.languageClient = languageClient;
17088
+
17089
+ _defineProperty(this, "onRequestDisposable", void 0);
17090
+ }
17091
+
17092
+ fillClientCapabilities() {}
17093
+
17094
+ initialize(capabilities, documentSelector) {
17095
+ this.onRequestDisposable = this.languageClient.onRequest(ResolveCobolSubroutineRequestType, routineName => {
17096
+ var _vscode$workspace$roo, _vscode$workspace$tex;
17097
+
17098
+ const constantRoutinePaths = {
17099
+ '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")
17100
+ };
17101
+ const contantRoutinePath = constantRoutinePaths[routineName.toLowerCase()];
17102
+
17103
+ if (contantRoutinePath != null) {
17104
+ return contantRoutinePath;
17105
+ }
17106
+
17107
+ 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();
17108
+ });
17109
+ }
17110
+
17111
+ getState() {
17112
+ return {
17113
+ kind: 'static'
17114
+ };
17115
+ }
17116
+
17117
+ dispose() {
17118
+ var _this$onRequestDispos;
17119
+
17120
+ (_this$onRequestDispos = this.onRequestDisposable) === null || _this$onRequestDispos === void 0 ? void 0 : _this$onRequestDispos.dispose();
17121
+ }
17122
+
17123
+ }
17124
+
17125
+ async function asInlayHints(values, client) {
17126
+ if (!Array.isArray(values)) {
17127
+ return undefined;
17128
+ }
17129
+
17130
+ return values.map(lsHint => asInlayHint(lsHint, client));
17131
+ }
17132
+
17133
+ function asInlayHint(value, client) {
17134
+ const label = value.label;
17135
+ const result = new vscode$3.InlayHint(client.protocol2CodeConverter.asPosition(value.position), label);
17136
+ result.paddingRight = true;
17137
+ result.kind = vscode$3.InlayHintKind.Parameter;
17138
+ return result;
17139
+ }
17140
+ /**
17141
+ * Comes from https://github.com/redhat-developer/vscode-java/blob/9b6046eecc65fd47507f309a3ccc9add45c6d3be/src/inlayHintsProvider.ts#L5
17142
+ */
17143
+
17144
+
17145
+ class JavaInlayHintsProvider {
17146
+ constructor(client) {
17147
+ this.client = client;
17148
+
17149
+ _defineProperty(this, "onDidChange", new vscode$3.EventEmitter());
17150
+
17151
+ _defineProperty(this, "onDidChangeInlayHints", this.onDidChange.event);
17152
+
17153
+ this.client.onRequest(InlayHintRefreshRequest.type, async () => {
17154
+ this.onDidChange.fire();
17155
+ });
17156
+ }
17157
+
17158
+ async provideInlayHints(document, range, token) {
17159
+ const requestParams = {
17160
+ textDocument: this.client.code2ProtocolConverter.asTextDocumentIdentifier(document),
17161
+ range: this.client.code2ProtocolConverter.asRange(range)
17162
+ };
17163
+
17164
+ try {
17165
+ const values = await this.client.sendRequest(InlayHintRequest.type, requestParams, token);
17166
+
17167
+ if (token.isCancellationRequested) {
17168
+ return [];
17169
+ }
17170
+
17171
+ return asInlayHints(values, this.client);
17172
+ } catch (error) {
17173
+ return this.client.handleFailedRequest(InlayHintRequest.type, token, error, []);
17174
+ }
17175
+ }
17176
+
17177
+ }
17178
+
17179
+ class JavaExtensionFeature {
17180
+ constructor(languageClient) {
17181
+ this.languageClient = languageClient;
17182
+
17183
+ _defineProperty(this, "disposables", void 0);
17184
+
17185
+ this.disposables = new DisposableCollection();
17186
+ }
17187
+
17188
+ fillClientCapabilities() {}
17189
+
17190
+ initialize() {
17191
+ // Comes from https://github.com/redhat-developer/vscode-java/blob/9b6046eecc65fd47507f309a3ccc9add45c6d3be/src/standardLanguageClient.ts#L321
17192
+ this.disposables.push(vscode$3.commands.registerCommand('java.apply.workspaceEdit', async obj => {
17193
+ const edit = await this.languageClient.protocol2CodeConverter.asWorkspaceEdit(obj);
17194
+ return vscode$3.workspace.applyEdit(edit);
17195
+ }));
17196
+ this.disposables.push(vscode$3.languages.registerInlayHintsProvider(this.languageClient.clientOptions.documentSelector, new JavaInlayHintsProvider(this.languageClient)));
17197
+ }
17198
+
17199
+ getState() {
17200
+ return {
17201
+ kind: 'static'
17202
+ };
17203
+ }
17204
+
17205
+ dispose() {
17206
+ this.disposables.dispose();
17207
+ }
17208
+
17209
+ }
17210
+
17023
17211
  const asLanguageClientOptionsById = options => options;
17024
17212
 
17025
17213
  const staticOptions = asLanguageClientOptionsById({
@@ -17087,7 +17275,12 @@ const staticOptions = asLanguageClientOptionsById({
17087
17275
  configurationSection: 'cobol-lsp'
17088
17276
  },
17089
17277
  mutualizable: false,
17090
- vscodeExtensionIds: ['cobol']
17278
+ vscodeExtensionIds: ['cobol'],
17279
+
17280
+ createAdditionalFeatures(client) {
17281
+ return [new CobolResolveSubroutineFeature(client)];
17282
+ }
17283
+
17091
17284
  },
17092
17285
  dart: {
17093
17286
  documentSelector: [{
@@ -17143,7 +17336,12 @@ const staticOptions = asLanguageClientOptionsById({
17143
17336
  configurationSection: ['java', 'editor.insertSpaces', 'editor.tabSize']
17144
17337
  },
17145
17338
  mutualizable: true,
17146
- vscodeExtensionIds: ['java']
17339
+ vscodeExtensionIds: ['java'],
17340
+
17341
+ createAdditionalFeatures(client) {
17342
+ return [new JavaExtensionFeature(client)];
17343
+ }
17344
+
17147
17345
  },
17148
17346
  javascript: {
17149
17347
  documentSelector: [{
@@ -17417,63 +17615,6 @@ monaco.editor.onWillDisposeModel(model => {
17417
17615
 
17418
17616
  var main = {};
17419
17617
 
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
17618
  var require$$1 = /*@__PURE__*/getAugmentedNamespace(browser);
17478
17619
 
17479
17620
  (function (exports) {
@@ -17665,6 +17806,15 @@ class WatchableOutputChannel {
17665
17806
  this.onWillCloseEmitter.fire();
17666
17807
  }
17667
17808
 
17809
+ } // eslint-disable-next-line @typescript-eslint/no-explicit-any
17810
+
17811
+
17812
+ function isMessageItem(item) {
17813
+ return item != null && item.title;
17814
+ }
17815
+
17816
+ function getMessage(item) {
17817
+ return isMessageItem(item) ? item.title : item;
17668
17818
  }
17669
17819
 
17670
17820
  class WatchableConsoleWindow {
@@ -17706,11 +17856,28 @@ class WatchableConsoleWindow {
17706
17856
  }
17707
17857
 
17708
17858
  async showMessage(type, message) {
17859
+ var _ref;
17860
+
17709
17861
  for (var _len = arguments.length, actions = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
17710
17862
  actions[_key - 2] = arguments[_key];
17711
17863
  }
17712
17864
 
17713
- const displayedMessage = message + '\n' + actions.map(action => "- ".concat(action.title)).join('\n');
17865
+ const optionsOrFirstItem = actions[0];
17866
+ let items;
17867
+ let options;
17868
+
17869
+ if (typeof optionsOrFirstItem === 'string' || isMessageItem(optionsOrFirstItem)) {
17870
+ items = actions;
17871
+ } else {
17872
+ options = optionsOrFirstItem;
17873
+ items = actions.slice(1);
17874
+ }
17875
+
17876
+ let displayedMessage = message;
17877
+
17878
+ if (items.length > 0) {
17879
+ displayedMessage = "".concat(displayedMessage, "\nActions:\n").concat(items.map(action => "- ".concat(getMessage(action))).join('\n'));
17880
+ }
17714
17881
 
17715
17882
  if (type === Severity.Error) {
17716
17883
  console.error('[LSP]', displayedMessage);
@@ -17724,19 +17891,30 @@ class WatchableConsoleWindow {
17724
17891
  console.info('[LSP]', displayedMessage);
17725
17892
  }
17726
17893
 
17727
- if (actions.length > 1) {
17728
- return swal({
17729
- text: message,
17730
- buttons: actions.reduce((acc, action, index) => _objectSpread2(_objectSpread2({}, acc), {}, {
17894
+ const defaultAction = (_ref = items.find(item => {
17895
+ var _item$isCloseAffordan;
17896
+
17897
+ return isMessageItem(item) && ((_item$isCloseAffordan = item.isCloseAffordance) !== null && _item$isCloseAffordan !== void 0 ? _item$isCloseAffordan : false);
17898
+ })) !== null && _ref !== void 0 ? _ref : actions[0];
17899
+
17900
+ if (items.length > 1) {
17901
+ var _await$swal, _options;
17902
+
17903
+ return (_await$swal = await swal({
17904
+ title: message,
17905
+ text: (_options = options) === null || _options === void 0 ? void 0 : _options.detail,
17906
+ closeOnEsc: true,
17907
+ closeOnClickOutside: true,
17908
+ buttons: items.reduce((acc, action, index) => _objectSpread2(_objectSpread2({}, acc), {}, {
17731
17909
  ["option-".concat(index)]: {
17732
- text: action.title,
17910
+ text: getMessage(action),
17733
17911
  value: action
17734
17912
  }
17735
17913
  }), {})
17736
- });
17914
+ })) !== null && _await$swal !== void 0 ? _await$swal : defaultAction;
17737
17915
  }
17738
17916
 
17739
- return actions[0];
17917
+ return defaultAction;
17740
17918
  }
17741
17919
 
17742
17920
  createOutputChannel(name) {
@@ -18007,24 +18185,12 @@ class CodinGameMonacoEnv {
18007
18185
 
18008
18186
  }
18009
18187
 
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
18188
  const services = {
18022
18189
  workspace: new CodinGameMonacoWorkspace('file:///tmp/project'),
18023
18190
  window: new WatchableConsoleWindow(),
18024
18191
  env: new CodinGameMonacoEnv()
18025
18192
  };
18026
18193
  Services.install(services);
18027
- installCommands();
18028
18194
 
18029
18195
  function updateServices(infrastructure) {
18030
18196
  services.workspace.initialize(infrastructure.rootUri, infrastructure.workspaceFolders, !infrastructure.automaticTextDocumentUpdate);
@@ -18034,193 +18200,19 @@ function getServices() {
18034
18200
  return Services.get();
18035
18201
  }
18036
18202
 
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;
18203
+ class MiddlewareMessageWriter {
18204
+ constructor(delegate, middleware) {
18205
+ this.delegate = delegate;
18206
+ this.middleware = middleware;
18041
18207
 
18042
- _defineProperty(this, "didOpenTextDocumentDisposable", void 0);
18043
- }
18208
+ _defineProperty(this, "onError", cb => {
18209
+ return this.delegate.onError(cb);
18210
+ });
18044
18211
 
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
- }
18212
+ _defineProperty(this, "onClose", cb => {
18213
+ return this.delegate.onClose(cb);
18214
+ });
18215
+ }
18224
18216
 
18225
18217
  dispose() {
18226
18218
  this.delegate.dispose();
@@ -18356,7 +18348,8 @@ function createLanguageClient(id, infrastructure, _ref, errorHandler, middleware
18356
18348
  let {
18357
18349
  documentSelector,
18358
18350
  synchronize,
18359
- initializationOptions
18351
+ initializationOptions,
18352
+ createAdditionalFeatures
18360
18353
  } = _ref;
18361
18354
  const client = new MonacoLanguageClient({
18362
18355
  id: "".concat(id, "-languageclient"),
@@ -18375,10 +18368,141 @@ function createLanguageClient(id, infrastructure, _ref, errorHandler, middleware
18375
18368
  client.registerConfigurationFeatures();
18376
18369
  client.registerProgressFeatures();
18377
18370
  client.registerTextDocumentSaveFeatures();
18378
- registerExtensionFeatures(client, id);
18371
+
18372
+ if (createAdditionalFeatures != null) {
18373
+ client.registerFeatures(createAdditionalFeatures(client));
18374
+ }
18375
+
18379
18376
  return client;
18380
18377
  }
18381
18378
 
18379
+ // Initialize the file content into the lsp server for implementations that don't support open/close notifications
18380
+ class InitializeTextDocumentFeature {
18381
+ constructor(languageClient) {
18382
+ this.languageClient = languageClient;
18383
+
18384
+ _defineProperty(this, "didOpenTextDocumentDisposable", void 0);
18385
+ }
18386
+
18387
+ fillClientCapabilities() {}
18388
+
18389
+ initialize(capabilities, documentSelector) {
18390
+ var _textDocumentSyncOpti;
18391
+
18392
+ const textDocumentSyncOptions = capabilities.resolvedTextDocumentSync;
18393
+
18394
+ if (documentSelector == null || ((_textDocumentSyncOpti = textDocumentSyncOptions === null || textDocumentSyncOptions === void 0 ? void 0 : textDocumentSyncOptions.openClose) !== null && _textDocumentSyncOpti !== void 0 ? _textDocumentSyncOpti : false)) {
18395
+ return;
18396
+ }
18397
+
18398
+ const languageClient = this.languageClient;
18399
+
18400
+ async function saveFile(textDocument) {
18401
+ if (documentSelector != null && vscode$3.languages.match(documentSelector, textDocument) > 0) {
18402
+ 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)
18403
+
18404
+ await languageClient.sendNotification(DidSaveTextDocumentNotification.type, {
18405
+ textDocument: {
18406
+ uri: textDocument.uri.toString()
18407
+ },
18408
+ text: textDocument.getText()
18409
+ });
18410
+ }
18411
+ }
18412
+
18413
+ this.didOpenTextDocumentDisposable = vscode$3.workspace.onDidOpenTextDocument(saveFile);
18414
+ vscode$3.workspace.textDocuments.forEach(saveFile);
18415
+ }
18416
+
18417
+ getState() {
18418
+ return {
18419
+ kind: 'static'
18420
+ };
18421
+ }
18422
+
18423
+ dispose() {
18424
+ var _this$didOpenTextDocu;
18425
+
18426
+ (_this$didOpenTextDocu = this.didOpenTextDocumentDisposable) === null || _this$didOpenTextDocu === void 0 ? void 0 : _this$didOpenTextDocu.dispose();
18427
+ }
18428
+
18429
+ }
18430
+ class WillDisposeFeature {
18431
+ constructor(languageClient, onWillShutdownEmitter) {
18432
+ this.languageClient = languageClient;
18433
+ this.onWillShutdownEmitter = onWillShutdownEmitter;
18434
+ }
18435
+
18436
+ fillClientCapabilities() {}
18437
+
18438
+ initialize() {
18439
+ this.languageClient.onNotification(willShutdownNotificationType, params => {
18440
+ this.onWillShutdownEmitter.fire(params);
18441
+ });
18442
+ }
18443
+
18444
+ getState() {
18445
+ return {
18446
+ kind: 'static'
18447
+ };
18448
+ }
18449
+
18450
+ dispose() {}
18451
+
18452
+ }
18453
+ class FileSystemFeature {
18454
+ constructor(infrastructure, languageClientManager) {
18455
+ this.infrastructure = infrastructure;
18456
+ this.languageClientManager = languageClientManager;
18457
+
18458
+ _defineProperty(this, "disposable", void 0);
18459
+ }
18460
+
18461
+ registerFileHandlers() {
18462
+ const disposableCollection = new DisposableCollection();
18463
+ const infrastructure = this.infrastructure;
18464
+ const languageClientManager = this.languageClientManager;
18465
+ disposableCollection.push(registerTextModelContentProvider('file', {
18466
+ async provideTextContent(resource) {
18467
+ return await infrastructure.getFileContent(resource, languageClientManager);
18468
+ }
18469
+
18470
+ }));
18471
+ disposableCollection.push(getServices().workspace.registerSaveDocumentHandler({
18472
+ async saveTextContent(document, reason) {
18473
+ if (languageClientManager.isModelManaged(document)) {
18474
+ var _infrastructure$saveF;
18475
+
18476
+ await ((_infrastructure$saveF = infrastructure.saveFileContent) === null || _infrastructure$saveF === void 0 ? void 0 : _infrastructure$saveF.call(infrastructure, document, reason, languageClientManager));
18477
+ }
18478
+ }
18479
+
18480
+ }));
18481
+ return disposableCollection;
18482
+ }
18483
+
18484
+ fillClientCapabilities() {}
18485
+
18486
+ initialize() {
18487
+ this.dispose();
18488
+ this.disposable = this.registerFileHandlers();
18489
+ }
18490
+
18491
+ getState() {
18492
+ return {
18493
+ kind: 'static'
18494
+ };
18495
+ }
18496
+
18497
+ dispose() {
18498
+ var _this$disposable;
18499
+
18500
+ (_this$disposable = this.disposable) === null || _this$disposable === void 0 ? void 0 : _this$disposable.dispose();
18501
+ this.disposable = undefined;
18502
+ }
18503
+
18504
+ }
18505
+
18382
18506
  const RETRY_CONNECTION_DELAY = 3000;
18383
18507
  class LanguageClientManager {
18384
18508
  constructor(id, clientOptions, infrastructure, managerOptions) {
@@ -18703,4 +18827,4 @@ function createLanguageClientManager(id, infrastructure) {
18703
18827
  return new LanguageClientManager(id, clientOptions, infrastructure, managerOptions);
18704
18828
  }
18705
18829
 
18706
- export { CodinGameInfrastructure, LanguageClientManager, createLanguageClientManager, loadExtensionConfigurations, registerLanguageClient };
18830
+ export { CodinGameInfrastructure, LanguageClientManager, createLanguageClientManager, getLanguageClientOptions, loadExtensionConfigurations, registerLanguageClient };