in server/src/graphStore.ts [692:721]
public declarations(uri: string, position: lsp.Position): lsp.Location | lsp.Location[] | undefined {
const ranges = this.findRange(this.toDatabase(uri), position);
if (ranges === undefined) {
return undefined;
}
const findDeclaration = (range: RangeResult): lsp.Location | lsp.Location[] | undefined => {
const [declarationResult] = this.getResultForId(range.id, EdgeLabels.textDocument_declaration);
if (declarationResult === undefined) {
return undefined;
}
const result: lsp.Location[] = [];
const queryResult: LocationResult[] = this.findRangeFromResult.all({ id: declarationResult.id });
if (queryResult && queryResult.length > 0) {
for(let item of queryResult) {
result.push(this.createLocation(item));
}
}
return result;
};
for (const range of ranges) {
const result = findDeclaration(range);
if (result !== undefined) {
return result;
}
}
return undefined;
}