Skip to main content

prefix_diagnostic_helper

Function prefix_diagnostic_helper 

Source
pub fn prefix_diagnostic_helper<'a>(
    turtle: &Turtle,
    prefixes: &Prefixes,
    rope: &RopeC,
    label: &Label,
    lovs: impl Iterator<Item = &'a LocalPrefix>,
    prefix_cc: impl Iterator<Item = &'a PrefixEntry>,
    make_fix_edit: impl FnMut(&str, &str) -> Vec<TextEdit>,
    report_undefined: bool,
    report_unused: bool,
) -> (Vec<Diagnostic>, Vec<CodeAction>)
Expand description

Analyse a document’s parsed Turtle model against its declared prefixes and return (diagnostics, code_actions).

Walking the model (rather than the derived Triples) is what makes prefix usage detection correct for prefixes that appear only in a literal’s datatype ("5"^^xsd:integer) — the triple form stores datatypes pre-expanded, dropping the prefix entirely.

The caller supplies make_fix_edit(prefix_name, suggested_url) -> Vec<TextEdit> — identical in spirit to the extra_edits callback in prefix_completion_helper. This callback is responsible for generating the language-specific text edit that adds a prefix declaration (typically via LangHelper::prefix_edits). It may return an empty Vec if the language does not support auto-insertion.

LOV / prefix.cc iterators are used to suggest a URL for undefined prefixes. Because there are usually only a handful of undefined prefixes, we collect the undefined set first and then make a single pass over the LOV / prefix.cc data to resolve just those — rather than materialising the entire prefix universe into a lookup map.