How to use the botbuilder-lg.Templates.parseText function in botbuilder-lg

To help you get started, we’ve selected a few botbuilder-lg examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / BotBuilder-Samples / experimental / adaptive-tool / src / lg / providers / diagnostics.ts View on Github external
function updateDiagnostics(document: vscode.TextDocument, collection: vscode.DiagnosticCollection): void {
    if(!util.isLgFile(document.fileName) ) {
        collection.clear();
        return;
    }
    
    const engine: Templates = Templates.parseText(document.getText(), document.uri.fsPath);
    const diagnostics = engine.diagnostics;

    TemplatesStatus.templatesMap.set(document.uri.fsPath, new TemplatesEntity(document.uri, engine));

    const vscodeDiagnostics: vscode.Diagnostic[] = [];
    const confDiagLevel = vscode.workspace.getConfiguration().get('LG.Expression.ignoreUnknownFunction');
    const confCustomFuncListSetting: string = vscode.workspace.getConfiguration().get('LG.Expression.customFunctionList');
    let customFunctionList: string[] = [];
    if (confCustomFuncListSetting.length >= 1) {
        customFunctionList = confCustomFuncListSetting.split(",").map(u => u.trim());
    }
    diagnostics.forEach(u => {
        const isUnkownFuncDiag: boolean = u.message.includes("it's not a built-in function or a custom function");
        if (isUnkownFuncDiag === true){
            let ignored = false;
            const funcName = extractFuncName(u.message);
github microsoft / BotBuilder-Samples / experimental / generation / generator / packages / library / src / mergeAssets.ts View on Github external
async function changeEntityEnumLG(oldPath: string, oldFileList: string[], newFileList: string[], mergedPath: string, filename: string, feedback: Feedback): Promise {
    let oldFilePath = oldFileList.filter(file => file.match(filename))[0]
    let oldText = await fs.readFile(oldFilePath, 'utf8')
    let oldStatements = oldText.split(os.EOL)
    let oldTemplates = Templates.parseText(oldText)

    let newFilePath = newFileList.filter(file => file.match(filename))[0]
    let newText = await fs.readFile(newFilePath, 'utf8')
    let newStatements = newText.split(os.EOL)
    let newTemplates = Templates.parseText(newText)

    let mergedStatements: string[] = []

    let recordPart: object[] = []

    for (let oldTemplate of oldTemplates) {
        let oldBody = oldTemplate.templateBodyParseTree
        if (oldBody === undefined) {
            continue
        }
        if (oldBody instanceof SwitchCaseBodyContext) {
            for (let newTemplate of newTemplates) {
                if (newTemplate.name !== oldTemplate.name) {
                    continue
                }
                let newBody = newTemplate.templateBodyParseTree
github microsoft / BotBuilder-Samples / experimental / generation / generator / packages / library / src / mergeAssets.ts View on Github external
async function changeEntityEnumLG(oldPath: string, oldFileList: string[], newFileList: string[], mergedPath: string, filename: string, feedback: Feedback): Promise {
    let oldFilePath = oldFileList.filter(file => file.match(filename))[0]
    let oldText = await fs.readFile(oldFilePath, 'utf8')
    let oldStatements = oldText.split(os.EOL)
    let oldTemplates = Templates.parseText(oldText)

    let newFilePath = newFileList.filter(file => file.match(filename))[0]
    let newText = await fs.readFile(newFilePath, 'utf8')
    let newStatements = newText.split(os.EOL)
    let newTemplates = Templates.parseText(newText)

    let mergedStatements: string[] = []

    let recordPart: object[] = []

    for (let oldTemplate of oldTemplates) {
        let oldBody = oldTemplate.templateBodyParseTree
        if (oldBody === undefined) {
            continue
        }
        if (oldBody instanceof SwitchCaseBodyContext) {