marco_core/intelligence/
mod.rs1pub mod analysis;
10pub mod catalog;
11pub mod editor;
12pub mod lsp_protocol;
13pub mod markdown;
14pub mod toc;
15
16pub use analysis::{
17 compute_diagnostics, compute_diagnostics_critical, compute_diagnostics_with_options,
18 compute_lints, compute_lints_detailed, compute_lints_detailed_with_options,
19 compute_lints_with_options, Diagnostic, DiagnosticCode, DiagnosticSeverity, DiagnosticsOptions,
20 DiagnosticsProfile, LintCodeBucket, LintDetailedReport, LintReport,
21};
22pub use catalog::{
23 diagnostics_catalog, diagnostics_catalog_groups, diagnostics_catalog_settings,
24 diagnostics_markdown_features, find_catalog_entry, find_catalog_entry_by_key,
25 find_catalog_group, find_catalog_group_by_code, find_markdown_feature, DiagnosticsCatalog,
26 DiagnosticsCatalogEntry, DiagnosticsCatalogGroup, DiagnosticsCatalogSettings,
27 MarkdownFeatureCoverage,
28};
29pub use editor::{
30 compute_highlights, compute_highlights_with_source, get_hover_info, get_markdown_completions,
31 get_position_span, CompletionItem, Highlight, HighlightTag, HoverInfo,
32};
33
34use crate::parser::{Document, Position};
35
36#[derive(Default)]
38pub struct MarkdownIntelligenceProvider {
39 document: Option<Document>,
40}
41
42impl MarkdownIntelligenceProvider {
43 pub fn new() -> Self {
44 log::info!("Markdown intelligence provider initialized");
45 Self { document: None }
46 }
47
48 pub fn update_document(&mut self, document: Document) {
49 self.document = Some(document);
50 }
51
52 pub fn highlights(&self, source: &str) -> Vec<Highlight> {
53 self.document
54 .as_ref()
55 .map(|doc| compute_highlights_with_source(doc, source))
56 .unwrap_or_default()
57 }
58
59 pub fn diagnostics(&self) -> Vec<Diagnostic> {
60 self.document
61 .as_ref()
62 .map(compute_diagnostics)
63 .unwrap_or_default()
64 }
65
66 pub fn diagnostics_with_options(&self, options: DiagnosticsOptions) -> Vec<Diagnostic> {
67 self.document
68 .as_ref()
69 .map(|doc| compute_diagnostics_with_options(doc, options))
70 .unwrap_or_default()
71 }
72
73 pub fn hover(&self, position: Position) -> Option<HoverInfo> {
74 self.document
75 .as_ref()
76 .and_then(|doc| get_hover_info(position, doc))
77 }
78
79 pub fn completions(&self, query: &str) -> Vec<CompletionItem> {
80 get_markdown_completions(query)
81 }
82}