summaryrefslogtreecommitdiff
path: root/support/texlab/crates/links/src/include.rs
blob: 1392b16eaa94515362d1efbc8057e965cc3edf89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use base_db::{DocumentLocation, FeatureParams};

pub(super) fn find_links<'a>(
    params: &FeatureParams<'a>,
    results: &mut Vec<DocumentLocation<'a>>,
) -> Option<()> {
    let document = params.document;
    let parent = *params
        .workspace
        .parents(document)
        .iter()
        .next()
        .unwrap_or(&document);

    let graph = base_db::graph::Graph::new(params.workspace, parent);

    for edge in &graph.edges {
        if edge.source == document {
            if let Some(weight) = &edge.weight {
                results.push(DocumentLocation::new(edge.target, weight.link.path.range));
            }
        }
    }

    Some(())
}