How to use the botbuilder-lg.DiagnosticSeverity.Information 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 / BotFramework-Composer / Composer / packages / tools / language-servers / language-generation / src / utils.ts View on Github external
while ((match = wordDefinition.exec(lineText))) {
    const matchIndex = match.index || 0;
    if (matchIndex > pos) {
      return undefined;
    } else if (wordDefinition.lastIndex >= pos) {
      return Range.create(line, matchIndex, line, wordDefinition.lastIndex);
    }
  }

  return undefined;
}

const severityMap = {
  [LGDiagnosticSeverity.Error]: DiagnosticSeverity.Error,
  [LGDiagnosticSeverity.Hint]: DiagnosticSeverity.Hint,
  [LGDiagnosticSeverity.Information]: DiagnosticSeverity.Information,
  [LGDiagnosticSeverity.Warning]: DiagnosticSeverity.Warning,
};

export function convertSeverity(severity: LGDiagnosticSeverity): DiagnosticSeverity {
  return severityMap[severity];
}

export function convertDiagnostics(lgDiags: LGDiagnostic[] = [], document: TextDocument, lineOffset = 0): Diagnostic[] {
  const diagnostics: Diagnostic[] = [];
  lgDiags.forEach(diag => {
    const diagnostic: Diagnostic = {
      severity: convertSeverity(diag.Severity),
      range: Range.create(
        Position.create(diag.Range.Start.Line - 1 - lineOffset, diag.Range.Start.Character),
        Position.create(diag.Range.End.Line - 1 - lineOffset, diag.Range.End.Character)
      ),