Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function readInput(toolOutput: LSIF.Element[]): void {
const outputMessage: string = 'Reading input...';
process.stdout.write(`${outputMessage}\r`);
for (const object of toolOutput) {
if (object.type === LSIF.ElementTypes.edge) {
const edge: LSIF.Edge = object as LSIF.Edge;
const id: string = edge.id.toString();
edges[id] = new Element(edge);
if (edge.outV === undefined) {
errors.push(new Error(edge, `requires property "outV"`));
edges[id].invalidate();
}
if (!LSIF.Edge.is11(edge) && !LSIF.Edge.is1N(edge)) {
errors.push(new Error(edge, `requires property "inV" or "inVs"`));
edges[id].invalidate();
} else {
checkVertexBeforeEdge(edge);
}
} else if (object.type === 'vertex') {
vertices[object.id.toString()] = new Element(object);
} else {
errors.push(new Error(object, `unknown element type`));
}
}
console.log(`${outputMessage} done`);
}
.forEach((key: string) => {
const edge: LSIF.Edge = edges[key] as LSIF.Edge;
if (LSIF.Edge.is11(edge)) {
digraph += ` ${edge.outV} -> ${edge.inV} [label="${edge.label}"]\n`;
} else {
for (const inV of edge.inVs) {
digraph += ` ${edge.outV} -> ${inV} [label="${edge.label}"]\n`;
}
}
});