mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-22 17:48:56 +01:00
Load html data using new API per Microsoft/vscode-html-languageservice#45
This commit is contained in:
@@ -3,56 +3,8 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ITagSet, IAttributeSet, HTMLTagSpecification } from 'vscode-html-languageservice';
|
||||
import { HTMLData } from 'vscode-html-languageservice';
|
||||
|
||||
interface Tag {
|
||||
label: string;
|
||||
description: string;
|
||||
attributes: Attribute[];
|
||||
}
|
||||
interface Attribute {
|
||||
label: string;
|
||||
description: string;
|
||||
}
|
||||
interface RawTagSet {
|
||||
tags: Tag[];
|
||||
}
|
||||
interface RawAttributeSet {
|
||||
attributes: Attribute[];
|
||||
}
|
||||
|
||||
export function parseTagSet(source: string): ITagSet {
|
||||
const tagSet: ITagSet = {};
|
||||
|
||||
let rawTagSet: RawTagSet;
|
||||
try {
|
||||
rawTagSet = JSON.parse(source);
|
||||
} catch (err) {
|
||||
return {};
|
||||
}
|
||||
|
||||
rawTagSet.tags.forEach(c => {
|
||||
tagSet[c.label] = new HTMLTagSpecification(c.description, c.attributes.map(a => a.label));
|
||||
});
|
||||
|
||||
return tagSet;
|
||||
}
|
||||
|
||||
export function parseAttributes(source: string): IAttributeSet {
|
||||
const attributeSet: IAttributeSet = {};
|
||||
|
||||
let rawAttributeSet: RawAttributeSet;
|
||||
try {
|
||||
rawAttributeSet = JSON.parse(source);
|
||||
} catch (err) {
|
||||
return {};
|
||||
}
|
||||
|
||||
rawAttributeSet.attributes.forEach(ag => {
|
||||
attributeSet[ag.label] = {
|
||||
...ag
|
||||
};
|
||||
});
|
||||
|
||||
return attributeSet;
|
||||
export function parseHTMLData(source: string): HTMLData {
|
||||
return JSON.parse(source);
|
||||
}
|
||||
Reference in New Issue
Block a user