Skip to content

Commit

Permalink
added API to check extension status
Browse files Browse the repository at this point in the history
  • Loading branch information
a2975667 committed Jul 23, 2020
1 parent 08d8e44 commit 2499a1e
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -233,7 +245,7 @@ export function activate(context: ExtensionContext) {
onExtensionChange(extensions.all);
});
}

clientIsReady = true;
});
languages.setLanguageConfiguration('xml', getIndentationRules());
languages.setLanguageConfiguration('xsl', getIndentationRules());
Expand Down Expand Up @@ -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;
}
};

Expand Down

0 comments on commit 2499a1e

Please sign in to comment.