@depup/vscode-languageserver 10.1.1-depup.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/License.txt +11 -0
- package/README.md +25 -0
- package/bin/installServerIntoExtension +73 -0
- package/changes.json +5 -0
- package/eslint.config.js +10 -0
- package/lib/browser/main.d.ts +20 -0
- package/lib/browser/main.js +61 -0
- package/lib/common/api.d.ts +15 -0
- package/lib/common/api.js +35 -0
- package/lib/common/callHierarchy.d.ts +15 -0
- package/lib/common/callHierarchy.js +34 -0
- package/lib/common/configuration.d.ts +9 -0
- package/lib/common/configuration.js +71 -0
- package/lib/common/diagnostic.d.ts +29 -0
- package/lib/common/diagnostic.js +30 -0
- package/lib/common/fileOperations.d.ts +16 -0
- package/lib/common/fileOperations.js +43 -0
- package/lib/common/foldingRange.d.ts +22 -0
- package/lib/common/foldingRange.js +26 -0
- package/lib/common/inlayHint.d.ts +28 -0
- package/lib/common/inlayHint.js +30 -0
- package/lib/common/inlineCompletion.d.ts +18 -0
- package/lib/common/inlineCompletion.js +22 -0
- package/lib/common/inlineValue.d.ts +22 -0
- package/lib/common/inlineValue.js +25 -0
- package/lib/common/linkedEditingRange.d.ts +16 -0
- package/lib/common/linkedEditingRange.js +18 -0
- package/lib/common/moniker.d.ts +13 -0
- package/lib/common/moniker.js +23 -0
- package/lib/common/notebook.d.ts +99 -0
- package/lib/common/notebook.js +262 -0
- package/lib/common/progress.d.ts +25 -0
- package/lib/common/progress.js +172 -0
- package/lib/common/semanticTokens.d.ts +43 -0
- package/lib/common/semanticTokens.js +251 -0
- package/lib/common/server.d.ts +812 -0
- package/lib/common/server.js +798 -0
- package/lib/common/showDocument.d.ts +6 -0
- package/lib/common/showDocument.js +16 -0
- package/lib/common/textDocumentContent.d.ts +14 -0
- package/lib/common/textDocumentContent.js +25 -0
- package/lib/common/textDocuments.d.ts +133 -0
- package/lib/common/textDocuments.js +180 -0
- package/lib/common/typeHierarchy.d.ts +15 -0
- package/lib/common/typeHierarchy.js +34 -0
- package/lib/common/utils/is.d.ts +9 -0
- package/lib/common/utils/is.js +42 -0
- package/lib/common/utils/uuid.d.ts +22 -0
- package/lib/common/utils/uuid.js +98 -0
- package/lib/common/workspaceFolder.d.ts +7 -0
- package/lib/common/workspaceFolder.js +47 -0
- package/lib/node/files.d.ts +19 -0
- package/lib/node/files.js +295 -0
- package/lib/node/main.d.ts +60 -0
- package/lib/node/main.js +295 -0
- package/lib/node/resolve.d.ts +1 -0
- package/lib/node/resolve.js +20 -0
- package/package.json +65 -0
- package/thirdpartynotices.txt +84 -0
- package/typings/thenable.d.ts +5 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated Use the `vscode-uri` npm module which provides a more
|
|
3
|
+
* complete implementation of handling VS Code URIs.
|
|
4
|
+
*/
|
|
5
|
+
export declare function uriToFilePath(uri: string): string | undefined;
|
|
6
|
+
export declare function resolve(moduleName: string, nodePath: string | undefined, cwd: string | undefined, tracer: (message: string, verbose?: string) => void): Promise<string>;
|
|
7
|
+
/**
|
|
8
|
+
* Resolve the global npm package path.
|
|
9
|
+
* @deprecated Since this depends on the used package manager and their version the best is that servers
|
|
10
|
+
* implement this themselves since they know best what kind of package managers to support.
|
|
11
|
+
* @param tracer the tracer to use
|
|
12
|
+
*/
|
|
13
|
+
export declare function resolveGlobalNodePath(tracer?: (message: string) => void): string | undefined;
|
|
14
|
+
export declare function resolveGlobalYarnPath(tracer?: (message: string) => void): string | undefined;
|
|
15
|
+
export declare namespace FileSystem {
|
|
16
|
+
function isCaseSensitive(): boolean;
|
|
17
|
+
function isParent(parent: string, child: string): boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare function resolveModulePath(workspaceRoot: string, moduleName: string, nodePath: string, tracer: (message: string, verbose?: string) => void): Promise<string>;
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* --------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
+
* ------------------------------------------------------------------------------------------ */
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
+
var ownKeys = function(o) {
|
|
24
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
+
var ar = [];
|
|
26
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
return ownKeys(o);
|
|
30
|
+
};
|
|
31
|
+
return function (mod) {
|
|
32
|
+
if (mod && mod.__esModule) return mod;
|
|
33
|
+
var result = {};
|
|
34
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
+
__setModuleDefault(result, mod);
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.FileSystem = void 0;
|
|
41
|
+
exports.uriToFilePath = uriToFilePath;
|
|
42
|
+
exports.resolve = resolve;
|
|
43
|
+
exports.resolveGlobalNodePath = resolveGlobalNodePath;
|
|
44
|
+
exports.resolveGlobalYarnPath = resolveGlobalYarnPath;
|
|
45
|
+
exports.resolveModulePath = resolveModulePath;
|
|
46
|
+
const url = __importStar(require("url"));
|
|
47
|
+
const path = __importStar(require("path"));
|
|
48
|
+
const fs = __importStar(require("fs"));
|
|
49
|
+
const child_process_1 = require("child_process");
|
|
50
|
+
/**
|
|
51
|
+
* @deprecated Use the `vscode-uri` npm module which provides a more
|
|
52
|
+
* complete implementation of handling VS Code URIs.
|
|
53
|
+
*/
|
|
54
|
+
function uriToFilePath(uri) {
|
|
55
|
+
const parsed = url.parse(uri);
|
|
56
|
+
if (parsed.protocol !== 'file:' || !parsed.path) {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
const segments = parsed.path.split('/');
|
|
60
|
+
for (let i = 0, len = segments.length; i < len; i++) {
|
|
61
|
+
segments[i] = decodeURIComponent(segments[i]);
|
|
62
|
+
}
|
|
63
|
+
if (process.platform === 'win32' && segments.length > 1) {
|
|
64
|
+
const first = segments[0];
|
|
65
|
+
const second = segments[1];
|
|
66
|
+
// Do we have a drive letter and we started with a / which is the
|
|
67
|
+
// case if the first segement is empty (see split above)
|
|
68
|
+
if (first.length === 0 && second.length > 1 && second[1] === ':') {
|
|
69
|
+
// Remove first slash
|
|
70
|
+
segments.shift();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return path.normalize(segments.join('/'));
|
|
74
|
+
}
|
|
75
|
+
function isWindows() {
|
|
76
|
+
return process.platform === 'win32';
|
|
77
|
+
}
|
|
78
|
+
function resolve(moduleName, nodePath, cwd, tracer) {
|
|
79
|
+
const nodePathKey = 'NODE_PATH';
|
|
80
|
+
const app = [
|
|
81
|
+
'var p = process;',
|
|
82
|
+
'p.on(\'message\',function(m){',
|
|
83
|
+
'if(m.c===\'e\'){',
|
|
84
|
+
'p.exit(0);',
|
|
85
|
+
'}',
|
|
86
|
+
'else if(m.c===\'rs\'){',
|
|
87
|
+
'try{',
|
|
88
|
+
'var r=require.resolve(m.a);',
|
|
89
|
+
'p.send({c:\'r\',s:true,r:r});',
|
|
90
|
+
'}',
|
|
91
|
+
'catch(err){',
|
|
92
|
+
'p.send({c:\'r\',s:false});',
|
|
93
|
+
'}',
|
|
94
|
+
'}',
|
|
95
|
+
'});'
|
|
96
|
+
].join('');
|
|
97
|
+
return new Promise((resolve, reject) => {
|
|
98
|
+
const env = process.env;
|
|
99
|
+
const newEnv = Object.create(null);
|
|
100
|
+
Object.keys(env).forEach(key => newEnv[key] = env[key]);
|
|
101
|
+
if (nodePath && fs.existsSync(nodePath) /* see issue 545 */) {
|
|
102
|
+
if (newEnv[nodePathKey]) {
|
|
103
|
+
newEnv[nodePathKey] = nodePath + path.delimiter + newEnv[nodePathKey];
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
newEnv[nodePathKey] = nodePath;
|
|
107
|
+
}
|
|
108
|
+
if (tracer) {
|
|
109
|
+
tracer(`NODE_PATH value is: ${newEnv[nodePathKey]}`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
newEnv['ELECTRON_RUN_AS_NODE'] = '1';
|
|
113
|
+
try {
|
|
114
|
+
const cp = (0, child_process_1.fork)('', [], {
|
|
115
|
+
cwd: cwd,
|
|
116
|
+
env: newEnv,
|
|
117
|
+
execArgv: ['-e', app]
|
|
118
|
+
});
|
|
119
|
+
if (cp.pid === void 0) {
|
|
120
|
+
reject(new Error(`Starting process to resolve node module ${moduleName} failed`));
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
cp.on('error', (error) => {
|
|
124
|
+
reject(error);
|
|
125
|
+
});
|
|
126
|
+
cp.on('message', (message) => {
|
|
127
|
+
if (message.c === 'r') {
|
|
128
|
+
cp.send({ c: 'e' });
|
|
129
|
+
if (message.s) {
|
|
130
|
+
resolve(message.r);
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
reject(new Error(`Failed to resolve module: ${moduleName}`));
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
const message = {
|
|
138
|
+
c: 'rs',
|
|
139
|
+
a: moduleName
|
|
140
|
+
};
|
|
141
|
+
cp.send(message);
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
reject(error);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Resolve the global npm package path.
|
|
150
|
+
* @deprecated Since this depends on the used package manager and their version the best is that servers
|
|
151
|
+
* implement this themselves since they know best what kind of package managers to support.
|
|
152
|
+
* @param tracer the tracer to use
|
|
153
|
+
*/
|
|
154
|
+
function resolveGlobalNodePath(tracer) {
|
|
155
|
+
let npmCommand = 'npm';
|
|
156
|
+
const env = Object.create(null);
|
|
157
|
+
Object.keys(process.env).forEach(key => env[key] = process.env[key]);
|
|
158
|
+
env['NO_UPDATE_NOTIFIER'] = 'true';
|
|
159
|
+
const options = {
|
|
160
|
+
encoding: 'utf8',
|
|
161
|
+
env
|
|
162
|
+
};
|
|
163
|
+
if (isWindows()) {
|
|
164
|
+
npmCommand = 'npm.cmd';
|
|
165
|
+
options.shell = true;
|
|
166
|
+
}
|
|
167
|
+
const handler = () => { };
|
|
168
|
+
try {
|
|
169
|
+
process.on('SIGPIPE', handler);
|
|
170
|
+
const stdout = (0, child_process_1.spawnSync)(npmCommand, ['config', 'get', 'prefix'], options).stdout;
|
|
171
|
+
if (!stdout) {
|
|
172
|
+
if (tracer) {
|
|
173
|
+
tracer(`'npm config get prefix' didn't return a value.`);
|
|
174
|
+
}
|
|
175
|
+
return undefined;
|
|
176
|
+
}
|
|
177
|
+
const prefix = stdout.trim();
|
|
178
|
+
if (tracer) {
|
|
179
|
+
tracer(`'npm config get prefix' value is: ${prefix}`);
|
|
180
|
+
}
|
|
181
|
+
if (prefix.length > 0) {
|
|
182
|
+
if (isWindows()) {
|
|
183
|
+
return path.join(prefix, 'node_modules');
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
return path.join(prefix, 'lib', 'node_modules');
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return undefined;
|
|
190
|
+
}
|
|
191
|
+
catch (err) {
|
|
192
|
+
return undefined;
|
|
193
|
+
}
|
|
194
|
+
finally {
|
|
195
|
+
process.removeListener('SIGPIPE', handler);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
/*
|
|
199
|
+
* Resolve the global yarn pakage path.
|
|
200
|
+
* @deprecated Since this depends on the used package manager and their version the best is that servers
|
|
201
|
+
* implement this themselves since they know best what kind of package managers to support.
|
|
202
|
+
* @param tracer the tracer to use
|
|
203
|
+
*/
|
|
204
|
+
function resolveGlobalYarnPath(tracer) {
|
|
205
|
+
let yarnCommand = 'yarn';
|
|
206
|
+
const options = {
|
|
207
|
+
encoding: 'utf8'
|
|
208
|
+
};
|
|
209
|
+
if (isWindows()) {
|
|
210
|
+
yarnCommand = 'yarn.cmd';
|
|
211
|
+
options.shell = true;
|
|
212
|
+
}
|
|
213
|
+
const handler = () => { };
|
|
214
|
+
try {
|
|
215
|
+
process.on('SIGPIPE', handler);
|
|
216
|
+
const results = (0, child_process_1.spawnSync)(yarnCommand, ['global', 'dir', '--json'], options);
|
|
217
|
+
const stdout = results.stdout;
|
|
218
|
+
if (!stdout) {
|
|
219
|
+
if (tracer) {
|
|
220
|
+
tracer(`'yarn global dir' didn't return a value.`);
|
|
221
|
+
if (results.stderr) {
|
|
222
|
+
tracer(results.stderr);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return undefined;
|
|
226
|
+
}
|
|
227
|
+
const lines = stdout.trim().split(/\r?\n/);
|
|
228
|
+
for (const line of lines) {
|
|
229
|
+
try {
|
|
230
|
+
const yarn = JSON.parse(line);
|
|
231
|
+
if (yarn.type === 'log') {
|
|
232
|
+
return path.join(yarn.data, 'node_modules');
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
catch (e) {
|
|
236
|
+
// Do nothing. Ignore the line
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return undefined;
|
|
240
|
+
}
|
|
241
|
+
catch (err) {
|
|
242
|
+
return undefined;
|
|
243
|
+
}
|
|
244
|
+
finally {
|
|
245
|
+
process.removeListener('SIGPIPE', handler);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
var FileSystem;
|
|
249
|
+
(function (FileSystem) {
|
|
250
|
+
let _isCaseSensitive = undefined;
|
|
251
|
+
function isCaseSensitive() {
|
|
252
|
+
if (_isCaseSensitive !== void 0) {
|
|
253
|
+
return _isCaseSensitive;
|
|
254
|
+
}
|
|
255
|
+
if (process.platform === 'win32') {
|
|
256
|
+
_isCaseSensitive = false;
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
// convert current file name to upper case / lower case and check if file exists
|
|
260
|
+
// (guards against cases when name is already all uppercase or lowercase)
|
|
261
|
+
_isCaseSensitive = !fs.existsSync(__filename.toUpperCase()) || !fs.existsSync(__filename.toLowerCase());
|
|
262
|
+
}
|
|
263
|
+
return _isCaseSensitive;
|
|
264
|
+
}
|
|
265
|
+
FileSystem.isCaseSensitive = isCaseSensitive;
|
|
266
|
+
function isParent(parent, child) {
|
|
267
|
+
if (isCaseSensitive()) {
|
|
268
|
+
return path.normalize(child).indexOf(path.normalize(parent)) === 0;
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
return path.normalize(child).toLowerCase().indexOf(path.normalize(parent).toLowerCase()) === 0;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
FileSystem.isParent = isParent;
|
|
275
|
+
})(FileSystem || (exports.FileSystem = FileSystem = {}));
|
|
276
|
+
function resolveModulePath(workspaceRoot, moduleName, nodePath, tracer) {
|
|
277
|
+
if (nodePath) {
|
|
278
|
+
if (!path.isAbsolute(nodePath)) {
|
|
279
|
+
nodePath = path.join(workspaceRoot, nodePath);
|
|
280
|
+
}
|
|
281
|
+
return resolve(moduleName, nodePath, nodePath, tracer).then((value) => {
|
|
282
|
+
if (FileSystem.isParent(nodePath, value)) {
|
|
283
|
+
return value;
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
return Promise.reject(new Error(`Failed to load ${moduleName} from node path location.`));
|
|
287
|
+
}
|
|
288
|
+
}).then(undefined, (_error) => {
|
|
289
|
+
return resolve(moduleName, resolveGlobalNodePath(tracer), workspaceRoot, tracer);
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
return resolve(moduleName, resolveGlobalNodePath(tracer), workspaceRoot, tracer);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/// <reference path="../../typings/thenable.d.ts" preserve="true" />
|
|
2
|
+
import { Connection, _, _Connection, Features } from '../common/server';
|
|
3
|
+
import * as fm from './files';
|
|
4
|
+
import { ConnectionStrategy, ConnectionOptions, MessageReader, MessageWriter } from 'vscode-languageserver-protocol/node';
|
|
5
|
+
export * from 'vscode-languageserver-protocol/node';
|
|
6
|
+
export * from '../common/api';
|
|
7
|
+
export declare namespace Files {
|
|
8
|
+
const uriToFilePath: typeof fm.uriToFilePath;
|
|
9
|
+
const resolveGlobalNodePath: typeof fm.resolveGlobalNodePath;
|
|
10
|
+
const resolveGlobalYarnPath: typeof fm.resolveGlobalYarnPath;
|
|
11
|
+
const resolve: typeof fm.resolve;
|
|
12
|
+
const resolveModulePath: typeof fm.resolveModulePath;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new connection based on the processes command line arguments:
|
|
16
|
+
*
|
|
17
|
+
* @param options An optional connection strategy or connection options to control additional settings
|
|
18
|
+
*/
|
|
19
|
+
export declare function createConnection(options?: ConnectionStrategy | ConnectionOptions): Connection;
|
|
20
|
+
/**
|
|
21
|
+
* Creates a new connection using a the given streams.
|
|
22
|
+
*
|
|
23
|
+
* @param inputStream The stream to read messages from.
|
|
24
|
+
* @param outputStream The stream to write messages to.
|
|
25
|
+
* @param options An optional connection strategy or connection options to control additional settings
|
|
26
|
+
* @return A {@link Connection connection}
|
|
27
|
+
*/
|
|
28
|
+
export declare function createConnection(inputStream: NodeJS.ReadableStream, outputStream: NodeJS.WritableStream, options?: ConnectionStrategy | ConnectionOptions): Connection;
|
|
29
|
+
/**
|
|
30
|
+
* Creates a new connection.
|
|
31
|
+
*
|
|
32
|
+
* @param reader The message reader to read messages from.
|
|
33
|
+
* @param writer The message writer to write message to.
|
|
34
|
+
* @param options An optional connection strategy or connection options to control additional settings
|
|
35
|
+
*/
|
|
36
|
+
export declare function createConnection(reader: MessageReader, writer: MessageWriter, options?: ConnectionStrategy | ConnectionOptions): Connection;
|
|
37
|
+
/**
|
|
38
|
+
* Creates a new connection based on the processes command line arguments. The new connection surfaces proposed API
|
|
39
|
+
*
|
|
40
|
+
* @param factories: the factories to use to implement the proposed API
|
|
41
|
+
* @param options An optional connection strategy or connection options to control additional settings
|
|
42
|
+
*/
|
|
43
|
+
export declare function createConnection<PConsole = _, PTracer = _, PTelemetry = _, PClient = _, PWindow = _, PWorkspace = _, PLanguages = _, PNotebooks = _>(factories: Features<PConsole, PTracer, PTelemetry, PClient, PWindow, PWorkspace, PLanguages, PNotebooks>, options?: ConnectionStrategy | ConnectionOptions): _Connection<PConsole, PTracer, PTelemetry, PClient, PWindow, PWorkspace, PLanguages, PNotebooks>;
|
|
44
|
+
/**
|
|
45
|
+
* Creates a new connection using a the given streams.
|
|
46
|
+
*
|
|
47
|
+
* @param inputStream The stream to read messages from.
|
|
48
|
+
* @param outputStream The stream to write messages to.
|
|
49
|
+
* @param options An optional connection strategy or connection options to control additional settings
|
|
50
|
+
* @return A {@link Connection connection}
|
|
51
|
+
*/
|
|
52
|
+
export declare function createConnection<PConsole = _, PTracer = _, PTelemetry = _, PClient = _, PWindow = _, PWorkspace = _, PLanguages = _, PNotebooks = _>(factories: Features<PConsole, PTracer, PTelemetry, PClient, PWindow, PWorkspace, PLanguages, PNotebooks>, inputStream: NodeJS.ReadableStream, outputStream: NodeJS.WritableStream, options?: ConnectionStrategy | ConnectionOptions): _Connection<PConsole, PTracer, PTelemetry, PClient, PWindow, PWorkspace, PLanguages, PNotebooks>;
|
|
53
|
+
/**
|
|
54
|
+
* Creates a new connection.
|
|
55
|
+
*
|
|
56
|
+
* @param reader The message reader to read messages from.
|
|
57
|
+
* @param writer The message writer to write message to.
|
|
58
|
+
* @param options An optional connection strategy or connection options to control additional settings
|
|
59
|
+
*/
|
|
60
|
+
export declare function createConnection<PConsole = _, PTracer = _, PTelemetry = _, PClient = _, PWindow = _, PWorkspace = _, PLanguages = _, PNotebooks = _>(factories: Features<PConsole, PTracer, PTelemetry, PClient, PWindow, PWorkspace, PLanguages, PNotebooks>, reader: MessageReader, writer: MessageWriter, options?: ConnectionStrategy | ConnectionOptions): _Connection<PConsole, PTracer, PTelemetry, PClient, PWindow, PWorkspace, PLanguages, PNotebooks>;
|
package/lib/node/main.js
ADDED
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* --------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
+
* ------------------------------------------------------------------------------------------ */
|
|
6
|
+
/// <reference path="../../typings/thenable.d.ts" preserve="true"/>
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
+
}) : function(o, v) {
|
|
21
|
+
o["default"] = v;
|
|
22
|
+
});
|
|
23
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
+
var ownKeys = function(o) {
|
|
25
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
+
var ar = [];
|
|
27
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
+
return ar;
|
|
29
|
+
};
|
|
30
|
+
return ownKeys(o);
|
|
31
|
+
};
|
|
32
|
+
return function (mod) {
|
|
33
|
+
if (mod && mod.__esModule) return mod;
|
|
34
|
+
var result = {};
|
|
35
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
+
__setModuleDefault(result, mod);
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
})();
|
|
40
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
41
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
42
|
+
};
|
|
43
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
+
exports.Files = void 0;
|
|
45
|
+
exports.createConnection = createConnection;
|
|
46
|
+
const node_util_1 = require("node:util");
|
|
47
|
+
const Is = __importStar(require("../common/utils/is"));
|
|
48
|
+
const server_1 = require("../common/server");
|
|
49
|
+
const fm = __importStar(require("./files"));
|
|
50
|
+
const node_1 = require("vscode-languageserver-protocol/node");
|
|
51
|
+
__exportStar(require("vscode-languageserver-protocol/node"), exports);
|
|
52
|
+
__exportStar(require("../common/api"), exports);
|
|
53
|
+
var Files;
|
|
54
|
+
(function (Files) {
|
|
55
|
+
Files.uriToFilePath = fm.uriToFilePath;
|
|
56
|
+
Files.resolveGlobalNodePath = fm.resolveGlobalNodePath;
|
|
57
|
+
Files.resolveGlobalYarnPath = fm.resolveGlobalYarnPath;
|
|
58
|
+
Files.resolve = fm.resolve;
|
|
59
|
+
Files.resolveModulePath = fm.resolveModulePath;
|
|
60
|
+
})(Files || (exports.Files = Files = {}));
|
|
61
|
+
let _protocolConnection;
|
|
62
|
+
function endProtocolConnection() {
|
|
63
|
+
if (_protocolConnection === undefined) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
try {
|
|
67
|
+
_protocolConnection.end();
|
|
68
|
+
}
|
|
69
|
+
catch (_err) {
|
|
70
|
+
// Ignore. The client process could have already
|
|
71
|
+
// did and we can't send an end into the connection.
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
let _shutdownReceived = false;
|
|
75
|
+
let exitTimer = undefined;
|
|
76
|
+
function setupExitTimer() {
|
|
77
|
+
const argName = '--clientProcessId';
|
|
78
|
+
function runTimer(value) {
|
|
79
|
+
try {
|
|
80
|
+
const processId = parseInt(value);
|
|
81
|
+
if (!isNaN(processId)) {
|
|
82
|
+
exitTimer = setInterval(() => {
|
|
83
|
+
try {
|
|
84
|
+
process.kill(processId, 0);
|
|
85
|
+
}
|
|
86
|
+
catch (ex) {
|
|
87
|
+
// Parent process doesn't exist anymore. Exit the server.
|
|
88
|
+
endProtocolConnection();
|
|
89
|
+
process.exit(_shutdownReceived ? 0 : 1);
|
|
90
|
+
}
|
|
91
|
+
}, 3000);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
catch (e) {
|
|
95
|
+
// Ignore errors;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
for (let i = 2; i < process.argv.length; i++) {
|
|
99
|
+
const arg = process.argv[i];
|
|
100
|
+
if (arg === argName && i + 1 < process.argv.length) {
|
|
101
|
+
runTimer(process.argv[i + 1]);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
const args = arg.split('=');
|
|
106
|
+
if (args[0] === argName) {
|
|
107
|
+
runTimer(args[1]);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
setupExitTimer();
|
|
113
|
+
const watchDog = {
|
|
114
|
+
initialize: (params) => {
|
|
115
|
+
const processId = params.processId;
|
|
116
|
+
if (Is.number(processId) && exitTimer === undefined) {
|
|
117
|
+
// We received a parent process id. Set up a timer to periodically check
|
|
118
|
+
// if the parent is still alive.
|
|
119
|
+
setInterval(() => {
|
|
120
|
+
try {
|
|
121
|
+
process.kill(processId, 0);
|
|
122
|
+
}
|
|
123
|
+
catch (ex) {
|
|
124
|
+
// Parent process doesn't exist anymore. Exit the server.
|
|
125
|
+
process.exit(_shutdownReceived ? 0 : 1);
|
|
126
|
+
}
|
|
127
|
+
}, 3000);
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
get shutdownReceived() {
|
|
131
|
+
return _shutdownReceived;
|
|
132
|
+
},
|
|
133
|
+
set shutdownReceived(value) {
|
|
134
|
+
_shutdownReceived = value;
|
|
135
|
+
},
|
|
136
|
+
exit: (code) => {
|
|
137
|
+
endProtocolConnection();
|
|
138
|
+
process.exit(code);
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
function createConnection(arg1, arg2, arg3, arg4) {
|
|
142
|
+
let factories;
|
|
143
|
+
let input;
|
|
144
|
+
let output;
|
|
145
|
+
let options;
|
|
146
|
+
if (arg1 !== undefined && arg1.__brand === 'features') {
|
|
147
|
+
factories = arg1;
|
|
148
|
+
arg1 = arg2;
|
|
149
|
+
arg2 = arg3;
|
|
150
|
+
arg3 = arg4;
|
|
151
|
+
}
|
|
152
|
+
if (node_1.ConnectionStrategy.is(arg1) || node_1.ConnectionOptions.is(arg1)) {
|
|
153
|
+
options = arg1;
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
input = arg1;
|
|
157
|
+
output = arg2;
|
|
158
|
+
options = arg3;
|
|
159
|
+
}
|
|
160
|
+
return _createConnection(input, output, options, factories);
|
|
161
|
+
}
|
|
162
|
+
function _createConnection(input, output, options, factories) {
|
|
163
|
+
let stdio = false;
|
|
164
|
+
if (!input && !output && process.argv.length > 2) {
|
|
165
|
+
let port = undefined;
|
|
166
|
+
let pipeName = undefined;
|
|
167
|
+
const argv = process.argv.slice(2);
|
|
168
|
+
for (let i = 0; i < argv.length; i++) {
|
|
169
|
+
const arg = argv[i];
|
|
170
|
+
if (arg === '--node-ipc') {
|
|
171
|
+
input = new node_1.IPCMessageReader(process);
|
|
172
|
+
output = new node_1.IPCMessageWriter(process);
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
else if (arg === '--stdio') {
|
|
176
|
+
stdio = true;
|
|
177
|
+
input = process.stdin;
|
|
178
|
+
output = process.stdout;
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
else if (arg === '--socket') {
|
|
182
|
+
port = parseInt(argv[i + 1]);
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
else if (arg === '--pipe') {
|
|
186
|
+
pipeName = argv[i + 1];
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
const args = arg.split('=');
|
|
191
|
+
if (args[0] === '--socket') {
|
|
192
|
+
port = parseInt(args[1]);
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
else if (args[0] === '--pipe') {
|
|
196
|
+
pipeName = args[1];
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
if (port) {
|
|
202
|
+
const transport = (0, node_1.createServerSocketTransport)(port);
|
|
203
|
+
input = transport[0];
|
|
204
|
+
output = transport[1];
|
|
205
|
+
}
|
|
206
|
+
else if (pipeName) {
|
|
207
|
+
const transport = (0, node_1.createServerPipeTransport)(pipeName);
|
|
208
|
+
input = transport[0];
|
|
209
|
+
output = transport[1];
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
const commandLineMessage = 'Use arguments of createConnection or set command line parameters: \'--node-ipc\', \'--stdio\' or \'--socket={number}\'';
|
|
213
|
+
if (!input) {
|
|
214
|
+
throw new Error('Connection input stream is not set. ' + commandLineMessage);
|
|
215
|
+
}
|
|
216
|
+
if (!output) {
|
|
217
|
+
throw new Error('Connection output stream is not set. ' + commandLineMessage);
|
|
218
|
+
}
|
|
219
|
+
// Backwards compatibility
|
|
220
|
+
if (Is.func(input.read) && Is.func(input.on)) {
|
|
221
|
+
const inputStream = input;
|
|
222
|
+
inputStream.on('end', () => {
|
|
223
|
+
endProtocolConnection();
|
|
224
|
+
process.exit(_shutdownReceived ? 0 : 1);
|
|
225
|
+
});
|
|
226
|
+
inputStream.on('close', () => {
|
|
227
|
+
endProtocolConnection();
|
|
228
|
+
process.exit(_shutdownReceived ? 0 : 1);
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
const connectionFactory = (logger) => {
|
|
232
|
+
const result = (0, node_1.createProtocolConnection)(input, output, logger, options);
|
|
233
|
+
if (stdio) {
|
|
234
|
+
patchConsole(logger);
|
|
235
|
+
}
|
|
236
|
+
return result;
|
|
237
|
+
};
|
|
238
|
+
return (0, server_1.createConnection)(connectionFactory, watchDog, factories);
|
|
239
|
+
}
|
|
240
|
+
function patchConsole(logger) {
|
|
241
|
+
function serialize(args) {
|
|
242
|
+
return args.map(arg => typeof arg === 'string' ? arg : (0, node_util_1.inspect)(arg)).join(' ');
|
|
243
|
+
}
|
|
244
|
+
const counters = new Map();
|
|
245
|
+
console.assert = function assert(assertion, ...args) {
|
|
246
|
+
if (assertion) {
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
if (args.length === 0) {
|
|
250
|
+
logger.error('Assertion failed');
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
const [message, ...rest] = args;
|
|
254
|
+
logger.error(`Assertion failed: ${message} ${serialize(rest)}`);
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
console.count = function count(label = 'default') {
|
|
258
|
+
const message = String(label);
|
|
259
|
+
let counter = counters.get(message) ?? 0;
|
|
260
|
+
counter += 1;
|
|
261
|
+
counters.set(message, counter);
|
|
262
|
+
logger.log(`${message}: ${message}`);
|
|
263
|
+
};
|
|
264
|
+
console.countReset = function countReset(label) {
|
|
265
|
+
if (label === undefined) {
|
|
266
|
+
counters.clear();
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
counters.delete(String(label));
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
console.debug = function debug(...args) {
|
|
273
|
+
logger.log(serialize(args));
|
|
274
|
+
};
|
|
275
|
+
console.dir = function dir(arg, options) {
|
|
276
|
+
logger.log((0, node_util_1.inspect)(arg, options));
|
|
277
|
+
};
|
|
278
|
+
console.log = function log(...args) {
|
|
279
|
+
logger.log(serialize(args));
|
|
280
|
+
};
|
|
281
|
+
console.error = function error(...args) {
|
|
282
|
+
logger.error(serialize(args));
|
|
283
|
+
};
|
|
284
|
+
console.trace = function trace(...args) {
|
|
285
|
+
const stack = new Error().stack.replace(/(.+\n){2}/, '');
|
|
286
|
+
let message = 'Trace';
|
|
287
|
+
if (args.length !== 0) {
|
|
288
|
+
message += `: ${serialize(args)}`;
|
|
289
|
+
}
|
|
290
|
+
logger.log(`${message}\n${stack}`);
|
|
291
|
+
};
|
|
292
|
+
console.warn = function warn(...args) {
|
|
293
|
+
logger.warn(serialize(args));
|
|
294
|
+
};
|
|
295
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* --------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
+
* ------------------------------------------------------------------------------------------ */
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
process.on('message', (message) => {
|
|
8
|
+
if (message.command === 'exit') {
|
|
9
|
+
process.exit(0);
|
|
10
|
+
}
|
|
11
|
+
else if (message.command === 'resolve') {
|
|
12
|
+
try {
|
|
13
|
+
const result = require.resolve(message.args);
|
|
14
|
+
process.send({ command: 'resolve', success: true, result: result });
|
|
15
|
+
}
|
|
16
|
+
catch (err) {
|
|
17
|
+
process.send({ command: 'resolve', success: false });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
});
|