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
|
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", () => {
|
describe("onMessage", () => {
|
||||||
|
@ -220,6 +233,7 @@ namespace ts.server {
|
||||||
CommandNames.Saveto,
|
CommandNames.Saveto,
|
||||||
CommandNames.SignatureHelp,
|
CommandNames.SignatureHelp,
|
||||||
CommandNames.SignatureHelpFull,
|
CommandNames.SignatureHelpFull,
|
||||||
|
CommandNames.Status,
|
||||||
CommandNames.TypeDefinition,
|
CommandNames.TypeDefinition,
|
||||||
CommandNames.ProjectInfo,
|
CommandNames.ProjectInfo,
|
||||||
CommandNames.ReloadProjects,
|
CommandNames.ReloadProjects,
|
||||||
|
|
|
@ -71,6 +71,7 @@ namespace ts.server.protocol {
|
||||||
SignatureHelp = "signatureHelp",
|
SignatureHelp = "signatureHelp",
|
||||||
/* @internal */
|
/* @internal */
|
||||||
SignatureHelpFull = "signatureHelp-full",
|
SignatureHelpFull = "signatureHelp-full",
|
||||||
|
Status = "status",
|
||||||
TypeDefinition = "typeDefinition",
|
TypeDefinition = "typeDefinition",
|
||||||
ProjectInfo = "projectInfo",
|
ProjectInfo = "projectInfo",
|
||||||
ReloadProjects = "reloadProjects",
|
ReloadProjects = "reloadProjects",
|
||||||
|
@ -216,6 +217,24 @@ namespace ts.server.protocol {
|
||||||
projectFileName?: string;
|
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
|
* Requests a JS Doc comment template for a given position
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1703,6 +1703,10 @@ namespace ts.server {
|
||||||
}
|
}
|
||||||
|
|
||||||
private handlers = createMapFromTemplate<(request: protocol.Request) => HandlerResponse>({
|
private handlers = createMapFromTemplate<(request: protocol.Request) => HandlerResponse>({
|
||||||
|
[CommandNames.Status]: () => {
|
||||||
|
const response: protocol.StatusResponseBody = { version };
|
||||||
|
return this.requiredResponse(response);
|
||||||
|
},
|
||||||
[CommandNames.OpenExternalProject]: (request: protocol.OpenExternalProjectRequest) => {
|
[CommandNames.OpenExternalProject]: (request: protocol.OpenExternalProjectRequest) => {
|
||||||
this.projectService.openExternalProject(request.arguments, /*suppressRefreshOfInferredProjects*/ false);
|
this.projectService.openExternalProject(request.arguments, /*suppressRefreshOfInferredProjects*/ false);
|
||||||
// TODO: GH#20447 report errors
|
// TODO: GH#20447 report errors
|
||||||
|
|
|
@ -4905,6 +4905,7 @@ declare namespace ts.server.protocol {
|
||||||
Rename = "rename",
|
Rename = "rename",
|
||||||
Saveto = "saveto",
|
Saveto = "saveto",
|
||||||
SignatureHelp = "signatureHelp",
|
SignatureHelp = "signatureHelp",
|
||||||
|
Status = "status",
|
||||||
TypeDefinition = "typeDefinition",
|
TypeDefinition = "typeDefinition",
|
||||||
ProjectInfo = "projectInfo",
|
ProjectInfo = "projectInfo",
|
||||||
ReloadProjects = "reloadProjects",
|
ReloadProjects = "reloadProjects",
|
||||||
|
@ -5006,6 +5007,21 @@ declare namespace ts.server.protocol {
|
||||||
file: string;
|
file: string;
|
||||||
projectFileName?: 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
|
* Requests a JS Doc comment template for a given position
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue