UNPKG

gauge-ts

Version:
33 lines (32 loc) 1.25 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.StepPositionsProcessor = void 0; const messages_pb_1 = require("../gen/messages_pb"); const spec_pb_1 = require("../gen/spec_pb"); const StepRegistry_1 = require("../models/StepRegistry"); class StepPositionsProcessor { process(req) { const positions = StepRegistry_1.default.getStepPositions(req.getFilepath()); return this.createStepPostionsResponse(positions); } createStepPostionsResponse(positions) { const res = new messages_pb_1.StepPositionsResponse(); res.setError(""); res.setSteppositionsList(positions.map((p) => { const sp = new messages_pb_1.StepPositionsResponse.StepPosition(); sp.setStepvalue(p.stepValue); sp.setSpan(this.getSpan(p.span)); return sp; })); return res; } getSpan(range) { const span = new spec_pb_1.Span(); span.setStart(range.getStart().getLine()); span.setEnd(range.getEnd().getLine()); span.setStartchar(range.getStart().getChar()); span.setEndchar(range.getEnd().getChar()); return span; } } exports.StepPositionsProcessor = StepPositionsProcessor;