in src/AzureRMTools.ts [1152:1251]
private updateEditorStateInBackground(): void {
callWithTelemetryAndErrorHandling("updateEditorState", async (actionContext: IActionContext) => {
actionContext.telemetry.suppressIfSuccessful = true;
let isWarning: boolean = false;
let statusBarText: string | undefined;
let isTemplateFile = false;
let templateFileHasParamFile = false;
let isParamFile = false;
let paramFileHasTemplateFile = false;
try {
const activeDocument = vscode.window.activeTextEditor?.document;
if (activeDocument) {
const state = ext.languageServerState;
switch (state) {
case LanguageServerState.Failed:
case LanguageServerState.Stopped:
statusBarText = state === LanguageServerState.Failed ? "$(error) ARM language server failed to start." : "$(error) ARM language server stopped.";
this._paramsStatusBarItem.text = statusBarText;
this._paramsStatusBarItem.command = undefined;
this._paramsStatusBarItem.color = undefined;
this._paramsStatusBarItem.show();
return;
case LanguageServerState.LoadingSchemas:
case LanguageServerState.NotStarted:
case LanguageServerState.Running:
case LanguageServerState.Starting:
break;
default:
assertNever(state);
}
const deploymentTemplate = this.getOpenedDeploymentDocument(activeDocument);
if (deploymentTemplate instanceof DeploymentTemplateDoc) {
isTemplateFile = true;
const paramFileUri = this._mapping.getParameterFile(activeDocument.uri);
if (paramFileUri) {
templateFileHasParamFile = true;
const doesParamFileExist = await pathExistsNoThrow(paramFileUri);
statusBarText = `Parameter file: ${getFriendlyPathToFile(paramFileUri)}`;
if (!doesParamFileExist) {
statusBarText += " $(error) Not found";
}
} else {
statusBarText = "Select/Create parameter file...";
}
// Add message to indicate if full validation is disabled
const fullValidationOn = deploymentTemplate.templateGraph?.fullValidationStatus.fullValidationEnabled ?? templateFileHasParamFile;
isWarning = !fullValidationOn;
statusBarText = isWarning ?
`$(warning) WARNING: Full template validation off. Add param file or top-level param defaults to enable.` :
statusBarText;
this._paramsStatusBarItem.command = "azurerm-vscode-tools.selectParameterFile";
this._paramsStatusBarItem.text = statusBarText;
} else if (deploymentTemplate instanceof DeploymentParametersDoc) {
// Current file is a parameter file
isParamFile = true;
const templateFileUri = this._mapping.getTemplateFile(activeDocument.uri);
if (templateFileUri) {
paramFileHasTemplateFile = true;
const doesTemplateFileExist = await pathExistsNoThrow(templateFileUri);
statusBarText = `Template file: ${getFriendlyPathToFile(templateFileUri)}`;
if (!doesTemplateFileExist) {
statusBarText += " $(error) Not found";
}
} else {
statusBarText = "No template file selected";
}
this._paramsStatusBarItem.command = "azurerm-vscode-tools.openTemplateFile";
this._paramsStatusBarItem.text = statusBarText;
}
this._paramsStatusBarItem.color = isWarning ? new vscode.ThemeColor('problemsWarningIcon.foreground') : undefined;
}
} finally {
if (statusBarText) {
this._paramsStatusBarItem.show();
} else {
this._paramsStatusBarItem.hide();
}
setContext({
isTemplateFile,
hasParamFile: templateFileHasParamFile,
isParamFile: isParamFile,
hasTemplateFile: paramFileHasTemplateFile
});
}
}).catch(err => {
assert.fail("updateEditorStateInBackground shouldn't throw");
});
}