Merge pull request #20465 from Microsoft/dev/aozgaa/tsserverVersion
Add a status request-response for editors
This commit is contained in:
commit
477c1f57a9
|
@ -169,6 +169,19 @@ namespace ts.server {
|
|||
allowNonTsExtensions: true // injected by tsserver
|
||||
});
|
||||
});
|
||||
|
||||
it("Status request gives ts.version", () => {
|
||||
const req: protocol.StatusRequest = {
|
||||
command: CommandNames.Status,
|
||||
seq: 0,
|
||||
type: "request"
|
||||
};
|
||||
|
||||
const expected: protocol.StatusResponseBody = {
|
||||
version: ts.version
|
||||
};
|
||||
assert.deepEqual(session.executeCommand(req).response, expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe("onMessage", () => {
|
||||
|
@ -220,6 +233,7 @@ namespace ts.server {
|
|||
CommandNames.Saveto,
|
||||
CommandNames.SignatureHelp,
|
||||
CommandNames.SignatureHelpFull,
|
||||
CommandNames.Status,
|
||||
CommandNames.TypeDefinition,
|
||||
CommandNames.ProjectInfo,
|
||||
CommandNames.ReloadProjects,
|
||||
|
|
|
@ -71,6 +71,7 @@ namespace ts.server.protocol {
|
|||
SignatureHelp = "signatureHelp",
|
||||
/* @internal */
|
||||
SignatureHelpFull = "signatureHelp-full",
|
||||
Status = "status",
|
||||
TypeDefinition = "typeDefinition",
|
||||
ProjectInfo = "projectInfo",
|
||||
ReloadProjects = "reloadProjects",
|
||||
|
@ -216,6 +217,24 @@ namespace ts.server.protocol {
|
|||
projectFileName?: string;
|
||||
}
|
||||
|
||||
export interface StatusRequest extends Request {
|
||||
command: CommandTypes.Status;
|
||||
}
|
||||
|
||||
export interface StatusResponseBody {
|
||||
/**
|
||||
* The TypeScript version (`ts.version`).
|
||||
*/
|
||||
version: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Response to StatusRequest
|
||||
*/
|
||||
export interface StatusResponse extends Response {
|
||||
body: StatusResponseBody;
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests a JS Doc comment template for a given position
|
||||
*/
|
||||
|
|
|
@ -1703,6 +1703,10 @@ namespace ts.server {
|
|||
}
|
||||
|
||||
private handlers = createMapFromTemplate<(request: protocol.Request) => HandlerResponse>({
|
||||
[CommandNames.Status]: () => {
|
||||
const response: protocol.StatusResponseBody = { version };
|
||||
return this.requiredResponse(response);
|
||||
},
|
||||
[CommandNames.OpenExternalProject]: (request: protocol.OpenExternalProjectRequest) => {
|
||||
this.projectService.openExternalProject(request.arguments, /*suppressRefreshOfInferredProjects*/ false);
|
||||
// TODO: GH#20447 report errors
|
||||
|
|
|
@ -4905,6 +4905,7 @@ declare namespace ts.server.protocol {
|
|||
Rename = "rename",
|
||||
Saveto = "saveto",
|
||||
SignatureHelp = "signatureHelp",
|
||||
Status = "status",
|
||||
TypeDefinition = "typeDefinition",
|
||||
ProjectInfo = "projectInfo",
|
||||
ReloadProjects = "reloadProjects",
|
||||
|
@ -5006,6 +5007,21 @@ declare namespace ts.server.protocol {
|
|||
file: string;
|
||||
projectFileName?: string;
|
||||
}
|
||||
interface StatusRequest extends Request {
|
||||
command: CommandTypes.Status;
|
||||
}
|
||||
interface StatusResponseBody {
|
||||
/**
|
||||
* The TypeScript version (`ts.version`).
|
||||
*/
|
||||
version: string;
|
||||
}
|
||||
/**
|
||||
* Response to StatusRequest
|
||||
*/
|
||||
interface StatusResponse extends Response {
|
||||
body: StatusResponseBody;
|
||||
}
|
||||
/**
|
||||
* Requests a JS Doc comment template for a given position
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue