Module diagnostics

Module diagnostics 

Source
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
  • Diagnostic types: Error, warning, and hint severity levels

§External LSP Integration

The diagnostics engine integrates with external LSP servers for semantic diagnostics:

  1. External LSP First: If an external LSP server is configured for the language, it provides semantic diagnostics (compiler errors, type errors, etc.)
  2. Merge Results: External diagnostics are merged with internal diagnostics (external takes priority)
  3. 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§

DefaultDiagnosticsEngine
Default diagnostics engine implementation

Enums§

DiagnosticsError
Error type for diagnostics operations

Traits§

DiagnosticsEngine
Trait for generating diagnostics from code

Type Aliases§

DiagnosticsResult
Result type for diagnostics operations