typescript-language-server 1.1.2 → 1.2.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/CHANGELOG.md +16 -0
- package/LICENSE +39 -0
- package/README.md +15 -0
- package/lib/completion.d.ts +1 -1
- package/lib/completion.d.ts.map +1 -1
- package/lib/completion.js +10 -3
- package/lib/completion.js.map +1 -1
- package/lib/configuration-manager.d.ts +3 -10
- package/lib/configuration-manager.d.ts.map +1 -1
- package/lib/configuration-manager.js +23 -3
- package/lib/configuration-manager.js.map +1 -1
- package/lib/features/inlay-hints.js +2 -2
- package/lib/features/inlay-hints.js.map +1 -1
- package/lib/lsp-server.d.ts +2 -4
- package/lib/lsp-server.d.ts.map +1 -1
- package/lib/lsp-server.js +46 -85
- package/lib/lsp-server.js.map +1 -1
- package/lib/lsp-server.spec.js +84 -6
- package/lib/lsp-server.spec.js.map +1 -1
- package/lib/refactor.d.ts +2 -1
- package/lib/refactor.d.ts.map +1 -1
- package/lib/refactor.js +17 -7
- package/lib/refactor.js.map +1 -1
- package/lib/test-utils.d.ts +16 -0
- package/lib/test-utils.d.ts.map +1 -1
- package/lib/test-utils.js +5 -4
- package/lib/test-utils.js.map +1 -1
- package/lib/ts-protocol.d.ts +3 -1
- package/lib/ts-protocol.d.ts.map +1 -1
- package/lib/tsServer/callbackMap.d.ts +17 -0
- package/lib/tsServer/callbackMap.d.ts.map +1 -0
- package/lib/tsServer/callbackMap.js +47 -0
- package/lib/tsServer/callbackMap.js.map +1 -0
- package/lib/tsServer/cancellation.d.ts +19 -0
- package/lib/tsServer/cancellation.d.ts.map +1 -0
- package/lib/tsServer/cancellation.js +52 -0
- package/lib/tsServer/cancellation.js.map +1 -0
- package/lib/tsServer/requestQueue.d.ts +34 -0
- package/lib/tsServer/requestQueue.d.ts.map +1 -0
- package/lib/tsServer/requestQueue.js +74 -0
- package/lib/tsServer/requestQueue.js.map +1 -0
- package/lib/tsServer/requests.d.ts +68 -0
- package/lib/tsServer/requests.d.ts.map +1 -0
- package/lib/tsServer/requests.js +28 -0
- package/lib/tsServer/requests.js.map +1 -0
- package/lib/tsServer/server.d.ts +93 -0
- package/lib/tsServer/server.d.ts.map +1 -0
- package/lib/tsServer/server.js +208 -0
- package/lib/tsServer/server.js.map +1 -0
- package/lib/tsServer/serverError.d.ts +18 -0
- package/lib/tsServer/serverError.d.ts.map +1 -0
- package/lib/tsServer/serverError.js +53 -0
- package/lib/tsServer/serverError.js.map +1 -0
- package/lib/tsServer/serverProcess.d.ts +7 -0
- package/lib/tsServer/serverProcess.d.ts.map +1 -0
- package/lib/tsServer/serverProcess.js +238 -0
- package/lib/tsServer/serverProcess.js.map +1 -0
- package/lib/tsServer/spawner.d.ts +14 -0
- package/lib/tsServer/spawner.d.ts.map +1 -0
- package/lib/tsServer/spawner.js +122 -0
- package/lib/tsServer/spawner.js.map +1 -0
- package/lib/{utils → tsServer}/versionProvider.d.ts +2 -2
- package/lib/tsServer/versionProvider.d.ts.map +1 -0
- package/lib/{utils → tsServer}/versionProvider.js +2 -2
- package/lib/tsServer/versionProvider.js.map +1 -0
- package/lib/tsp-client.d.ts +17 -52
- package/lib/tsp-client.d.ts.map +1 -1
- package/lib/tsp-client.js +186 -139
- package/lib/tsp-client.js.map +1 -1
- package/lib/tsp-client.spec.js +11 -6
- package/lib/tsp-client.spec.js.map +1 -1
- package/lib/utils/api.d.ts +1 -0
- package/lib/utils/api.d.ts.map +1 -1
- package/lib/utils/api.js +1 -0
- package/lib/utils/api.js.map +1 -1
- package/lib/utils/modules-resolver.spec.js +1 -1
- package/lib/utils/modules-resolver.spec.js.map +1 -1
- package/package.json +7 -7
- package/lib/utils/versionProvider.d.ts.map +0 -1
- package/lib/utils/versionProvider.js.map +0 -1
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type tsp from 'typescript/lib/protocol.d.js';
|
|
2
|
+
export declare enum RequestQueueingType {
|
|
3
|
+
/**
|
|
4
|
+
* Normal request that is executed in order.
|
|
5
|
+
*/
|
|
6
|
+
Normal = 1,
|
|
7
|
+
/**
|
|
8
|
+
* Request that normal requests jump in front of in the queue.
|
|
9
|
+
*/
|
|
10
|
+
LowPriority = 2,
|
|
11
|
+
/**
|
|
12
|
+
* A fence that blocks request reordering.
|
|
13
|
+
*
|
|
14
|
+
* Fences are not reordered. Unlike a normal request, a fence will never jump in front of a low priority request
|
|
15
|
+
* in the request queue.
|
|
16
|
+
*/
|
|
17
|
+
Fence = 3
|
|
18
|
+
}
|
|
19
|
+
export interface RequestItem {
|
|
20
|
+
readonly request: tsp.Request;
|
|
21
|
+
readonly expectsResponse: boolean;
|
|
22
|
+
readonly isAsync: boolean;
|
|
23
|
+
readonly queueingType: RequestQueueingType;
|
|
24
|
+
}
|
|
25
|
+
export declare class RequestQueue {
|
|
26
|
+
private readonly queue;
|
|
27
|
+
private sequenceNumber;
|
|
28
|
+
get length(): number;
|
|
29
|
+
enqueue(item: RequestItem): void;
|
|
30
|
+
dequeue(): RequestItem | undefined;
|
|
31
|
+
tryDeletePendingRequest(seq: number): boolean;
|
|
32
|
+
createRequest(command: string, args: any): tsp.Request;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=requestQueue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requestQueue.d.ts","sourceRoot":"","sources":["../../src/tsServer/requestQueue.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,GAAG,MAAM,8BAA8B,CAAC;AAEpD,oBAAY,mBAAmB;IAC3B;;OAEG;IACH,MAAM,IAAI;IAEV;;OAEG;IACH,WAAW,IAAI;IAEf;;;;;OAKG;IACH,KAAK,IAAI;CACZ;AAED,MAAM,WAAW,WAAW;IACxB,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC;IAC9B,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAC;CAC9C;AAED,qBAAa,YAAY;IACrB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAqB;IAC3C,OAAO,CAAC,cAAc,CAAK;IAE3B,IAAW,MAAM,IAAI,MAAM,CAE1B;IAEM,OAAO,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI;IAgBhC,OAAO,IAAI,WAAW,GAAG,SAAS;IAIlC,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAU7C,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,GAAG,CAAC,OAAO;CAQhE"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
/*
|
|
6
|
+
* Copyright (C) 2022 TypeFox and others.
|
|
7
|
+
*
|
|
8
|
+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*/
|
|
11
|
+
export var RequestQueueingType;
|
|
12
|
+
(function (RequestQueueingType) {
|
|
13
|
+
/**
|
|
14
|
+
* Normal request that is executed in order.
|
|
15
|
+
*/
|
|
16
|
+
RequestQueueingType[RequestQueueingType["Normal"] = 1] = "Normal";
|
|
17
|
+
/**
|
|
18
|
+
* Request that normal requests jump in front of in the queue.
|
|
19
|
+
*/
|
|
20
|
+
RequestQueueingType[RequestQueueingType["LowPriority"] = 2] = "LowPriority";
|
|
21
|
+
/**
|
|
22
|
+
* A fence that blocks request reordering.
|
|
23
|
+
*
|
|
24
|
+
* Fences are not reordered. Unlike a normal request, a fence will never jump in front of a low priority request
|
|
25
|
+
* in the request queue.
|
|
26
|
+
*/
|
|
27
|
+
RequestQueueingType[RequestQueueingType["Fence"] = 3] = "Fence";
|
|
28
|
+
})(RequestQueueingType = RequestQueueingType || (RequestQueueingType = {}));
|
|
29
|
+
export class RequestQueue {
|
|
30
|
+
constructor() {
|
|
31
|
+
this.queue = [];
|
|
32
|
+
this.sequenceNumber = 0;
|
|
33
|
+
}
|
|
34
|
+
get length() {
|
|
35
|
+
return this.queue.length;
|
|
36
|
+
}
|
|
37
|
+
enqueue(item) {
|
|
38
|
+
if (item.queueingType === RequestQueueingType.Normal) {
|
|
39
|
+
let index = this.queue.length - 1;
|
|
40
|
+
while (index >= 0) {
|
|
41
|
+
if (this.queue[index].queueingType !== RequestQueueingType.LowPriority) {
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
--index;
|
|
45
|
+
}
|
|
46
|
+
this.queue.splice(index + 1, 0, item);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
// Only normal priority requests can be reordered. All other requests just go to the end.
|
|
50
|
+
this.queue.push(item);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
dequeue() {
|
|
54
|
+
return this.queue.shift();
|
|
55
|
+
}
|
|
56
|
+
tryDeletePendingRequest(seq) {
|
|
57
|
+
for (let i = 0; i < this.queue.length; i++) {
|
|
58
|
+
if (this.queue[i].request.seq === seq) {
|
|
59
|
+
this.queue.splice(i, 1);
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
createRequest(command, args) {
|
|
66
|
+
return {
|
|
67
|
+
seq: this.sequenceNumber++,
|
|
68
|
+
type: 'request',
|
|
69
|
+
command: command,
|
|
70
|
+
arguments: args,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=requestQueue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requestQueue.js","sourceRoot":"","sources":["../../src/tsServer/requestQueue.ts"],"names":[],"mapp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,CAAC,CAAC,OAAO,CAAC,GAAG,KAAK,GAAG,EAAE;gBACnC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;gBACxB,OAAO,IAAI,CAAC;aACf;SACJ;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;IAEM,aAAa,CAAC,OAAe,EAAE,IAAS;QAC3C,OAAO;YACH,GAAG,EAAE,IAAI,CAAC,cAAc,EAAE;YAC1B,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,OAAO;YAChB,SAAS,EAAE,IAAI;SAClB,CAAC;IACN,CAAC;CACJ"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import vscodeUri from 'vscode-uri';
|
|
2
|
+
import type tsp from 'typescript/lib/protocol.d.js';
|
|
3
|
+
import { CommandTypes } from '../tsp-command-types.js';
|
|
4
|
+
import { ExecutionTarget } from './server.js';
|
|
5
|
+
export declare enum ServerType {
|
|
6
|
+
Syntax = "syntax",
|
|
7
|
+
Semantic = "semantic"
|
|
8
|
+
}
|
|
9
|
+
export declare namespace ServerResponse {
|
|
10
|
+
class Cancelled {
|
|
11
|
+
readonly reason: string;
|
|
12
|
+
readonly type = "cancelled";
|
|
13
|
+
constructor(reason: string);
|
|
14
|
+
}
|
|
15
|
+
const NoContent: {
|
|
16
|
+
readonly type: "noContent";
|
|
17
|
+
};
|
|
18
|
+
const NoServer: {
|
|
19
|
+
readonly type: "noServer";
|
|
20
|
+
};
|
|
21
|
+
type Response<T extends tsp.Response> = T | Cancelled | typeof NoContent | typeof NoServer;
|
|
22
|
+
}
|
|
23
|
+
export interface TypeScriptRequestTypes {
|
|
24
|
+
[CommandTypes.ApplyCodeActionCommand]: [tsp.ApplyCodeActionCommandRequestArgs, tsp.ApplyCodeActionCommandResponse];
|
|
25
|
+
[CommandTypes.Change]: [tsp.ChangeRequestArgs, null];
|
|
26
|
+
[CommandTypes.Close]: [tsp.FileRequestArgs, null];
|
|
27
|
+
[CommandTypes.CompilerOptionsForInferredProjects]: [tsp.SetCompilerOptionsForInferredProjectsArgs, tsp.SetCompilerOptionsForInferredProjectsResponse];
|
|
28
|
+
[CommandTypes.CompletionDetails]: [tsp.CompletionDetailsRequestArgs, tsp.CompletionDetailsResponse];
|
|
29
|
+
[CommandTypes.CompletionInfo]: [tsp.CompletionsRequestArgs, tsp.CompletionInfoResponse];
|
|
30
|
+
[CommandTypes.Configure]: [tsp.ConfigureRequestArguments, tsp.ConfigureResponse];
|
|
31
|
+
[CommandTypes.Definition]: [tsp.FileLocationRequestArgs, tsp.DefinitionResponse];
|
|
32
|
+
[CommandTypes.DefinitionAndBoundSpan]: [tsp.FileLocationRequestArgs, tsp.DefinitionInfoAndBoundSpanResponse];
|
|
33
|
+
[CommandTypes.DocCommentTemplate]: [tsp.FileLocationRequestArgs, tsp.DocCommandTemplateResponse];
|
|
34
|
+
[CommandTypes.DocumentHighlights]: [tsp.DocumentHighlightsRequestArgs, tsp.DocumentHighlightsResponse];
|
|
35
|
+
[CommandTypes.EncodedSemanticClassificationsFull]: [tsp.EncodedSemanticClassificationsRequestArgs, tsp.EncodedSemanticClassificationsResponse];
|
|
36
|
+
[CommandTypes.FindSourceDefinition]: [tsp.FileLocationRequestArgs, tsp.DefinitionResponse];
|
|
37
|
+
[CommandTypes.Format]: [tsp.FormatRequestArgs, tsp.FormatResponse];
|
|
38
|
+
[CommandTypes.Formatonkey]: [tsp.FormatOnKeyRequestArgs, tsp.FormatResponse];
|
|
39
|
+
[CommandTypes.GetApplicableRefactors]: [tsp.GetApplicableRefactorsRequestArgs, tsp.GetApplicableRefactorsResponse];
|
|
40
|
+
[CommandTypes.GetCodeFixes]: [tsp.CodeFixRequestArgs, tsp.CodeFixResponse];
|
|
41
|
+
[CommandTypes.GetCombinedCodeFix]: [tsp.GetCombinedCodeFixRequestArgs, tsp.GetCombinedCodeFixResponse];
|
|
42
|
+
[CommandTypes.GetEditsForFileRename]: [tsp.GetEditsForFileRenameRequestArgs, tsp.GetEditsForFileRenameResponse];
|
|
43
|
+
[CommandTypes.GetEditsForRefactor]: [tsp.GetEditsForRefactorRequestArgs, tsp.GetEditsForRefactorResponse];
|
|
44
|
+
[CommandTypes.Geterr]: [tsp.GeterrRequestArgs, any];
|
|
45
|
+
[CommandTypes.GetOutliningSpans]: [tsp.FileRequestArgs, tsp.OutliningSpansResponse];
|
|
46
|
+
[CommandTypes.GetSupportedCodeFixes]: [null, tsp.GetSupportedCodeFixesResponse];
|
|
47
|
+
[CommandTypes.Implementation]: [tsp.FileLocationRequestArgs, tsp.ImplementationResponse];
|
|
48
|
+
[CommandTypes.JsxClosingTag]: [tsp.JsxClosingTagRequestArgs, tsp.JsxClosingTagResponse];
|
|
49
|
+
[CommandTypes.Navto]: [tsp.NavtoRequestArgs, tsp.NavtoResponse];
|
|
50
|
+
[CommandTypes.NavTree]: [tsp.FileRequestArgs, tsp.NavTreeResponse];
|
|
51
|
+
[CommandTypes.Open]: [tsp.OpenRequestArgs, null];
|
|
52
|
+
[CommandTypes.OrganizeImports]: [tsp.OrganizeImportsRequestArgs, tsp.OrganizeImportsResponse];
|
|
53
|
+
[CommandTypes.ProjectInfo]: [tsp.ProjectInfoRequestArgs, tsp.ProjectInfoResponse];
|
|
54
|
+
[CommandTypes.ProvideInlayHints]: [tsp.InlayHintsRequestArgs, tsp.InlayHintsResponse];
|
|
55
|
+
[CommandTypes.Quickinfo]: [tsp.FileLocationRequestArgs, tsp.QuickInfoResponse];
|
|
56
|
+
[CommandTypes.References]: [tsp.FileLocationRequestArgs, tsp.ReferencesResponse];
|
|
57
|
+
[CommandTypes.Rename]: [tsp.RenameRequestArgs, tsp.RenameResponse];
|
|
58
|
+
[CommandTypes.SignatureHelp]: [tsp.SignatureHelpRequestArgs, tsp.SignatureHelpResponse];
|
|
59
|
+
[CommandTypes.TypeDefinition]: [tsp.FileLocationRequestArgs, tsp.TypeDefinitionResponse];
|
|
60
|
+
[CommandTypes.UpdateOpen]: [tsp.UpdateOpenRequestArgs, tsp.Response];
|
|
61
|
+
}
|
|
62
|
+
export declare type ExecConfig = {
|
|
63
|
+
readonly lowPriority?: boolean;
|
|
64
|
+
readonly nonRecoverable?: boolean;
|
|
65
|
+
readonly cancelOnResourceChange?: vscodeUri.URI;
|
|
66
|
+
readonly executionTarget?: ExecutionTarget;
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=requests.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requests.d.ts","sourceRoot":"","sources":["../../src/tsServer/requests.ts"],"names":[],"mappings":"AAWA,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,KAAK,GAAG,MAAM,8BAA8B,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,oBAAY,UAAU;IAClB,MAAM,WAAW;IACjB,QAAQ,aAAa;CACxB;AAED,yBAAiB,cAAc,CAAC;IAE5B,MAAa,SAAS;iBAIE,MAAM,EAAE,MAAM;QAHlC,SAAgB,IAAI,eAAe;oBAGf,MAAM,EAAE,MAAM;KAErC;IAEM,MAAM,SAAS;;KAAiC,CAAC;IAEjD,MAAM,QAAQ;;KAAgC,CAAC;IAEtD,KAAY,QAAQ,CAAC,CAAC,SAAS,GAAG,CAAC,QAAQ,IAAI,CAAC,GAAG,SAAS,GAAG,OAAO,SAAS,GAAG,OAAO,QAAQ,CAAC;CACrG;AAED,MAAM,WAAW,sBAAsB;IACnC,CAAC,YAAY,CAAC,sBAAsB,CAAC,EAAE,CAAC,GAAG,CAAC,iCAAiC,EAAE,GAAG,CAAC,8BAA8B,CAAC,CAAC;IACnH,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;IACrD,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,CAAC,CA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CAAC;IAC/B,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,sBAAsB,CAAC,EAAE,SAAS,CAAC,GAAG,CAAC;IAChD,QAAQ,CAAC,eAAe,CAAC,EAAE,eAAe,CAAC;CAC9C,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
/*
|
|
6
|
+
* Copyright (C) 2022 TypeFox and others.
|
|
7
|
+
*
|
|
8
|
+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*/
|
|
11
|
+
export var ServerType;
|
|
12
|
+
(function (ServerType) {
|
|
13
|
+
ServerType["Syntax"] = "syntax";
|
|
14
|
+
ServerType["Semantic"] = "semantic";
|
|
15
|
+
})(ServerType = ServerType || (ServerType = {}));
|
|
16
|
+
export var ServerResponse;
|
|
17
|
+
(function (ServerResponse) {
|
|
18
|
+
class Cancelled {
|
|
19
|
+
constructor(reason) {
|
|
20
|
+
this.reason = reason;
|
|
21
|
+
this.type = 'cancelled';
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
ServerResponse.Cancelled = Cancelled;
|
|
25
|
+
ServerResponse.NoContent = { type: 'noContent' };
|
|
26
|
+
ServerResponse.NoServer = { type: 'noServer' };
|
|
27
|
+
})(ServerResponse = ServerResponse || (ServerResponse = {}));
|
|
28
|
+
//# sourceMappingURL=requests.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requests.js","sourceRoot":"","sources":["../../src/tsServer/requests.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;;;;GAKG;AAOH,MAAM,CAAN,IAAY,UAGX;AAHD,WAAY,UAAU;IAClB,+BAAiB,CAAA;IACjB,mCAAqB,CAAA;AACzB,CAAC,EAHW,UAAU,GAAV,UAAU,KAAV,UAAU,QAGrB;AAED,MAAM,KAAW,cAAc,CAe9B;AAfD,WAAiB,cAAc;IAE3B,MAAa,SAAS;QAGlB,YACoB,MAAc;YAAd,WAAM,GAAN,MAAM,CAAQ;YAHlB,SAAI,GAAG,WAAW,CAAC;QAI/B,CAAC;KACR;IANY,wBAAS,YAMrB,CAAA;IAEY,wBAAS,GAAG,EAAE,IAAI,EAAE,WAAW,EAAW,CAAC;IAE3C,uBAAQ,GAAG,EAAE,IAAI,EAAE,UAAU,EAAW,CAAC;AAG1D,CAAC,EAfgB,cAAc,GAAd,cAAc,KAAd,cAAc,QAe9B"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
import type tsp from 'typescript/lib/protocol.d.js';
|
|
3
|
+
import { CancellationToken } from 'vscode-jsonrpc';
|
|
4
|
+
import { ServerResponse, ServerType, TypeScriptRequestTypes } from './requests.js';
|
|
5
|
+
import type { TspClientOptions } from '../tsp-client.js';
|
|
6
|
+
import { OngoingRequestCanceller } from './cancellation.js';
|
|
7
|
+
import type { TypeScriptVersion } from './versionProvider.js';
|
|
8
|
+
export declare enum ExecutionTarget {
|
|
9
|
+
Semantic = 0,
|
|
10
|
+
Syntax = 1
|
|
11
|
+
}
|
|
12
|
+
export interface TypeScriptServerExitEvent {
|
|
13
|
+
readonly code: number | null;
|
|
14
|
+
readonly signal: NodeJS.Signals | null;
|
|
15
|
+
}
|
|
16
|
+
declare type OnEventHandler = (e: tsp.Event) => any;
|
|
17
|
+
declare type OnExitHandler = (e: TypeScriptServerExitEvent) => any;
|
|
18
|
+
declare type OnErrorHandler = (e: any) => any;
|
|
19
|
+
export interface ITypeScriptServer {
|
|
20
|
+
onEvent(handler: OnEventHandler): void;
|
|
21
|
+
onExit(handler: OnExitHandler): void;
|
|
22
|
+
onError(handler: OnErrorHandler): void;
|
|
23
|
+
readonly tsServerLogFile: string | undefined;
|
|
24
|
+
kill(): void;
|
|
25
|
+
/**
|
|
26
|
+
* @return A list of all execute requests. If there are multiple entries, the first item is the primary
|
|
27
|
+
* request while the rest are secondary ones.
|
|
28
|
+
*/
|
|
29
|
+
executeImpl(command: keyof TypeScriptRequestTypes, args: any, executeInfo: {
|
|
30
|
+
isAsync: boolean;
|
|
31
|
+
token?: CancellationToken;
|
|
32
|
+
expectsResult: boolean;
|
|
33
|
+
lowPriority?: boolean;
|
|
34
|
+
executionTarget?: ExecutionTarget;
|
|
35
|
+
}): Array<Promise<ServerResponse.Response<tsp.Response>> | undefined>;
|
|
36
|
+
dispose(): void;
|
|
37
|
+
}
|
|
38
|
+
export declare const enum TsServerProcessKind {
|
|
39
|
+
Main = "main",
|
|
40
|
+
Syntax = "syntax",
|
|
41
|
+
Semantic = "semantic",
|
|
42
|
+
Diagnostics = "diagnostics"
|
|
43
|
+
}
|
|
44
|
+
export interface TsServerProcessFactory {
|
|
45
|
+
fork(version: TypeScriptVersion, args: readonly string[], kind: TsServerProcessKind, configuration: TspClientOptions): TsServerProcess;
|
|
46
|
+
}
|
|
47
|
+
export interface TsServerProcess {
|
|
48
|
+
write(serverRequest: tsp.Request): void;
|
|
49
|
+
onData(handler: (data: tsp.Response) => void): void;
|
|
50
|
+
onExit(handler: (code: number | null, signal: NodeJS.Signals | null) => void): void;
|
|
51
|
+
onError(handler: (error: Error) => void): void;
|
|
52
|
+
kill(): void;
|
|
53
|
+
}
|
|
54
|
+
export declare class ProcessBasedTsServer implements ITypeScriptServer {
|
|
55
|
+
private readonly _serverId;
|
|
56
|
+
private readonly _serverSource;
|
|
57
|
+
private readonly _process;
|
|
58
|
+
private readonly _tsServerLogFile;
|
|
59
|
+
private readonly _requestCanceller;
|
|
60
|
+
private readonly _version;
|
|
61
|
+
private readonly _requestQueue;
|
|
62
|
+
private readonly _callbacks;
|
|
63
|
+
private readonly _pendingResponses;
|
|
64
|
+
private readonly _eventHandlers;
|
|
65
|
+
private readonly _exitHandlers;
|
|
66
|
+
private readonly _errorHandlers;
|
|
67
|
+
constructor(_serverId: string, _serverSource: ServerType, _process: TsServerProcess, _tsServerLogFile: string | undefined, _requestCanceller: OngoingRequestCanceller, _version: TypeScriptVersion);
|
|
68
|
+
onEvent(handler: OnEventHandler): void;
|
|
69
|
+
onExit(handler: OnExitHandler): void;
|
|
70
|
+
onError(handler: OnErrorHandler): void;
|
|
71
|
+
get tsServerLogFile(): string | undefined;
|
|
72
|
+
private write;
|
|
73
|
+
dispose(): void;
|
|
74
|
+
kill(): void;
|
|
75
|
+
private dispatchMessage;
|
|
76
|
+
private tryCancelRequest;
|
|
77
|
+
private dispatchResponse;
|
|
78
|
+
executeImpl(command: keyof TypeScriptRequestTypes, args: any, executeInfo: {
|
|
79
|
+
isAsync: boolean;
|
|
80
|
+
token?: CancellationToken;
|
|
81
|
+
expectsResult: boolean;
|
|
82
|
+
lowPriority?: boolean;
|
|
83
|
+
executionTarget?: ExecutionTarget;
|
|
84
|
+
}): Array<Promise<ServerResponse.Response<tsp.Response>> | undefined>;
|
|
85
|
+
private sendNextRequests;
|
|
86
|
+
private sendRequest;
|
|
87
|
+
private fetchCallback;
|
|
88
|
+
private logTrace;
|
|
89
|
+
private static readonly fenceCommands;
|
|
90
|
+
private static getQueueingType;
|
|
91
|
+
}
|
|
92
|
+
export {};
|
|
93
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/tsServer/server.ts"],"names":[],"mappings":";AAWA,OAAO,KAAK,GAAG,MAAM,8BAA8B,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACnF,OAAO,K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@@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
/*
|
|
6
|
+
* Copyright (C) 2022 TypeFox and others.
|
|
7
|
+
*
|
|
8
|
+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*/
|
|
11
|
+
import { RequestQueue, RequestQueueingType } from './requestQueue.js';
|
|
12
|
+
import { ServerResponse } from './requests.js';
|
|
13
|
+
import { CallbackMap } from './callbackMap.js';
|
|
14
|
+
import { TypeScriptServerError } from './serverError.js';
|
|
15
|
+
export var ExecutionTarget;
|
|
16
|
+
(function (ExecutionTarget) {
|
|
17
|
+
ExecutionTarget[ExecutionTarget["Semantic"] = 0] = "Semantic";
|
|
18
|
+
ExecutionTarget[ExecutionTarget["Syntax"] = 1] = "Syntax";
|
|
19
|
+
})(ExecutionTarget = ExecutionTarget || (ExecutionTarget = {}));
|
|
20
|
+
export class ProcessBasedTsServer {
|
|
21
|
+
constructor(_serverId, _serverSource, _process, _tsServerLogFile, _requestCanceller, _version) {
|
|
22
|
+
this._serverId = _serverId;
|
|
23
|
+
this._serverSource = _serverSource;
|
|
24
|
+
this._process = _process;
|
|
25
|
+
this._tsServerLogFile = _tsServerLogFile;
|
|
26
|
+
this._requestCanceller = _requestCanceller;
|
|
27
|
+
this._version = _version;
|
|
28
|
+
this._requestQueue = new RequestQueue();
|
|
29
|
+
this._callbacks = new CallbackMap();
|
|
30
|
+
this._pendingResponses = new Set();
|
|
31
|
+
this._eventHandlers = new Set();
|
|
32
|
+
this._exitHandlers = new Set();
|
|
33
|
+
this._errorHandlers = new Set();
|
|
34
|
+
this._process.onData(msg => {
|
|
35
|
+
this.dispatchMessage(msg);
|
|
36
|
+
});
|
|
37
|
+
this._process.onExit((code, signal) => {
|
|
38
|
+
this._exitHandlers.forEach(handler => handler({ code, signal }));
|
|
39
|
+
this._callbacks.destroy('server exited');
|
|
40
|
+
});
|
|
41
|
+
this._process.onError(error => {
|
|
42
|
+
this._errorHandlers.forEach(handler => handler(error));
|
|
43
|
+
this._callbacks.destroy('server errored');
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
onEvent(handler) {
|
|
47
|
+
this._eventHandlers.add(handler);
|
|
48
|
+
}
|
|
49
|
+
onExit(handler) {
|
|
50
|
+
this._exitHandlers.add(handler);
|
|
51
|
+
}
|
|
52
|
+
onError(handler) {
|
|
53
|
+
this._errorHandlers.add(handler);
|
|
54
|
+
}
|
|
55
|
+
get tsServerLogFile() {
|
|
56
|
+
return this._tsServerLogFile;
|
|
57
|
+
}
|
|
58
|
+
write(serverRequest) {
|
|
59
|
+
this._process.write(serverRequest);
|
|
60
|
+
}
|
|
61
|
+
dispose() {
|
|
62
|
+
this._callbacks.destroy('server disposed');
|
|
63
|
+
this._pendingResponses.clear();
|
|
64
|
+
this._eventHandlers.clear();
|
|
65
|
+
this._exitHandlers.clear();
|
|
66
|
+
this._errorHandlers.clear();
|
|
67
|
+
}
|
|
68
|
+
kill() {
|
|
69
|
+
this.dispose();
|
|
70
|
+
this._process.kill();
|
|
71
|
+
}
|
|
72
|
+
dispatchMessage(message) {
|
|
73
|
+
try {
|
|
74
|
+
switch (message.type) {
|
|
75
|
+
case 'response':
|
|
76
|
+
if (this._serverSource) {
|
|
77
|
+
this.dispatchResponse({
|
|
78
|
+
...message,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
this.dispatchResponse(message);
|
|
83
|
+
}
|
|
84
|
+
break;
|
|
85
|
+
case 'event': {
|
|
86
|
+
const event = message;
|
|
87
|
+
if (event.event === 'requestCompleted') {
|
|
88
|
+
const seq = event.body.request_seq;
|
|
89
|
+
const callback = this._callbacks.fetch(seq);
|
|
90
|
+
if (callback) {
|
|
91
|
+
// this._tracer.traceRequestCompleted(this._serverId, 'requestCompleted', seq, callback);
|
|
92
|
+
callback.onSuccess(undefined);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
// this._tracer.traceEvent(this._serverId, event);
|
|
97
|
+
this._eventHandlers.forEach(handler => handler(event));
|
|
98
|
+
}
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
default:
|
|
102
|
+
throw new Error(`Unknown message type ${message.type} received`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
finally {
|
|
106
|
+
this.sendNextRequests();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
tryCancelRequest(seq, command) {
|
|
110
|
+
try {
|
|
111
|
+
if (this._requestQueue.tryDeletePendingRequest(seq)) {
|
|
112
|
+
this.logTrace(`Canceled request with sequence number ${seq}`);
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
if (this._requestCanceller.tryCancelOngoingRequest(seq)) {
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
this.logTrace(`Tried to cancel request with sequence number ${seq}. But request got already delivered.`);
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
finally {
|
|
122
|
+
const callback = this.fetchCallback(seq);
|
|
123
|
+
callback?.onSuccess(new ServerResponse.Cancelled(`Cancelled request ${seq} - ${command}`));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
dispatchResponse(response) {
|
|
127
|
+
const callback = this.fetchCallback(response.request_seq);
|
|
128
|
+
if (!callback) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
// this._tracer.traceResponse(this._serverId, response, callback);
|
|
132
|
+
if (response.success) {
|
|
133
|
+
callback.onSuccess(response);
|
|
134
|
+
}
|
|
135
|
+
else if (response.message === 'No content available.') {
|
|
136
|
+
// Special case where response itself is successful but there is not any data to return.
|
|
137
|
+
callback.onSuccess(ServerResponse.NoContent);
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
callback.onError(TypeScriptServerError.create(this._serverId, this._version, response));
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
executeImpl(command, args, executeInfo) {
|
|
144
|
+
const request = this._requestQueue.createRequest(command, args);
|
|
145
|
+
const requestInfo = {
|
|
146
|
+
request,
|
|
147
|
+
expectsResponse: executeInfo.expectsResult,
|
|
148
|
+
isAsync: executeInfo.isAsync,
|
|
149
|
+
queueingType: ProcessBasedTsServer.getQueueingType(command, executeInfo.lowPriority),
|
|
150
|
+
};
|
|
151
|
+
let result;
|
|
152
|
+
if (executeInfo.expectsResult) {
|
|
153
|
+
result = new Promise((resolve, reject) => {
|
|
154
|
+
this._callbacks.add(request.seq, { onSuccess: resolve, onError: reject, queuingStartTime: Date.now(), isAsync: executeInfo.isAsync }, executeInfo.isAsync);
|
|
155
|
+
if (executeInfo.token) {
|
|
156
|
+
executeInfo.token.onCancellationRequested(() => {
|
|
157
|
+
this.tryCancelRequest(request.seq, command);
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
this._requestQueue.enqueue(requestInfo);
|
|
163
|
+
this.sendNextRequests();
|
|
164
|
+
return [result];
|
|
165
|
+
}
|
|
166
|
+
sendNextRequests() {
|
|
167
|
+
// console.error({ pending: this._pendingResponses.size, queue: this._requestQueue.length });
|
|
168
|
+
while (this._pendingResponses.size === 0 && this._requestQueue.length > 0) {
|
|
169
|
+
const item = this._requestQueue.dequeue();
|
|
170
|
+
if (item) {
|
|
171
|
+
this.sendRequest(item);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
sendRequest(requestItem) {
|
|
176
|
+
const serverRequest = requestItem.request;
|
|
177
|
+
// this._tracer.traceRequest(this._serverId, serverRequest, requestItem.expectsResponse, this._requestQueue.length);
|
|
178
|
+
if (requestItem.expectsResponse && !requestItem.isAsync) {
|
|
179
|
+
this._pendingResponses.add(requestItem.request.seq);
|
|
180
|
+
}
|
|
181
|
+
try {
|
|
182
|
+
this.write(serverRequest);
|
|
183
|
+
}
|
|
184
|
+
catch (err) {
|
|
185
|
+
const callback = this.fetchCallback(serverRequest.seq);
|
|
186
|
+
callback?.onError(err);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
fetchCallback(seq) {
|
|
190
|
+
const callback = this._callbacks.fetch(seq);
|
|
191
|
+
if (!callback) {
|
|
192
|
+
return undefined;
|
|
193
|
+
}
|
|
194
|
+
this._pendingResponses.delete(seq);
|
|
195
|
+
return callback;
|
|
196
|
+
}
|
|
197
|
+
logTrace(_message) {
|
|
198
|
+
// this._tracer.logTrace(this._serverId, message);
|
|
199
|
+
}
|
|
200
|
+
static getQueueingType(command, lowPriority) {
|
|
201
|
+
if (ProcessBasedTsServer.fenceCommands.has(command)) {
|
|
202
|
+
return RequestQueueingType.Fence;
|
|
203
|
+
}
|
|
204
|
+
return lowPriority ? RequestQueueingType.LowPriority : RequestQueueingType.Normal;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
ProcessBasedTsServer.fenceCommands = new Set(['change', 'close', 'open', 'updateOpen']);
|
|
208
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/tsServer/server.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;;;;GAKG;AAIH,OAAO,EAAe,YAAY,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACnF,OAAO,EAAE,cAAc,EAAsC,MAAM,eAAe,CAAC;AAGnF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAGzD,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACvB,6DAAQ,CAAA;IACR,yDAAM,CAAA;AACV,CAAC,EAHW,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CAAC,CAAC;SACnC;IACL,CAAC;IAEO,aAAa,CAAC,GAAW;QAC7B,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC5C,IAAI,CAAC,QAAQ,EAAE;YACX,OAAO,SAAS,CAAC;SACpB;QAED,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACnC,OAAO,QAAQ,CAAC;IACpB,CAAC;IAEO,QAAQ,CAAC,QAAgB;QAC7B,kDAAkD;IACtD,CAAC;IAIO,MAAM,CAAC,eAAe,CAC1B,OAAe,EACf,WAAqB;QAErB,IAAI,oBAAoB,CAAC,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;YACjD,OAAO,mBAAmB,CAAC,KAAK,CAAC;SACpC;QACD,OAAO,WAAW,CAAC,CAAC,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC,CAAC,mBAAmB,CAAC,MAAM,CAAC;IACtF,CAAC;;AAVuB,kCAAa,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type tsp from 'typescript/lib/protocol.d.js';
|
|
2
|
+
import type { TypeScriptVersion } from './versionProvider.js';
|
|
3
|
+
export declare class TypeScriptServerError extends Error {
|
|
4
|
+
readonly serverId: string;
|
|
5
|
+
readonly version: TypeScriptVersion;
|
|
6
|
+
private readonly response;
|
|
7
|
+
readonly serverMessage: string | undefined;
|
|
8
|
+
readonly serverStack: string | undefined;
|
|
9
|
+
static create(serverId: string, version: TypeScriptVersion, response: tsp.Response): TypeScriptServerError;
|
|
10
|
+
private constructor();
|
|
11
|
+
get serverErrorText(): string | undefined;
|
|
12
|
+
get serverCommand(): string;
|
|
13
|
+
/**
|
|
14
|
+
* Given a `errorText` from a tsserver request indicating failure in handling a request.
|
|
15
|
+
*/
|
|
16
|
+
private static parseErrorText;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=serverError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serverError.d.ts","sourceRoot":"","sources":["../../src/tsServer/serverError.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,GAAG,MAAM,8BAA8B,CAAC;AACpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE9D,qBAAa,qBAAsB,SAAQ,KAAK;aAWxB,QAAQ,EAAE,MAAM;aAChB,OAAO,EAAE,iBAAiB;IAC1C,OAAO,CAAC,QAAQ,CAAC,QAAQ;aACT,aAAa,EAAE,MAAM,GAAG,SAAS;aACjC,WAAW,EAAE,MAAM,GAAG,SAAS;WAdrC,MAAM,CAChB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,iBAAiB,EAC1B,QAAQ,EAAE,GAAG,CAAC,QAAQ,GACvB,qBAAqB;IAKxB,OAAO;IAUP,IAAW,eAAe,IAAI,MAAM,GAAG,SAAS,CAE/C;IAED,IAAW,aAAa,IAAI,MAAM,CAEjC;IAED;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,cAAc;CAmBhC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
/*
|
|
6
|
+
* Copyright (C) 2022 TypeFox and others.
|
|
7
|
+
*
|
|
8
|
+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*/
|
|
11
|
+
export class TypeScriptServerError extends Error {
|
|
12
|
+
constructor(serverId, version, response, serverMessage, serverStack) {
|
|
13
|
+
super(`<${serverId}> TypeScript Server Error (${version.versionString})\n${serverMessage}\n${serverStack}`);
|
|
14
|
+
this.serverId = serverId;
|
|
15
|
+
this.version = version;
|
|
16
|
+
this.response = response;
|
|
17
|
+
this.serverMessage = serverMessage;
|
|
18
|
+
this.serverStack = serverStack;
|
|
19
|
+
}
|
|
20
|
+
static create(serverId, version, response) {
|
|
21
|
+
const parsedResult = TypeScriptServerError.parseErrorText(response);
|
|
22
|
+
return new TypeScriptServerError(serverId, version, response, parsedResult?.message, parsedResult?.stack);
|
|
23
|
+
}
|
|
24
|
+
get serverErrorText() {
|
|
25
|
+
return this.response.message;
|
|
26
|
+
}
|
|
27
|
+
get serverCommand() {
|
|
28
|
+
return this.response.command;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Given a `errorText` from a tsserver request indicating failure in handling a request.
|
|
32
|
+
*/
|
|
33
|
+
static parseErrorText(response) {
|
|
34
|
+
const errorText = response.message;
|
|
35
|
+
if (errorText) {
|
|
36
|
+
const errorPrefix = 'Error processing request. ';
|
|
37
|
+
if (errorText.startsWith(errorPrefix)) {
|
|
38
|
+
const prefixFreeErrorText = errorText.substr(errorPrefix.length);
|
|
39
|
+
const newlineIndex = prefixFreeErrorText.indexOf('\n');
|
|
40
|
+
if (newlineIndex >= 0) {
|
|
41
|
+
// Newline expected between message and stack.
|
|
42
|
+
const stack = prefixFreeErrorText.substring(newlineIndex + 1);
|
|
43
|
+
return {
|
|
44
|
+
message: prefixFreeErrorText.substring(0, newlineIndex),
|
|
45
|
+
stack,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=serverError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serverError.js","sourceRoot":"","sources":["../../src/tsServer/serverError.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;;;;GAKG;A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8CAA8C;oBAC9C,MAAM,KAAK,GAAG,mBAAmB,CAAC,SAAS,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC;oBAC9D,OAAO;wBACH,OAAO,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC,EAAE,YAAY,CAAC;wBACvD,KAAK;qBACR,CAAC;iBACL;aACJ;SACJ;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TsServerProcess, TsServerProcessFactory, TsServerProcessKind } from './server.js';
|
|
2
|
+
import type { TspClientOptions } from '../tsp-client.js';
|
|
3
|
+
import type { TypeScriptVersion } from './versionProvider.js';
|
|
4
|
+
export declare class NodeTsServerProcessFactory implements TsServerProcessFactory {
|
|
5
|
+
fork(version: TypeScriptVersion, args: readonly string[], kind: TsServerProcessKind, configuration: TspClientOptions): TsServerProcess;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=serverProcess.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serverProcess.d.ts","sourceRoot":"","sources":["../../src/tsServer/serverProcess.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC3F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE9D,qBAAa,0BAA2B,YAAW,sBAAsB;IACrE,IAAI,CACA,OAAO,EAAE,iBAAiB,EAC1B,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,IAAI,EAAE,mBAAmB,EACzB,aAAa,EAAE,gBAAgB,GAChC,eAAe;CAmBrB"}
|