@codingame/monaco-languageclient-wrapper 5.0.0-update-monaco.4 → 5.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 (71) hide show
  1. package/dist/createLanguageClient.js +130 -0
  2. package/dist/{src/customRequests.js → customRequests.js} +11 -11
  3. package/dist/{src/extensionConfiguration.js → extensionConfiguration.js} +1 -1
  4. package/dist/extensions/cobol.js +27 -0
  5. package/dist/extensions/csharp.js +27 -0
  6. package/dist/extensions/java/commands.js +70 -70
  7. package/dist/extensions/java/extension.js +9 -8
  8. package/dist/extensions/java/inlayHintsProvider.js +43 -42
  9. package/dist/extensions/java/protocol.js +19 -19
  10. package/dist/extensions/java/sourceAction.js +328 -328
  11. package/dist/extensions/java.js +34 -0
  12. package/dist/extensions/tools.js +66 -0
  13. package/dist/extensions.js +171 -0
  14. package/dist/index.js +5 -5
  15. package/dist/infrastructure.js +89 -0
  16. package/dist/languageClient.js +314 -0
  17. package/dist/languageClientOptions.js +16 -0
  18. package/dist/node_modules/tslib/tslib.es6.js +9 -9
  19. package/dist/services.js +8 -0
  20. package/dist/staticOptions.js +421 -0
  21. package/package.json +12 -13
  22. package/stats.html +1 -1
  23. package/dist/_virtual/_commonjsHelpers.js +0 -5
  24. package/dist/_virtual/_rollupPluginBabelHelpers.js +0 -50
  25. package/dist/_virtual/api.js +0 -2
  26. package/dist/_virtual/cancellation.js +0 -2
  27. package/dist/_virtual/connection.js +0 -2
  28. package/dist/_virtual/disposable.js +0 -2
  29. package/dist/_virtual/events.js +0 -2
  30. package/dist/_virtual/is.js +0 -2
  31. package/dist/_virtual/linkedMap.js +0 -2
  32. package/dist/_virtual/main.js +0 -2
  33. package/dist/_virtual/messageBuffer.js +0 -2
  34. package/dist/_virtual/messageReader.js +0 -2
  35. package/dist/_virtual/messageWriter.js +0 -2
  36. package/dist/_virtual/messages.js +0 -2
  37. package/dist/_virtual/once.js +0 -2
  38. package/dist/_virtual/ral.js +0 -2
  39. package/dist/_virtual/ril.js +0 -2
  40. package/dist/_virtual/semaphore.js +0 -2
  41. package/dist/_virtual/sharedArrayCancellation.js +0 -2
  42. package/dist/node_modules/delay/index.js +0 -45
  43. package/dist/node_modules/once/once.js +0 -44
  44. package/dist/node_modules/vscode-jsonrpc/lib/browser/main.js +0 -77
  45. package/dist/node_modules/vscode-jsonrpc/lib/browser/ril.js +0 -153
  46. package/dist/node_modules/vscode-jsonrpc/lib/common/api.js +0 -96
  47. package/dist/node_modules/vscode-jsonrpc/lib/common/cancellation.js +0 -95
  48. package/dist/node_modules/vscode-jsonrpc/lib/common/connection.js +0 -1182
  49. package/dist/node_modules/vscode-jsonrpc/lib/common/disposable.js +0 -19
  50. package/dist/node_modules/vscode-jsonrpc/lib/common/events.js +0 -121
  51. package/dist/node_modules/vscode-jsonrpc/lib/common/is.js +0 -38
  52. package/dist/node_modules/vscode-jsonrpc/lib/common/linkedMap.js +0 -386
  53. package/dist/node_modules/vscode-jsonrpc/lib/common/messageBuffer.js +0 -149
  54. package/dist/node_modules/vscode-jsonrpc/lib/common/messageReader.js +0 -198
  55. package/dist/node_modules/vscode-jsonrpc/lib/common/messageWriter.js +0 -122
  56. package/dist/node_modules/vscode-jsonrpc/lib/common/messages.js +0 -240
  57. package/dist/node_modules/vscode-jsonrpc/lib/common/ral.js +0 -26
  58. package/dist/node_modules/vscode-jsonrpc/lib/common/semaphore.js +0 -72
  59. package/dist/node_modules/vscode-jsonrpc/lib/common/sharedArrayCancellation.js +0 -80
  60. package/dist/node_modules/wrappy/wrappy.js +0 -25
  61. package/dist/src/createLanguageClient.js +0 -131
  62. package/dist/src/extensions/cobol.js +0 -24
  63. package/dist/src/extensions/csharp.js +0 -29
  64. package/dist/src/extensions/java.js +0 -36
  65. package/dist/src/extensions/tools.js +0 -91
  66. package/dist/src/extensions.js +0 -172
  67. package/dist/src/infrastructure.js +0 -87
  68. package/dist/src/languageClient.js +0 -305
  69. package/dist/src/languageClientOptions.js +0 -16
  70. package/dist/src/services.js +0 -8
  71. package/dist/src/staticOptions.js +0 -441
@@ -1,80 +0,0 @@
1
- import { __exports as sharedArrayCancellation } from '../../../../_virtual/sharedArrayCancellation.js';
2
- import { __require as requireCancellation } from './cancellation.js';
3
- var hasRequiredSharedArrayCancellation;
4
- function requireSharedArrayCancellation () {
5
- if (hasRequiredSharedArrayCancellation) return sharedArrayCancellation;
6
- hasRequiredSharedArrayCancellation = 1;
7
- Object.defineProperty(sharedArrayCancellation, "__esModule", { value: true });
8
- sharedArrayCancellation.SharedArrayReceiverStrategy = sharedArrayCancellation.SharedArraySenderStrategy = void 0;
9
- const cancellation_1 = requireCancellation();
10
- var CancellationState;
11
- (function (CancellationState) {
12
- CancellationState.Continue = 0;
13
- CancellationState.Cancelled = 1;
14
- })(CancellationState || (CancellationState = {}));
15
- class SharedArraySenderStrategy {
16
- constructor() {
17
- this.buffers = new Map();
18
- }
19
- enableCancellation(request) {
20
- if (request.id === null) {
21
- return;
22
- }
23
- const buffer = new SharedArrayBuffer(4);
24
- const data = new Int32Array(buffer, 0, 1);
25
- data[0] = CancellationState.Continue;
26
- this.buffers.set(request.id, buffer);
27
- request.$cancellationData = buffer;
28
- }
29
- async sendCancellation(_conn, id) {
30
- const buffer = this.buffers.get(id);
31
- if (buffer === undefined) {
32
- return;
33
- }
34
- const data = new Int32Array(buffer, 0, 1);
35
- Atomics.store(data, 0, CancellationState.Cancelled);
36
- }
37
- cleanup(id) {
38
- this.buffers.delete(id);
39
- }
40
- dispose() {
41
- this.buffers.clear();
42
- }
43
- }
44
- sharedArrayCancellation.SharedArraySenderStrategy = SharedArraySenderStrategy;
45
- class SharedArrayBufferCancellationToken {
46
- constructor(buffer) {
47
- this.data = new Int32Array(buffer, 0, 1);
48
- }
49
- get isCancellationRequested() {
50
- return Atomics.load(this.data, 0) === CancellationState.Cancelled;
51
- }
52
- get onCancellationRequested() {
53
- throw new Error(`Cancellation over SharedArrayBuffer doesn't support cancellation events`);
54
- }
55
- }
56
- class SharedArrayBufferCancellationTokenSource {
57
- constructor(buffer) {
58
- this.token = new SharedArrayBufferCancellationToken(buffer);
59
- }
60
- cancel() {
61
- }
62
- dispose() {
63
- }
64
- }
65
- class SharedArrayReceiverStrategy {
66
- constructor() {
67
- this.kind = 'request';
68
- }
69
- createCancellationTokenSource(request) {
70
- const buffer = request.$cancellationData;
71
- if (buffer === undefined) {
72
- return new cancellation_1.CancellationTokenSource();
73
- }
74
- return new SharedArrayBufferCancellationTokenSource(buffer);
75
- }
76
- }
77
- sharedArrayCancellation.SharedArrayReceiverStrategy = SharedArrayReceiverStrategy;
78
- return sharedArrayCancellation;
79
- }
80
- export { requireSharedArrayCancellation as __require };
@@ -1,25 +0,0 @@
1
- var wrappy_1 = wrappy;
2
- function wrappy (fn, cb) {
3
- if (fn && cb) return wrappy(fn)(cb)
4
- if (typeof fn !== 'function')
5
- throw new TypeError('need wrapper function')
6
- Object.keys(fn).forEach(function (k) {
7
- wrapper[k] = fn[k];
8
- });
9
- return wrapper
10
- function wrapper() {
11
- var args = new Array(arguments.length);
12
- for (var i = 0; i < args.length; i++) {
13
- args[i] = arguments[i];
14
- }
15
- var ret = fn.apply(this, args);
16
- var cb = args[args.length-1];
17
- if (typeof ret === 'function' && ret !== cb) {
18
- Object.keys(cb).forEach(function (k) {
19
- ret[k] = cb[k];
20
- });
21
- }
22
- return ret
23
- }
24
- }
25
- export { wrappy_1 as w };
@@ -1,131 +0,0 @@
1
- import { objectSpread2 as _objectSpread2, defineProperty as _defineProperty } from '../_virtual/_rollupPluginBabelHelpers.js';
2
- import '../node_modules/vscode-jsonrpc/lib/browser/main.js';
3
- import { BaseLanguageClient } from 'vscode-languageclient';
4
- import { InitializeRequest } from 'vscode-languageserver-protocol';
5
- import { __exports as main } from '../_virtual/main.js';
6
- class MiddlewareMessageWriter {
7
- constructor(delegate, middleware) {
8
- this.delegate = delegate;
9
- this.middleware = middleware;
10
- _defineProperty(this, "onError", cb => {
11
- return this.delegate.onError(cb);
12
- });
13
- _defineProperty(this, "onClose", cb => {
14
- return this.delegate.onClose(cb);
15
- });
16
- }
17
- dispose() {
18
- this.delegate.dispose();
19
- }
20
- write(msg) {
21
- return this.delegate.write(this.middleware(msg));
22
- }
23
- end() {
24
- return this.delegate.end();
25
- }
26
- }
27
- class MiddlewareMessageReader {
28
- constructor(delegate, middleware) {
29
- this.delegate = delegate;
30
- this.middleware = middleware;
31
- _defineProperty(this, "onError", cb => {
32
- return this.delegate.onError(cb);
33
- });
34
- _defineProperty(this, "onClose", cb => {
35
- return this.delegate.onClose(cb);
36
- });
37
- _defineProperty(this, "onPartialMessage", cb => {
38
- return this.delegate.onPartialMessage(cb);
39
- });
40
- }
41
- listen(callback) {
42
- return this.delegate.listen(message => {
43
- callback(this.middleware(message));
44
- });
45
- }
46
- dispose() {
47
- this.delegate.dispose();
48
- }
49
- }
50
- class MonacoLanguageClient extends BaseLanguageClient {
51
- constructor(id, name, clientOptions, connectionProvider) {
52
- super(id, name, clientOptions);
53
- this.connectionProvider = connectionProvider;
54
- }
55
- createMessageTransports(encoding) {
56
- return this.connectionProvider.get(encoding);
57
- }
58
- }
59
- function hackTransports(transports) {
60
- return {
61
- reader: new MiddlewareMessageReader(transports.reader, message => {
62
- return message;
63
- }),
64
- writer: new MiddlewareMessageWriter(transports.writer, message => {
65
- if (main.Message.isRequest(message) && message.method === InitializeRequest.type.method) {
66
- var _params$rootPath, _params$rootUri$repla, _params$rootUri;
67
- const params = message.params;
68
- const fixedParams = _objectSpread2(_objectSpread2({}, params), {}, {
69
- rootPath: (_params$rootPath = params.rootPath) === null || _params$rootPath === void 0 ? void 0 : _params$rootPath.replace(/\\/g, '/'),
70
- rootUri: (_params$rootUri$repla = (_params$rootUri = params.rootUri) === null || _params$rootUri === void 0 ? void 0 : _params$rootUri.replace(/\\/g, '/')) !== null && _params$rootUri$repla !== void 0 ? _params$rootUri$repla : null
71
- });
72
- return _objectSpread2(_objectSpread2({}, message), {}, {
73
- params: fixedParams
74
- });
75
- }
76
- return message;
77
- })
78
- };
79
- }
80
- class CGLSPConnectionProvider {
81
- constructor(id, infrastructure) {
82
- this.id = id;
83
- this.infrastructure = infrastructure;
84
- }
85
- async get() {
86
- return hackTransports(await this.infrastructure.openConnection(this.id));
87
- }
88
- }
89
- async function createLanguageClient(id, infrastructure, _ref, errorHandler, middleware) {
90
- let {
91
- documentSelector,
92
- synchronize,
93
- initializationOptions,
94
- createAdditionalFeatures
95
- } = _ref;
96
- const allInitializationOptions = () => {
97
- var _infrastructure$getIn;
98
- const infrastructureInitOptions = (_infrastructure$getIn = infrastructure.getInitializationOptions) === null || _infrastructure$getIn === void 0 ? void 0 : _infrastructure$getIn.call(infrastructure, documentSelector);
99
- const languageInitOptions = typeof initializationOptions === 'function' ? initializationOptions() : initializationOptions;
100
- if (infrastructureInitOptions != null || languageInitOptions != null) {
101
- return _objectSpread2(_objectSpread2({}, infrastructureInitOptions !== null && infrastructureInitOptions !== void 0 ? infrastructureInitOptions : {}), languageInitOptions !== null && languageInitOptions !== void 0 ? languageInitOptions : {});
102
- }
103
- return undefined;
104
- };
105
- class _MonacoLanguageClient extends MonacoLanguageClient {
106
- async stop(timeout) {
107
- const connection = this['_connection'];
108
- try {
109
- await super.stop(timeout);
110
- } finally {
111
- try {
112
- connection.dispose();
113
- } catch (err) {
114
- }
115
- }
116
- }
117
- }
118
- const client = new _MonacoLanguageClient("".concat(id, "-languageclient"), "CodinGame ".concat(id, " Language Client"), {
119
- documentSelector,
120
- errorHandler,
121
- middleware,
122
- synchronize,
123
- initializationOptions: allInitializationOptions
124
- }, new CGLSPConnectionProvider(id, infrastructure));
125
- client.registerProposedFeatures();
126
- if (createAdditionalFeatures != null) {
127
- client.registerFeatures(await createAdditionalFeatures(client));
128
- }
129
- return client;
130
- }
131
- export { MonacoLanguageClient, createLanguageClient as default };
@@ -1,24 +0,0 @@
1
- import { ProtocolRequestType } from 'vscode-languageserver-protocol';
2
- import * as vscode from 'vscode';
3
- import { ExtensionFeature } from './tools.js';
4
- const ResolveCobolSubroutineRequestType = new ProtocolRequestType('cobol/resolveSubroutine');
5
- class CobolResolveSubroutineFeature extends ExtensionFeature {
6
- constructor(languageClient) {
7
- super();
8
- this.languageClient = languageClient;
9
- }
10
- activate(context, capabilities, documentSelector) {
11
- context.subscriptions.push(this.languageClient.onRequest(ResolveCobolSubroutineRequestType, routineName => {
12
- var _vscode$workspace$wor, _vscode$workspace$wor2, _vscode$workspace$wor3, _vscode$workspace$tex;
13
- const constantRoutinePaths = {
14
- 'assert-equals': "file:".concat((_vscode$workspace$wor = (_vscode$workspace$wor2 = vscode.workspace.workspaceFolders) === null || _vscode$workspace$wor2 === void 0 ? void 0 : (_vscode$workspace$wor3 = _vscode$workspace$wor2[0]) === null || _vscode$workspace$wor3 === void 0 ? void 0 : _vscode$workspace$wor3.uri.fsPath) !== null && _vscode$workspace$wor !== void 0 ? _vscode$workspace$wor : '/tmp/project', "/deps/assert-equals.cbl")
15
- };
16
- const contantRoutinePath = constantRoutinePaths[routineName.toLowerCase()];
17
- if (contantRoutinePath != null) {
18
- return contantRoutinePath;
19
- }
20
- return (_vscode$workspace$tex = vscode.workspace.textDocuments.filter(textDocument => vscode.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();
21
- }));
22
- }
23
- }
24
- export { CobolResolveSubroutineFeature, ResolveCobolSubroutineRequestType };
@@ -1,29 +0,0 @@
1
- import { workspace } from 'vscode';
2
- import { ProtocolRequestType } from 'vscode-languageserver-protocol';
3
- import { ExtensionFeature } from './tools.js';
4
- const OmnisharpMetadataRequestType = new ProtocolRequestType('o#/metadata');
5
- class CsharpExtensionFeature extends ExtensionFeature {
6
- constructor(languageClient) {
7
- super();
8
- this.languageClient = languageClient;
9
- }
10
- activate(context) {
11
- context.subscriptions.push(workspace.registerTextDocumentContentProvider('omnisharp-metadata', {
12
- provideTextDocumentContent: async (uri, token) => {
13
- const [, project, assembly, typeName] = /^\/Project\/(.*)\/Assembly\/(.*)\/Symbol\/(.*).cs$/.exec(uri.fsPath);
14
- const {
15
- Source
16
- } = await this.languageClient.sendRequest(OmnisharpMetadataRequestType, {
17
- Timeout: 5000,
18
- AssemblyName: assembly.replace(/\//g, '.'),
19
- Language: null,
20
- ProjectName: project,
21
- TypeName: typeName.replace(/\//g, '.'),
22
- VersionNumber: null
23
- }, token);
24
- return Source;
25
- }
26
- }));
27
- }
28
- }
29
- export { CsharpExtensionFeature };
@@ -1,36 +0,0 @@
1
- import { commands, Uri, languages, workspace } from 'vscode';
2
- import { JavaInlayHintsProvider } from '../../extensions/java/inlayHintsProvider.js';
3
- import { registerCommands } from '../../extensions/java/sourceAction.js';
4
- import { Commands } from '../../extensions/java/commands.js';
5
- import { applyWorkspaceEdit } from '../../extensions/java/extension.js';
6
- import { ClassFileContentsRequest } from '../../extensions/java/protocol.js';
7
- import { ExtensionFeature } from './tools.js';
8
- class JavaExtensionFeature extends ExtensionFeature {
9
- constructor(languageClient) {
10
- super();
11
- this.languageClient = languageClient;
12
- }
13
- activate(context) {
14
- context.subscriptions.push(commands.registerCommand(Commands.SHOW_JAVA_REFERENCES, (uri, position, locations) => {
15
- void commands.executeCommand(Commands.SHOW_REFERENCES, Uri.parse(uri), this.languageClient.protocol2CodeConverter.asPosition(position), locations.map(this.languageClient.protocol2CodeConverter.asLocation));
16
- }));
17
- context.subscriptions.push(commands.registerCommand(Commands.SHOW_JAVA_IMPLEMENTATIONS, (uri, position, locations) => {
18
- void commands.executeCommand(Commands.SHOW_REFERENCES, Uri.parse(uri), this.languageClient.protocol2CodeConverter.asPosition(position), locations.map(this.languageClient.protocol2CodeConverter.asLocation));
19
- }));
20
- context.subscriptions.push(commands.registerCommand(Commands.APPLY_WORKSPACE_EDIT, obj => {
21
- void applyWorkspaceEdit(obj, this.languageClient);
22
- }));
23
- context.subscriptions.push(languages.registerInlayHintsProvider(this.languageClient.clientOptions.documentSelector, new JavaInlayHintsProvider(this.languageClient)));
24
- registerCommands(this.languageClient, context);
25
- context.subscriptions.push(workspace.registerTextDocumentContentProvider('jdt', {
26
- provideTextDocumentContent: async (uri, token) => {
27
- return this.languageClient.sendRequest(ClassFileContentsRequest.type, {
28
- uri: uri.toString()
29
- }, token).then(v => {
30
- return v !== null && v !== void 0 ? v : '';
31
- });
32
- }
33
- }));
34
- }
35
- }
36
- export { JavaExtensionFeature };
@@ -1,91 +0,0 @@
1
- import { defineProperty as _defineProperty } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
- function unsupported() {
3
- throw new Error('unsupported');
4
- }
5
- class MultiDisposeError extends Error {
6
- constructor(errors) {
7
- super("Encountered errors while disposing of store. Errors: [".concat(errors.join(', '), "]"));
8
- this.errors = errors;
9
- }
10
- }
11
- class SimpleExtensionContext {
12
- constructor() {
13
- _defineProperty(this, "subscriptions", []);
14
- _defineProperty(this, "asAbsolutePath", unsupported);
15
- _defineProperty(this, "storageUri", undefined);
16
- _defineProperty(this, "storagePath", undefined);
17
- _defineProperty(this, "messagePassingProtocol", undefined);
18
- }
19
- dispose() {
20
- const errors = [];
21
- for (const d of this.subscriptions) {
22
- try {
23
- d.dispose();
24
- } catch (e) {
25
- errors.push(e);
26
- }
27
- }
28
- if (errors.length === 1) {
29
- throw errors[0];
30
- } else if (errors.length > 1) {
31
- throw new MultiDisposeError(errors);
32
- }
33
- }
34
- get workspaceState() {
35
- return unsupported();
36
- }
37
- get globalState() {
38
- return unsupported();
39
- }
40
- get secrets() {
41
- return unsupported();
42
- }
43
- get extensionUri() {
44
- return unsupported();
45
- }
46
- get extensionPath() {
47
- return unsupported();
48
- }
49
- get environmentVariableCollection() {
50
- return unsupported();
51
- }
52
- get globalStorageUri() {
53
- return unsupported();
54
- }
55
- get globalStoragePath() {
56
- return unsupported();
57
- }
58
- get logUri() {
59
- return unsupported();
60
- }
61
- get logPath() {
62
- return unsupported();
63
- }
64
- get extensionMode() {
65
- return unsupported();
66
- }
67
- get extension() {
68
- return unsupported();
69
- }
70
- get extensionRuntime() {
71
- return unsupported();
72
- }
73
- }
74
- class ExtensionFeature {
75
- constructor() {
76
- _defineProperty(this, "context", new SimpleExtensionContext());
77
- }
78
- fillClientCapabilities() {}
79
- initialize(capabilities, documentSelector) {
80
- this.activate(this.context, capabilities, documentSelector);
81
- }
82
- getState() {
83
- return {
84
- kind: 'static'
85
- };
86
- }
87
- clear() {
88
- this.context.dispose();
89
- }
90
- }
91
- export { ExtensionFeature, unsupported };
@@ -1,172 +0,0 @@
1
- import { defineProperty as _defineProperty } from '../_virtual/_rollupPluginBabelHelpers.js';
2
- import { monaco } from '@codingame/monaco-editor-wrapper';
3
- import { registerFileSystemOverlay, FileSystemProviderCapabilities, FileSystemProviderError, FileSystemProviderErrorCode, FileType } from '@codingame/monaco-vscode-files-service-override';
4
- import { DidSaveTextDocumentNotification } from 'vscode-languageserver-protocol';
5
- import * as vscode from 'vscode';
6
- import { DisposableStore } from 'vscode/monaco';
7
- import { willShutdownNotificationType } from './customRequests.js';
8
- class InitializeTextDocumentFeature {
9
- constructor(languageClient, infrastructure) {
10
- this.languageClient = languageClient;
11
- this.infrastructure = infrastructure;
12
- _defineProperty(this, "didOpenTextDocumentDisposable", void 0);
13
- }
14
- fillClientCapabilities() {}
15
- initialize(capabilities, documentSelector) {
16
- var _textDocumentSyncOpti;
17
- const textDocumentSyncOptions = capabilities.resolvedTextDocumentSync;
18
- if (documentSelector == null || ((_textDocumentSyncOpti = textDocumentSyncOptions === null || textDocumentSyncOptions === void 0 ? void 0 : textDocumentSyncOptions.openClose) !== null && _textDocumentSyncOpti !== void 0 ? _textDocumentSyncOpti : false)) {
19
- return;
20
- }
21
- const infrastructure = this.infrastructure;
22
- const languageClient = this.languageClient;
23
- async function saveFile(textDocument) {
24
- if (documentSelector != null && vscode.languages.match(documentSelector, textDocument) > 0 && textDocument.uri.scheme === 'file') {
25
- var _infrastructure$saveF;
26
- await ((_infrastructure$saveF = infrastructure.saveFileContent) === null || _infrastructure$saveF === void 0 ? void 0 : _infrastructure$saveF.call(infrastructure, textDocument.uri, textDocument.getText(), languageClient));
27
- await languageClient.sendNotification(DidSaveTextDocumentNotification.type, {
28
- textDocument: {
29
- uri: textDocument.uri.toString()
30
- },
31
- text: textDocument.getText()
32
- });
33
- }
34
- }
35
- this.didOpenTextDocumentDisposable = vscode.workspace.onDidOpenTextDocument(saveFile);
36
- vscode.workspace.textDocuments.forEach(saveFile);
37
- }
38
- getState() {
39
- return {
40
- kind: 'static'
41
- };
42
- }
43
- clear() {
44
- var _this$didOpenTextDocu;
45
- (_this$didOpenTextDocu = this.didOpenTextDocumentDisposable) === null || _this$didOpenTextDocu === void 0 ? void 0 : _this$didOpenTextDocu.dispose();
46
- }
47
- }
48
- class WillDisposeFeature {
49
- constructor(languageClient, onWillShutdownEmitter) {
50
- this.languageClient = languageClient;
51
- this.onWillShutdownEmitter = onWillShutdownEmitter;
52
- }
53
- fillClientCapabilities() {}
54
- initialize() {
55
- this.languageClient.onNotification(willShutdownNotificationType, params => {
56
- this.onWillShutdownEmitter.fire(params);
57
- });
58
- }
59
- getState() {
60
- return {
61
- kind: 'static'
62
- };
63
- }
64
- clear() {}
65
- }
66
- const encoder = new TextEncoder();
67
- const decoder = new TextDecoder();
68
- class InfrastructureTextFileSystemProvider {
69
- constructor(infrastructure, languageClientManager) {
70
- this.infrastructure = infrastructure;
71
- this.languageClientManager = languageClientManager;
72
- _defineProperty(this, "capabilities", FileSystemProviderCapabilities.FileReadWrite | FileSystemProviderCapabilities.PathCaseSensitive | FileSystemProviderCapabilities.Readonly);
73
- _defineProperty(this, "cachedContent", new Map());
74
- _defineProperty(this, "onDidChangeCapabilities", new vscode.EventEmitter().event);
75
- _defineProperty(this, "onDidChangeFile", new vscode.EventEmitter().event);
76
- }
77
- async getFileContent(resource) {
78
- const REMOTE_FILE_BLACKLIST = ['.git/config', '.vscode', monaco.Uri.parse(this.infrastructure.rootUri).path];
79
- const blacklisted = REMOTE_FILE_BLACKLIST.some(blacklisted => resource.path.endsWith(blacklisted));
80
- if (blacklisted) {
81
- return undefined;
82
- }
83
- if (!this.cachedContent.has(resource.toString())) {
84
- this.cachedContent.set(resource.toString(), this.infrastructure.getFileContent(resource, this.languageClientManager));
85
- }
86
- return await this.cachedContent.get(resource.toString());
87
- }
88
- async readFile(resource) {
89
- const content = await this.getFileContent(resource);
90
- return encoder.encode(content);
91
- }
92
- async writeFile() {
93
- throw FileSystemProviderError.create('not allowed', FileSystemProviderErrorCode.NoPermissions);
94
- }
95
- watch() {
96
- return {
97
- dispose() {}
98
- };
99
- }
100
- async stat(resource) {
101
- try {
102
- const content = await this.getFileContent(resource);
103
- if (content != null) {
104
- return {
105
- type: FileType.File,
106
- size: encoder.encode(content).length,
107
- mtime: Date.now(),
108
- ctime: Date.now()
109
- };
110
- }
111
- } catch (err) {
112
- throw FileSystemProviderError.create(err, FileSystemProviderErrorCode.Unknown);
113
- }
114
- throw FileSystemProviderError.create('file not found', FileSystemProviderErrorCode.FileNotFound);
115
- }
116
- async mkdir() {}
117
- async readdir() {
118
- return [];
119
- }
120
- delete() {
121
- throw new Error('Method not implemented.');
122
- }
123
- rename() {
124
- throw new Error('Method not implemented.');
125
- }
126
- }
127
- class FileSystemFeature {
128
- constructor(infrastructure, languageClientManager) {
129
- this.infrastructure = infrastructure;
130
- this.languageClientManager = languageClientManager;
131
- _defineProperty(this, "disposable", void 0);
132
- }
133
- registerFileHandlers() {
134
- const disposables = new DisposableStore();
135
- if (this.infrastructure.getFileContent != null) {
136
- disposables.add(registerFileSystemOverlay(-1, new InfrastructureTextFileSystemProvider(this.infrastructure, this.languageClientManager)));
137
- }
138
- if (this.infrastructure.saveFileContent != null) {
139
- const watcher = vscode.workspace.createFileSystemWatcher(new vscode.RelativePattern(vscode.Uri.parse(this.infrastructure.rootUri), '**/*'));
140
- disposables.add(watcher);
141
- const onFileChange = async uri => {
142
- if ((await vscode.workspace.fs.stat(uri)).type === vscode.FileType.File) {
143
- var _this$infrastructure$, _this$infrastructure;
144
- const content = await vscode.workspace.fs.readFile(uri);
145
- await ((_this$infrastructure$ = (_this$infrastructure = this.infrastructure).saveFileContent) === null || _this$infrastructure$ === void 0 ? void 0 : _this$infrastructure$.call(_this$infrastructure, uri, decoder.decode(content), this.languageClientManager));
146
- }
147
- };
148
- watcher.onDidChange(onFileChange);
149
- watcher.onDidCreate(onFileChange);
150
- }
151
- return disposables;
152
- }
153
- fillClientCapabilities() {}
154
- initialize() {
155
- this.dispose();
156
- this.disposable = this.registerFileHandlers();
157
- }
158
- getState() {
159
- return {
160
- kind: 'static'
161
- };
162
- }
163
- dispose() {
164
- var _this$disposable;
165
- (_this$disposable = this.disposable) === null || _this$disposable === void 0 ? void 0 : _this$disposable.dispose();
166
- this.disposable = undefined;
167
- }
168
- clear() {
169
- this.dispose();
170
- }
171
- }
172
- export { FileSystemFeature, InitializeTextDocumentFeature, WillDisposeFeature };
@@ -1,87 +0,0 @@
1
- import { defineProperty as _defineProperty } from '../_virtual/_rollupPluginBabelHelpers.js';
2
- import { toSocket, WebSocketMessageWriter, WebSocketMessageReader } from 'vscode-ws-jsonrpc';
3
- import * as monaco from 'monaco-editor';
4
- import * as vscode from 'vscode';
5
- import { updateFile, getFile } from './customRequests.js';
6
- class CloseOnDisposeWebSocketMessageReader extends WebSocketMessageReader {
7
- dispose() {
8
- super.dispose();
9
- this.socket.dispose();
10
- }
11
- }
12
- async function openWebsocketConnection(url) {
13
- const webSocket = new WebSocket(url);
14
- const socket = toSocket(webSocket);
15
- const reader = new CloseOnDisposeWebSocketMessageReader(socket);
16
- const writer = new WebSocketMessageWriter(socket);
17
- await new Promise((resolve, reject) => {
18
- webSocket.addEventListener('open', resolve);
19
- webSocket.addEventListener('error', reject);
20
- });
21
- return {
22
- reader,
23
- writer
24
- };
25
- }
26
- class CodinGameInfrastructure {
27
- constructor(
28
- serverAddress, _useMutualizedProxy,
29
- sessionId,
30
- libraryUrls) {
31
- this.serverAddress = serverAddress;
32
- this._useMutualizedProxy = _useMutualizedProxy;
33
- this.sessionId = sessionId;
34
- this.libraryUrls = libraryUrls;
35
- _defineProperty(this, "automaticTextDocumentUpdate", false);
36
- _defineProperty(this, "rootUri", 'file:///tmp/project');
37
- _defineProperty(this, "workspaceFolders", [{
38
- uri: monaco.Uri.file('/tmp/project'),
39
- index: 0,
40
- name: 'main'
41
- }]);
42
- }
43
- useMutualizedProxy(languageClientId, options) {
44
- return this._useMutualizedProxy && options.mutualizable;
45
- }
46
- async saveFileContent(document, content, languageClient) {
47
- if (languageClient.isConnected()) {
48
- await updateFile(document.toString(), content, languageClient);
49
- }
50
- }
51
- async getFileContent(resource, languageClient) {
52
- try {
53
- return (await getFile(resource.toString(true), languageClient)).text;
54
- } catch (error) {
55
- return undefined;
56
- }
57
- }
58
- async openConnection(id) {
59
- try {
60
- var _this$libraryUrls;
61
- const url = new URL(this.sessionId != null ? "run/".concat(this.sessionId, "/").concat(id) : "run/".concat(id), this.serverAddress);
62
- (_this$libraryUrls = this.libraryUrls) === null || _this$libraryUrls === void 0 ? void 0 : _this$libraryUrls.forEach(libraryUrl => url.searchParams.append('libraryUrl', libraryUrl));
63
- url.searchParams.append('token', await this.getSecurityToken());
64
- const connection = await openWebsocketConnection(url);
65
- return connection;
66
- } catch (error) {
67
- if (error instanceof Error) {
68
- throw error;
69
- }
70
- throw new Error('Unable to connect to server');
71
- }
72
- }
73
- getInitializationOptions(documentSelector) {
74
- let documents = vscode.workspace.textDocuments.filter(doc => doc.uri.scheme === 'file');
75
- if (documentSelector != null) {
76
- documents = documents.filter(doc => vscode.languages.match(documentSelector, doc));
77
- }
78
- const files = documents.reduce((map, doc) => {
79
- map[doc.uri.toString(true)] = doc.getText();
80
- return map;
81
- }, {});
82
- return {
83
- files
84
- };
85
- }
86
- }
87
- export { CodinGameInfrastructure };