[Code] added a language server launch failed status (#45753)

This commit is contained in:
Yulong 2019-09-18 13:49:29 +08:00 committed by GitHub
parent 25d01ec7e3
commit 265fcd7e89
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 25 additions and 0 deletions

View file

@ -11,6 +11,7 @@ export enum LanguageServerStatus {
INSTALLING,
READY, // installed but not running
RUNNING,
LAUNCH_FAILED,
}
export interface LanguageServer {

View file

@ -14,6 +14,7 @@ export enum RepoFileStatus {
REVISION_NOT_INDEXED = 'Current revision is not indexed.',
LANG_SERVER_NOT_INSTALLED = 'Install additional language server to support current file.',
FILE_IS_TOO_BIG = 'Current file is too big.',
LANG_SERVER_LAUNCH_FAILED = 'Language server failed to launch',
}
export enum Severity {
@ -84,6 +85,12 @@ export const RepoFileStatusText = {
defaultMessage: 'Current file is covered by dedicated language server.',
}
),
[RepoFileStatus.LANG_SERVER_LAUNCH_FAILED]: i18n.translate(
'xpack.code.repoFileStatus.langServerLaunchFailed',
{
defaultMessage: 'Language server launch failed.',
}
),
};
export enum CTA {
@ -124,5 +131,6 @@ export interface StatusReport {
langServerStatus?:
| RepoFileStatus.LANG_SERVER_IS_INITIALIZING
| RepoFileStatus.LANG_SERVER_NOT_INSTALLED
| RepoFileStatus.LANG_SERVER_LAUNCH_FAILED
| RepoFileStatus.LANG_SERVER_INITIALIZED;
}

View file

@ -25,6 +25,7 @@ export abstract class AbstractLauncher implements ILanguageServerLauncher {
protected readonly log: Logger;
private spawnTimes: number = 0;
private launchReject?: (reason?: any) => void;
launchFailed: boolean = false;
protected constructor(
readonly name: string,
readonly targetHost: string,
@ -140,6 +141,7 @@ export abstract class AbstractLauncher implements ILanguageServerLauncher {
'Launch language server failed.'
);
this.launchReject!(ServerStartFailed);
this.launchFailed = true;
proxy.setError(ServerStartFailed);
this.log.warn(`spawned program ${this.spawnTimes} times, mark this proxy unusable.`);
}

View file

@ -59,6 +59,8 @@ class LauncherStub implements ILanguageServerLauncher {
): Promise<ILanguageServerHandler> {
return Promise.resolve(launcherSpy(builtinWorkspace, maxWorkspace, installationPath));
}
launchFailed: boolean = false;
}
TYPESCRIPT.launcher = LauncherStub;

View file

@ -197,6 +197,9 @@ export class LanguageServerController implements ILanguageServerHandler {
// installed, but is it running?
if (status === LanguageServerStatus.READY) {
const ls = this.languageServers.find(d => d.definition === def);
if (ls && ls.launcher.launchFailed) {
return LanguageServerStatus.LAUNCH_FAILED;
}
if (ls && ls.launcher.running) {
return LanguageServerStatus.RUNNING;
}

View file

@ -11,6 +11,7 @@ import { ILanguageServerHandler } from './proxy';
export interface ILanguageServerLauncher {
running: boolean;
launch(builtinWorkspace: boolean, maxWorkspace: number): Promise<ILanguageServerHandler>;
launchFailed: boolean;
}
export type LauncherConstructor = new (

View file

@ -89,6 +89,13 @@ export function statusRoute(router: CodeServerRouter, codeServices: CodeServices
}
} else {
const def = dedicated || generic;
if (
(await lspService.languageServerStatus(endpoint, { langName: def!.name })) ===
LanguageServerStatus.LAUNCH_FAILED
) {
report.langServerStatus = RepoFileStatus.LANG_SERVER_LAUNCH_FAILED;
return;
}
const state = await lspService.initializeState(endpoint, { repoUri, revision });
const initState = state[def!.name];
report.langServerStatus =

View file

@ -4219,6 +4219,7 @@
"xpack.code.repoFileStatus.langserverType.noneMessage": "当前文件不受任何语言服务器支持。",
"xpack.code.repoFileStatus.langserverType.genericMessage": "当前文件仅由常规语言服务器支持。",
"xpack.code.repoFileStatus.langserverType.dedicatedMessage": "当前文件由专用语言服务器支持。",
"xpack.code.repoFileStatus.langServerLaunchFailed": "语言服务器启动失败。",
"xpack.code.searchBar.addRepoPlaceholder": "搜索以添加存储库",
"xpack.code.searchBar.addToScopeDescription": "将索引的存储库添加到搜索范围",
"xpack.code.searchBar.applyAndCloseButtonLabel": "应用并关闭",