How to use the lsif-protocol.Edge function in lsif-protocol

To help you get started, we’ve selected a few lsif-protocol examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / lsif-node / util / src / validate.ts View on Github external
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`);
}
github microsoft / lsif-node / util / src / visualize.ts View on Github external
.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`;
			}
		}
	});