ridx_format/workspace/notes.rs
1/*
2 * rust-intelligence — Ultra-fast, zero-memory code intelligence for Rust
3 * Copyright (c) 2026 Alexander Panasenko
4 *
5 * Contact: alex@prod.codes
6 * Author: https://prod.codes/about/
7 * Project: https://github.com/alex09x/rust-intelligence
8 * SPDX-License-Identifier: MIT OR Apache-2.0
9 */
10
11//! Notes (format version 4) looked up across the workspace's shards.
12
13use super::WorkspaceIndex;
14use crate::reader::ResolvedDefinition;
15
16impl WorkspaceIndex {
17 /// The `kind` note whose span starts at `(line, col)` of `file` (an absolute or workspace path).
18 pub fn note_at(&self, file: &str, line: u32, col: u32, kind: u32) -> Option<&str> {
19 self.resolved_reader_file_ids(file).into_iter().find_map(|(idx, file_id)| self.readers.get(idx)?.note_at(file_id, line, col, kind))
20 }
21
22 /// The `kind` note at the name of definition `d`, read from the shard that defines it.
23 pub fn note_at_definition(&self, d: &ResolvedDefinition<'_>, kind: u32) -> Option<&str> {
24 let reader = self.readers.get(d.reader_idx?)?;
25 let file_id = reader.find_file_id(d.file)?;
26 reader.note_at(file_id, d.start_line, d.start_col, kind)
27 }
28}