Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
),