Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
interface VisEdge {
from: number;
to: number;
label: string;
}
interface VisData {
nodes: VisNode[];
edges: VisEdge[];
}
function baseName(uri: string): string {
return path.basename(URI.parse(uri).fsPath);
}
const include: Set = new Set([VertexLabels.document, VertexLabels.range, VertexLabels.resultSet, VertexLabels.referenceResult]);
function filterVertex(element: Vertex): boolean {
return !include.has(element.label);
}
export const create: Create = (writer: Writer): Emitter => {
let data: VisData = {
nodes: [],
edges: []
};
return {
start: () => {
},
emit: (element: Vertex | Edge) => {
if (element.type === 'vertex') {
if (filterVertex(element)) {
private processVertex(vertex: Vertex): void {
this.vertices.all.set(vertex.id, vertex);
switch(vertex.label) {
case VertexLabels.metaData:
this.version = vertex.version;
if (vertex.projectRoot !== undefined) {
this.projectRoot = URI.parse(vertex.projectRoot);
}
break;
case VertexLabels.project:
this.vertices.projects.set(vertex.id, vertex);
break;
case VertexLabels.document:
this.vertices.documents.set(vertex.id, vertex);
this.indices.documents.set(vertex.uri, vertex);
break;
case VertexLabels.range:
this.vertices.ranges.set(vertex.id, vertex);
break;
}
}
public insert(element: Edge | Vertex): void {
if (element.type === ElementTypes.vertex) {
switch (element.label) {
case VertexLabels.metaData:
this.insertMetaData(element);
break;
case VertexLabels.project:
this.insertProject(element);
break;
case VertexLabels.document:
this.insertDocument(element);
break;
case VertexLabels.packageInformation:
this.insertPackageInformation(element);
break;
case VertexLabels.range:
this.insertRange(element);
break;
default:
this.insertVertex(element);
}
} else {
switch(element.label) {
case EdgeLabels.contains:
this.insertContains(element);
break;
public insert(element: Edge | Vertex): void {
if (element.type === ElementTypes.vertex) {
switch(element.label) {
case VertexLabels.metaData:
this.handleMetaData(element);
break;
case VertexLabels.document:
this.documents.set(element.id, element);
break;
case VertexLabels.range:
this.handleRange(element);
break;
case VertexLabels.resultSet:
this.handleResultSet(element);
break;
case VertexLabels.moniker:
this.handleMoniker(element);
break;
case VertexLabels.hoverResult:
this.handleHover(element);
break;
case VertexLabels.declarationResult:
this.handleDeclarationResult(element);