import * as fs from "fs" ; import VError = require ( "verror" ) ; import * as vscode from "vscode" ; import CssClassDefinition from "./common/css-class-definition" ; import IParseEngine from "./parse-engines/common/parse-engine" ; import ISimpleTextDocument from "./parse-engines/common/simple-text-document" ; import ParseEngineRegistry from "./parse-engines/parse-engine-registry" ; async function readFile ( file ) { return new Promise < string > ( ( resolve , reject ) => { fs . readFile ( file , ( err , data ) => { if ( err ) { reject ( err ) ; } resolve ( data . toString ( ) ) ; } ) ; } ) ; } async function createSimpleTextDocument ( uri ) { const text = await readFile ( uri . fsPath ) ; const simpleDocument = { languageId : uri . fsPath . split ( "." ) . pop ( ) || "" , getText ( ) { return text ; } , } ; return simpleDocument ; } class ParseEngineGateway { public static async callParser ( uri ) { const textDocument = await createSimpleTextDocument ( uri ) ; const parseEngine = ParseEngineRegistry . getParseEngine ( textDocument . languageId ) ; const cssClassDefinitions = await parseEngine . parse ( textDocument ) ; return cssClassDefinitions ; } } export default ParseEngineGateway ;