mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -05:00
e435c2be15
Co-authored-by: Ryan Dahl <ry@tinyclouds.org>
31 lines
834 B
TypeScript
31 lines
834 B
TypeScript
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
|
import { DiagnosticItem } from "../diagnostics.ts";
|
|
import { sendSync } from "./dispatch_json.ts";
|
|
|
|
export function formatDiagnostics(items: DiagnosticItem[]): string {
|
|
return sendSync("op_format_diagnostic", { items });
|
|
}
|
|
|
|
export interface Location {
|
|
filename: string;
|
|
|
|
line: number;
|
|
|
|
column: number;
|
|
}
|
|
|
|
export function applySourceMap(location: Location): Location {
|
|
const { filename, line, column } = location;
|
|
// On this side, line/column are 1 based, but in the source maps, they are
|
|
// 0 based, so we have to convert back and forth
|
|
const res = sendSync("op_apply_source_map", {
|
|
filename,
|
|
line: line - 1,
|
|
column: column - 1
|
|
});
|
|
return {
|
|
filename: res.filename,
|
|
line: res.line + 1,
|
|
column: res.column + 1
|
|
};
|
|
}
|