1use std::path::Path;
2
3use crate::error::AftError;
4pub use crate::symbols::{Range, Symbol, SymbolMatch};
5
6#[derive(Debug, Clone, PartialEq, Eq)]
8pub struct HeadingAnchor {
9 pub start_line: u32,
10 pub start_col: u32,
11 pub id: String,
12}
13
14pub trait LanguageProvider: Send + Sync {
18 fn resolve_symbol(&self, file: &Path, name: &str) -> Result<Vec<SymbolMatch>, AftError>;
20
21 fn list_symbols(&self, file: &Path) -> Result<Vec<Symbol>, AftError>;
23
24 fn heading_anchors(&self, _file: &Path) -> Result<Vec<HeadingAnchor>, AftError> {
26 Ok(Vec::new())
27 }
28
29 fn as_any(&self) -> &dyn std::any::Any;
31}
32
33pub struct StubProvider;
37
38impl LanguageProvider for StubProvider {
39 fn resolve_symbol(&self, _file: &Path, _name: &str) -> Result<Vec<SymbolMatch>, AftError> {
40 Err(AftError::InvalidRequest {
41 message: "no language provider configured".to_string(),
42 })
43 }
44
45 fn list_symbols(&self, _file: &Path) -> Result<Vec<Symbol>, AftError> {
46 Err(AftError::InvalidRequest {
47 message: "no language provider configured".to_string(),
48 })
49 }
50
51 fn as_any(&self) -> &dyn std::any::Any {
52 self
53 }
54}