Skip to main content

RulePackServer

Trait RulePackServer 

Source
pub trait RulePackServer {
Show 26 methods // Required methods fn rule_packs(&self) -> &ValidatedRulePackSet; fn grammar(&self) -> Language; fn server_name(&self) -> &'static str; fn client(&self) -> &Client; fn adapter(&self) -> &AutoLspAdapter; // Provided methods fn cross_file_rules(&self) -> &[CrossFileRule] { ... } fn workspace_index(&self) -> Option<&WorkspaceIndex> { ... } fn spc_monitor(&self) -> Option<&Mutex<SpcMonitor>> { ... } fn latency_trackers( &self, ) -> Option<&Arc<DashMap<String, RuleLatencyTracker>>> { ... } fn rule_circuit_breaker(&self) -> Option<&Arc<Mutex<CircuitBreaker>>> { ... } fn server_capabilities(&self) -> ServerCapabilities { ... } fn build_initialize_result(&self) -> InitializeResult { ... } async fn handle_did_open(&self, params: DidOpenTextDocumentParams) { ... } async fn handle_did_change(&self, params: DidChangeTextDocumentParams) { ... } fn handle_did_close(&self, params: DidCloseTextDocumentParams) { ... } fn scan_uri_classified( &self, uri: &DocumentUri, content: &str, ) -> ClassifiedFindings { ... } fn scan_uri(&self, uri: &DocumentUri, content: &str) -> Vec<Finding> { ... } async fn publish_findings_classified(&self, uri: DocumentUri, content: &str) { ... } async fn publish_findings(&self, uri: DocumentUri, content: &str) { ... } fn pull_document_diagnostics( &self, uri: &DocumentUri, ) -> DocumentDiagnosticReportResult { ... } fn conformance_for_content( &self, uri: &DocumentUri, content: &str, ) -> ConformanceVector { ... } fn snapshot_conformance(&self, uri: &DocumentUri) -> ConformanceVector { ... } fn workspace_conformance(&self) -> ConformanceVector { ... } fn evaluate_cross_file_rules(&self) -> Option<Vec<CrossFileViolation>> { ... } fn cross_file_violations_as_diagnostics( &self, violations: &[CrossFileViolation], ) -> HashMap<String, Vec<Diagnostic>> { ... } async fn publish_cross_file_diagnostics(&self) { ... }
}
Expand description

The bridge between lsp-max’s LanguageServer machinery and a set of loaded RulePacks.

Required Methods§

Source

fn rule_packs(&self) -> &ValidatedRulePackSet

The rule packs this server enforces, pre-validated for conflicts.

Source

fn grammar(&self) -> Language

The tree-sitter grammar used for incremental parsing.

Source

fn server_name(&self) -> &'static str

A stable, human-readable server identifier.

Source

fn client(&self) -> &Client

The Client handle for push-publishing diagnostics.

Source

fn adapter(&self) -> &AutoLspAdapter

The AutoLspAdapter that owns the incremental document store.

Provided Methods§

Source

fn cross_file_rules(&self) -> &[CrossFileRule]

Optional cross-file rules. Default: empty.

Source

fn workspace_index(&self) -> Option<&WorkspaceIndex>

The shared workspace index. Servers that want cross-file diagnostics must hold a WorkspaceIndex field and return it here.

Source

fn spc_monitor(&self) -> Option<&Mutex<SpcMonitor>>

Optional SPC monitor for scan-latency anomaly detection. Override to return Some(&self.spc_monitor) to enable Western Electric rule checks.

Source

fn latency_trackers(&self) -> Option<&Arc<DashMap<String, RuleLatencyTracker>>>

Optional per-rule latency tracker map for dynamic EvalBudget reclassification.

Source

fn rule_circuit_breaker(&self) -> Option<&Arc<Mutex<CircuitBreaker>>>

Optional circuit breaker protecting the rule-evaluation loop.

Source

fn server_capabilities(&self) -> ServerCapabilities

Build the ServerCapabilities block advertised during initialize.

When cross-file rules are present, inter_file_dependencies and workspace_diagnostics are set to true so editors know to request workspace-level diagnostic reports.

Source

fn build_initialize_result(&self) -> InitializeResult

Construct the InitializeResult this server returns.

Source

async fn handle_did_open(&self, params: DidOpenTextDocumentParams)

Handle textDocument/didOpen: index the document, parse incrementally, and publish diagnostics from all sync-budget rule packs.

Background-budget rules are dispatched as Tokio tasks.

Source

async fn handle_did_change(&self, params: DidChangeTextDocumentParams)

Handle textDocument/didChange: update the index and re-run sync rules.

Source

fn handle_did_close(&self, params: DidCloseTextDocumentParams)

Handle textDocument/didClose: evict from adapter and index.

Source

fn scan_uri_classified( &self, uri: &DocumentUri, content: &str, ) -> ClassifiedFindings

Scan content against every rule in every loaded pack, applying the EvalBudget classification.

Returns (sync_findings, background_findings).

Source

fn scan_uri(&self, uri: &DocumentUri, content: &str) -> Vec<Finding>

Scan content against all rules (ignoring budget classification).

Source

async fn publish_findings_classified(&self, uri: DocumentUri, content: &str)

Run scan_uri and push the resulting LSP diagnostics to the client, respecting EvalBudget. Sync findings are published immediately. Background findings are published from the calling task (Tokio will handle concurrency at the server level).

Source

async fn publish_findings(&self, uri: DocumentUri, content: &str)

Run scan_uri and push the resulting LSP diagnostics to the client.

Source

fn pull_document_diagnostics( &self, uri: &DocumentUri, ) -> DocumentDiagnosticReportResult

Build a DocumentDiagnosticReportResult for the pull-diagnostics endpoint.

Source

fn conformance_for_content( &self, uri: &DocumentUri, content: &str, ) -> ConformanceVector

Return the per-document ConformanceVector derived from rule-pack findings.

Source

fn snapshot_conformance(&self, uri: &DocumentUri) -> ConformanceVector

Return a ConformanceVector for the document currently held in the incremental adapter store, falling back to all-unknown.

Source

fn workspace_conformance(&self) -> ConformanceVector

Return the workspace-level ConformanceVector aggregated across all indexed documents.

This is the game-changer: a single vector showing admitted/refused/unknown axes across the entire workspace. No other LSP provides this.

Source

fn evaluate_cross_file_rules(&self) -> Option<Vec<CrossFileViolation>>

Evaluate all cross-file rules and return workspace violations.

Returns None if no workspace index is configured.

Source

fn cross_file_violations_as_diagnostics( &self, violations: &[CrossFileViolation], ) -> HashMap<String, Vec<Diagnostic>>

Convert cross-file violations to LSP diagnostics grouped by source URI.

Source

async fn publish_cross_file_diagnostics(&self)

Run cross-file rule evaluation and publish diagnostics per-file.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§