in tsc/src/common/graph.ts [450:512]
public item(from: DeclarationResult | DefinitionResult | TypeDefinitionResult | ReferenceResult | ImplementationResult, to: Vertex[], shard: Document | Project, property?: ItemEdgeProperties.declarations | ItemEdgeProperties.definitions | ItemEdgeProperties.references): item {
if (to.length === 0) {
const result: item = {
id: this.nextId(),
type: ElementTypes.edge,
label: EdgeLabels.item,
outV: from.id,
inVs: [],
shard: shard.id
};
// We have an empty to array. So treat the empty set as references or use the property provided.
if (from.label === 'referenceResult') {
result.property = property !== undefined ? property : ItemEdgeProperties.references;
}
return result;
}
const toKind = to[0].label;
const result: item = {
id: this.nextId(),
type: ElementTypes.edge,
label: EdgeLabels.item,
outV: from.id,
inVs: to.map(v => v.id),
shard: shard.id
};
switch (from.label) {
case 'declarationResult':
break;
case 'definitionResult':
break;
case 'referenceResult':
switch (toKind) {
case VertexLabels.range:
if (property === undefined) {
throw new Error(`An item edge pointing to ranges needs to define a property.`);
}
result.property = property;
break;
case VertexLabels.referenceResult:
result.property = ItemEdgeProperties.referenceResults;
break;
case VertexLabels.moniker:
result.property = ItemEdgeProperties.referenceLinks;
break;
default:
throw new Error('Should never happen.');
}
break;
case 'implementationResult':
switch (toKind) {
case VertexLabels.implementationResult:
result.property = ItemEdgeProperties.implementationResults;
break;
case VertexLabels.moniker:
result.property = ItemEdgeProperties.implementationLinks;
break;
}
break;
default:
throw new Error('Shouldn\'t happen');
}
return result;
}