microsoft/qdk
Publicmirrored from https://github.com/microsoft/qdkAvailable
source/language_service/src/openqasm/references.rs
31lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | use std::sync::Arc; |
| 5 | |
| 6 | use qsc::line_column::{Encoding, Position}; |
| 7 | use qsc::location::Location; |
| 8 | |
| 9 | use crate::openqasm::get_reference_locations; |
| 10 | |
| 11 | pub fn get_references( |
| 12 | sources: &[(Arc<str>, Arc<str>)], |
| 13 | source_name: &str, |
| 14 | position: Position, |
| 15 | position_encoding: Encoding, |
| 16 | ) -> Vec<Location> { |
| 17 | let (res, id) = |
| 18 | super::find_symbol_in_sources(sources, source_name, position, position_encoding); |
| 19 | |
| 20 | let Some(id) = id else { |
| 21 | return vec![]; |
| 22 | }; |
| 23 | |
| 24 | get_reference_locations( |
| 25 | position_encoding, |
| 26 | &res.program, |
| 27 | &res.source_map, |
| 28 | &res.symbols, |
| 29 | id, |
| 30 | ) |
| 31 | } |
| 32 | |