How to use the botbuilder-lg.LGParser.parse 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.

github microsoft / BotFramework-Composer / Composer / packages / tools / language-servers / language-generation / src / utils.ts View on Github external
export function updateTemplateInContent(content: string, { Name, Parameters = [], Body }: Template): string {
  const resource = LGParser.parse(content);
  return resource.updateTemplate(Name, Name, Parameters, Body).toString();
}
github microsoft / BotFramework-Composer / Composer / packages / client / src / utils / lgUtil.ts View on Github external
export function parse(content: string, id = ''): LGTemplate[] {
  const resource = LGParser.parse(content, id);
  return get(resource, 'templates', []);
}
github microsoft / BotFramework-Composer / Composer / packages / tools / language-servers / language-generation / src / utils.ts View on Github external
export function getLGResources(content: string): LGResource {
  return LGParser.parse(content, ' ');
}
github microsoft / BotFramework-Composer / Composer / packages / lib / indexers / src / lgIndexer.ts View on Github external
function parse(content: string, id: string): LgTemplate[] {
  const resource = LGParser.parse(content, id);
  const templates = resource.templates.map(t => {
    return {
      name: t.name,
      body: t.body,
      parameters: t.parameters,
      range: {
        startLineNumber: get(t, 'parseTree.start.line', 0),
        endLineNumber: get(t, 'parseTree.stop.line', 0),
      },
    };
  });
  return templates;
}
github microsoft / BotFramework-Composer / Composer / packages / client / src / utils / lgUtil.ts View on Github external
export function removeTemplate(content: string, templateName: string): string {
  const resource = LGParser.parse(content);
  return resource.deleteTemplate(templateName).toString();
}
github microsoft / BotFramework-Composer / Composer / packages / client / src / utils / lgUtil.ts View on Github external
export function getTemplate(content: string, templateName: string): LGTemplate | undefined {
  const resource = LGParser.parse(content);
  return resource.templates.find(t => t.name === templateName);
}
github microsoft / BotFramework-Composer / Composer / packages / client / src / utils / lgUtil.ts View on Github external
export function addTemplateAnyway(
  content: string,
  { name = 'TemplateName', parameters = [], body = '-TemplateBody' }: Template
): string {
  const resource = LGParser.parse(content);
  const newName = increaseNameUtilNotExist(resource.templates, name);

  return resource.addTemplate(newName, parameters, body).toString();
}
github microsoft / BotFramework-Composer / Composer / packages / tools / language-servers / language-generation / src / utils.ts View on Github external
export function getTemplatePositionOffset(content: string, { Name, Parameters = [], Body }: Template): number {
  const resource = LGParser.parse(content).updateTemplate(Name, Name, Parameters, Body);
  const template = resource.Templates.find(item => item.Name === Name);
  return get(template, 'ParseTree._start.line', 0);
}