Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(completionContributions: JSONWorkerContribution[]) {
this.jsonSchemaService = new JSONSchemaService(null, {
resolveRelativePath: (relativePath: string, resource: string) => {
return path.resolve(resource, relativePath);
}
}, null);
this.yamlValidation = new YAMLValidation(this.jsonSchemaService);
this.yamlValidation.configure({ validate: true });
this.yamlDocumentSymbols = new YAMLDocumentSymbols();
this.yamlCompletion = new YAMLCompletion(this.jsonSchemaService, completionContributions);
// enables auto completion suggestions for tags like !include ()
// commeted because they end up at the top of the list which does not look nice :-)
// this.yamlCompletion.configure(null, this.getValidYamlTags());
this.yamlHover = new YAMLHover(this.jsonSchemaService);
this.yamlFormatter = new YAMLFormatter();
}
export function getLanguageService(workspaceContext, promiseConstructor?): LanguageService {
let promise = promiseConstructor || Promise;
let jsonSchemaService = new JSONSchemaService(null, workspaceContext, null);
var jsonPath = path.join(__dirname, '..', 'lovelace-schema', 'ui-lovelace.json');
var sc = fs.readFileSync(jsonPath,"utf-8");
var schema = JSON.parse(sc);
jsonSchemaService.setSchemaContributions({
schemas: {
"http://schema.ha.com/lovelace": schema
},
schemaAssociations:{
"**/ui-lovelace.yaml": ["http://schema.ha.com/lovelace"]
}
});
let yamlvalidation = new YAMLValidation(jsonSchemaService, promise);
yamlvalidation.configure({