private findRangesFromPosition()

in server/src/jsonStore.ts [667:700]


	private findRangesFromPosition(file: string, position: lsp.Position): Range[] | undefined {
		const value = this.indices.documents.get(file);
		if (value === undefined) {
			return undefined;
		}
		let result: Range[] = [];
		for (const document of value.documents) {
			const id = document.id;
			let contains = this.out.contains.get(id);
			if (contains === undefined || contains.length === 0) {
				return undefined;
			}

			let candidate: Range | undefined;
			for (let item of contains) {
				if (item.label !== VertexLabels.range) {
					continue;
				}
				if (JsonStore.containsPosition(item, position)) {
					if (!candidate) {
						candidate = item;
					} else {
						if (JsonStore.containsRange(candidate, item)) {
							candidate = item;
						}
					}
				}
			}
			if (candidate !== undefined) {
				result.push(candidate);
			}
		}
		return result.length > 0 ? result : undefined;
	}