in src/languageservice/serviceclient.ts [164:207]
public initializeForPlatform(platformInfo: PlatformInformation, context: ExtensionContext): Promise<ServerInitializationResult> {
return new Promise<ServerInitializationResult>( (resolve, reject) => {
this._logger.appendLine(Constants.commandsNotAvailableWhileInstallingTheService);
this._logger.appendLine();
this._logger.append(`Platform-------------: ${platformInfo.toString()}`);
if (!platformInfo.isValidRuntime) {
this._logger.appendLine();
this._logger.append('Platform invalid');
Utils.showErrorMsg(Constants.unsupportedPlatformErrorMessage);
Telemetry.sendTelemetryEvent('UnsupportedPlatform', {platform: platformInfo.toString()} );
reject('Invalid Platform');
} else {
if (platformInfo.runtimeId) {
this._logger.appendLine(` (${getRuntimeDisplayName(platformInfo.runtimeId)})`);
} else {
this._logger.appendLine();
}
this._logger.appendLine();
this._server.getServerPath(platformInfo.runtimeId).then(async serverPath => {
this._logger.appendLine();
if (serverPath === undefined) {
// Check if the service already installed and if not open the output channel to show the logs
if (_channel !== undefined) {
_channel.show();
}
let installedServerPath = await this._server.downloadServerFiles(platformInfo.runtimeId);
this.initializeLanguageClient(installedServerPath, context);
await this._client.onReady();
resolve(new ServerInitializationResult(true, true, installedServerPath));
} else {
this.initializeLanguageClient(serverPath, context);
await this._client.onReady();
resolve(new ServerInitializationResult(false, true, serverPath));
}
}).catch(err => {
Utils.logDebug(Constants.serviceLoadingFailed + ' ' + err );
Utils.showErrorMsg(Constants.serviceLoadingFailed);
Telemetry.sendTelemetryEvent('ServiceInitializingFailed');
reject(err);
});
}
});
}