Expand description
Diagnostics Engine Module
This module provides the diagnostics engine for analyzing code and generating diagnostics (errors, warnings, hints) for identified issues.
§Architecture
The diagnostics engine is organized into:
DiagnosticsEngine: Main trait for generating diagnostics- Language-specific rule modules:
rust_rules,typescript_rules,python_rules Diagnostictypes: Error, warning, and hint severity levels
§External LSP Integration
The diagnostics engine integrates with external LSP servers for semantic diagnostics:
- External LSP First: If an external LSP server is configured for the language, it provides semantic diagnostics (compiler errors, type errors, etc.)
- Merge Results: External diagnostics are merged with internal diagnostics (external takes priority)
- Fallback: If the external LSP is unavailable, the system falls back to internal diagnostics engine
§Fallback Behavior
When external LSP is unavailable, the internal diagnostics engine provides:
- Syntax Errors: Basic syntax validation
- Pattern-Based Warnings: Common coding patterns and anti-patterns
- Style Issues: Code style and formatting issues
- Language-Specific Rules: Language-specific rules (Rust, TypeScript, Python)
However, the internal engine lacks:
- Type Checking: Cannot perform type inference or type checking
- Semantic Analysis: Cannot resolve references or perform semantic analysis
- Project Context: Cannot access project configuration or dependencies
- Compiler Errors: Cannot provide actual compiler errors
§Example
ⓘ
use ricecoder_lsp::diagnostics::DiagnosticsEngine;
use ricecoder_lsp::types::Language;
let engine = DefaultDiagnosticsEngine::new();
let diagnostics = engine.generate_diagnostics(code, Language::Rust)?;Re-exports§
pub use adapters::PythonDiagnosticsAdapter;pub use adapters::RustDiagnosticsAdapter;pub use adapters::TypeScriptDiagnosticsAdapter;pub use generic_engine::GenericDiagnosticsEngine;
Modules§
- adapters
- Adapter implementations for existing diagnostics engines to implement DiagnosticsProvider trait
- generic_
engine - Generic diagnostics engine that works with pluggable providers
- python_
rules - Python-specific diagnostic rules
- rust_
rules - Rust-specific diagnostic rules
- typescript_
rules - TypeScript-specific diagnostic rules
Structs§
- Default
Diagnostics Engine - Default diagnostics engine implementation
Enums§
- Diagnostics
Error - Error type for diagnostics operations
Traits§
- Diagnostics
Engine - Trait for generating diagnostics from code
Type Aliases§
- Diagnostics
Result - Result type for diagnostics operations