Update service and adopt HTML provider interface

This commit is contained in:
Pine Wu
2019-01-27 22:22:50 -08:00
parent 1b57516818
commit 3815bb15fd
7 changed files with 49 additions and 53 deletions

View File

@@ -0,0 +1,29 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IHTMLDataProvider, HTMLDataProvider } from 'vscode-html-languageservice';
import * as fs from 'fs';
export function getDataProviders(dataPaths?: string[]): IHTMLDataProvider[] {
if (!dataPaths) {
return [];
}
const providers: IHTMLDataProvider[] = [];
dataPaths.forEach((path, i) => {
try {
if (fs.existsSync(path)) {
const htmlData = JSON.parse(fs.readFileSync(path, 'utf-8'));
providers.push(new HTMLDataProvider(`customProvider${i}`, htmlData));
}
} catch (err) {
console.log(`Failed to laod tag from ${path}`);
}
});
return providers;
}