Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const errors = diags.map(d => {
// Convert lines to zero-based to accomodate protocol
const startPosition = types.Position.create(d.start.line - 1, d.start.offset - 1)
const endPosition = types.Position.create(d.end.line - 1, d.end.offset - 1)
const range = types.Range.create(startPosition, endPosition)
const ret: types.Diagnostic = {
// type: null,
code: d.code,
message: d.text,
range,
severity: types.DiagnosticSeverity.Error,
}
return ret
})
export function intoCode(type: Type): types.DiagnosticSeverity {
switch (type) {
case "env": return types.DiagnosticSeverity.Error;
case "parser": return types.DiagnosticSeverity.Error;
case "type": return types.DiagnosticSeverity.Error;
case "unknown": return types.DiagnosticSeverity.Error;
case "warning": return types.DiagnosticSeverity.Warning;
default: throw new Error(`: ${type}`);
}
}
}
export function intoCode(type: Type): types.DiagnosticSeverity {
switch (type) {
case "env": return types.DiagnosticSeverity.Error;
case "parser": return types.DiagnosticSeverity.Error;
case "type": return types.DiagnosticSeverity.Error;
case "unknown": return types.DiagnosticSeverity.Error;
case "warning": return types.DiagnosticSeverity.Warning;
default: throw new Error(`: ${type}`);
}
}
}
function translateSeverity(typescript, severity) {
switch (severity) {
case vscode.DiagnosticSeverity.Information:
case vscode.DiagnosticSeverity.Hint:
return typescript.DiagnosticCategory.Message;
case vscode.DiagnosticSeverity.Warning:
return typescript.DiagnosticCategory.Warning;
case vscode.DiagnosticSeverity.Error:
default:
return typescript.DiagnosticCategory.Error;
}
}
function toDisplayParts(text) {
function translateSeverity(
typescript: typeof ts,
severity: vscode.DiagnosticSeverity | undefined
): ts.DiagnosticCategory {
switch (severity) {
case vscode.DiagnosticSeverity.Information:
case vscode.DiagnosticSeverity.Hint:
return typescript.DiagnosticCategory.Message;
case vscode.DiagnosticSeverity.Warning:
return typescript.DiagnosticCategory.Warning;
case vscode.DiagnosticSeverity.Error:
default:
return typescript.DiagnosticCategory.Error;
}
}
function translateSeverity(severity) {
switch (severity) {
case vscode.DiagnosticSeverity.Information:
case vscode.DiagnosticSeverity.Hint:
return ts.DiagnosticCategory.Message;
case vscode.DiagnosticSeverity.Warning:
return ts.DiagnosticCategory.Warning;
case vscode.DiagnosticSeverity.Error:
default:
return ts.DiagnosticCategory.Error;
}
}
//# sourceMappingURL=styled-string-language-service.js.map
function toDiagnostic(marker) {
var range = vscode_languageserver_types_1.Range.create(document.positionAt(marker.getOffset()), document.positionAt(marker.getOffset() + marker.getLength()));
var source = document.languageId;
return {
code: marker.getRule().id,
source: source,
message: marker.getMessage(),
severity: marker.getLevel() === nodes.Level.Warning ? vscode_languageserver_types_1.DiagnosticSeverity.Warning : vscode_languageserver_types_1.DiagnosticSeverity.Error,
range: range
};
}
return entries.filter(function (entry) { return entry.getLevel() !== nodes.Level.Ignore; }).map(toDiagnostic);
function translateSeverity(severity) {
switch (severity) {
case vscode.DiagnosticSeverity.Information:
case vscode.DiagnosticSeverity.Hint:
return ts.DiagnosticCategory.Message;
case vscode.DiagnosticSeverity.Warning:
return ts.DiagnosticCategory.Warning;
case vscode.DiagnosticSeverity.Error:
default:
return ts.DiagnosticCategory.Error;
}
}
//# sourceMappingURL=styled-string-language-service.js.map
function translateSeverity(
typescript: typeof ts,
severity: vscode.DiagnosticSeverity | undefined
): ts.DiagnosticCategory {
switch (severity) {
case vscode.DiagnosticSeverity.Information:
case vscode.DiagnosticSeverity.Hint:
return typescript.DiagnosticCategory.Message;
case vscode.DiagnosticSeverity.Warning:
return typescript.DiagnosticCategory.Warning;
case vscode.DiagnosticSeverity.Error:
default:
return typescript.DiagnosticCategory.Error;
}
}
function translateSeverity(typescript, severity) {
switch (severity) {
case vscode.DiagnosticSeverity.Information:
case vscode.DiagnosticSeverity.Hint:
return typescript.DiagnosticCategory.Message;
case vscode.DiagnosticSeverity.Warning:
return typescript.DiagnosticCategory.Warning;
case vscode.DiagnosticSeverity.Error:
default:
return typescript.DiagnosticCategory.Error;
}
}
function toDisplayParts(text) {