UNPKG

@atomist/automation-client

Version:

Atomist API for software low-level client

25 lines 787 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const File_1 = require("../../project/File"); /** * Find the given source location within this project * @param {string} f file info: Path or File * @param {string} content * @param {number} offset * @return {SourceLocation} */ function toSourceLocation(f, content, offset) { if (!content || offset < 0 || offset > content.length - 1) { return undefined; } const lines = content.substr(0, offset) .split("\n"); return { path: File_1.isFile(f) ? f.path : f, lineFrom1: lines.length, columnFrom1: lines[lines.length - 1].length + 1, offset, }; } exports.toSourceLocation = toSourceLocation; //# sourceMappingURL=sourceLocationUtils.js.map