From 2499a1eda6b85c0b738c7f04c09efba8033650af Mon Sep 17 00:00:00 2001 From: Ti-Chung Cheng Date: Thu, 23 Jul 2020 13:54:24 -0500 Subject: [PATCH] added API to check extension status --- src/extension.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/extension.ts b/src/extension.ts index 3765fd59..b3e362c5 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -110,6 +110,17 @@ export interface XMLExtensionApi { * @returns None */ removeXMLFileAssociations(fileAssociations: XMLFileAssociation[]): void; + /** + * Returns the status of the Language Client + * + * @remarks + * An example is to call this API: + * ```ts + * isReady() + * ``` + * @returns Boolean + */ + isReady(): boolean; } namespace TagCloseRequest { @@ -196,6 +207,7 @@ export function activate(context: ExtensionContext) { let languageClient = new LanguageClient('xml', 'XML Support', serverOptions, clientOptions); let toDispose = context.subscriptions; let disposable = languageClient.start(); + let clientIsReady = false; toDispose.push(disposable); languageClient.onReady().then(() => { //Detect JDK configuration changes @@ -233,7 +245,7 @@ export function activate(context: ExtensionContext) { onExtensionChange(extensions.all); }); } - + clientIsReady = true; }); languages.setLanguageConfiguration('xml', getIndentationRules()); languages.setLanguageConfiguration('xsl', getIndentationRules()); @@ -284,6 +296,10 @@ export function activate(context: ExtensionContext) { }); languageClient.sendNotification(DidChangeConfigurationNotification.type, { settings: getXMLSettings(requirements.java_home) }); onConfigurationChange(); + }, + // return if Language Client is ready + isReady: () => { + return clientIsReady; } };