in server/src/jsonStore.ts [533:581]
public references(uri: string, position: lsp.Position, context: lsp.ReferenceContext): lsp.Location[] | undefined {
let ranges = this.findRangesFromPosition(this.toDatabase(uri), position);
if (ranges === undefined) {
return undefined;
}
const findReferences = (result: lsp.Location[], dedupLocations: Set<string>, dedupMonikers: Set<string>, range: Range): void => {
const resultPath = this.getResultPath(range.id, this.out.references);
if (resultPath.result === undefined) {
return;
}
const mostSpecificMoniker = this.getMostSpecificMoniker(resultPath);
const monikers: Moniker[] = mostSpecificMoniker !== undefined ? [mostSpecificMoniker] : [];
this.resolveReferenceResult(result, dedupLocations, monikers, resultPath.result.value, context);
for (const moniker of monikers) {
if (dedupMonikers.has(moniker.key)) {
continue;
}
dedupMonikers.add(moniker.key);
const matchingMonikers = this.indices.monikers.get(moniker.key);
if (matchingMonikers !== undefined) {
for (const matchingMoniker of matchingMonikers) {
if (moniker.id === matchingMoniker.id) {
continue;
}
const vertices = this.findVerticesForMoniker(matchingMoniker);
if (vertices !== undefined) {
for (const vertex of vertices) {
const resultPath = this.getResultPath(vertex.id, this.out.references);
if (resultPath.result === undefined) {
continue;
}
this.resolveReferenceResult(result, dedupLocations, monikers, resultPath.result.value, context);
}
}
}
}
}
};
const result: lsp.Location[] = [];
const dedupLocations: Set<string> = new Set();
const dedupMonikers: Set<string> = new Set();
for (const range of ranges) {
findReferences(result, dedupLocations, dedupMonikers, range);
}
return result;
}