aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_analysis/src/lib.rs')
-rw-r--r--crates/ra_analysis/src/lib.rs26
1 files changed, 25 insertions, 1 deletions
diff --git a/crates/ra_analysis/src/lib.rs b/crates/ra_analysis/src/lib.rs
index d33f3e4ca..eaf24cb36 100644
--- a/crates/ra_analysis/src/lib.rs
+++ b/crates/ra_analysis/src/lib.rs
@@ -178,6 +178,30 @@ impl Query {
178 } 178 }
179} 179}
180 180
181/// Result of "goto def" query.
182#[derive(Debug)]
183pub struct ReferenceResolution {
184 /// The range of the reference itself. Client does not know what constitutes
185 /// a reference, it handles us only the offset. It's helpful to tell the
186 /// client where the reference was.
187 pub reference_range: TextRange,
188 /// What this reference resolves to.
189 pub resolves_to: Vec<(FileId, FileSymbol)>,
190}
191
192impl ReferenceResolution {
193 fn new(reference_range: TextRange) -> ReferenceResolution {
194 ReferenceResolution {
195 reference_range,
196 resolves_to: Vec::new(),
197 }
198 }
199
200 fn add_resolution(&mut self, file_id: FileId, symbol: FileSymbol) {
201 self.resolves_to.push((file_id, symbol))
202 }
203}
204
181/// Analysis is a snapshot of a world state at a moment in time. It is the main 205/// Analysis is a snapshot of a world state at a moment in time. It is the main
182/// entry point for asking semantic information about the world. When the world 206/// entry point for asking semantic information about the world. When the world
183/// state is advanced using `AnalysisHost::apply_change` method, all existing 207/// state is advanced using `AnalysisHost::apply_change` method, all existing
@@ -236,7 +260,7 @@ impl Analysis {
236 pub fn approximately_resolve_symbol( 260 pub fn approximately_resolve_symbol(
237 &self, 261 &self,
238 position: FilePosition, 262 position: FilePosition,
239 ) -> Cancelable<Option<(TextRange, Vec<(FileId, FileSymbol)>)>> { 263 ) -> Cancelable<Option<ReferenceResolution>> {
240 self.imp.approximately_resolve_symbol(position) 264 self.imp.approximately_resolve_symbol(position)
241 } 265 }
242 pub fn find_all_refs(&self, position: FilePosition) -> Cancelable<Vec<(FileId, TextRange)>> { 266 pub fn find_all_refs(&self, position: FilePosition) -> Cancelable<Vec<(FileId, TextRange)>> {