Expand description
Ricecoder Refactoring Engine
A safe, language-agnostic refactoring engine with impact analysis, preview, and rollback capabilities.
§Architecture
The refactoring engine follows a language-agnostic, configuration-driven architecture:
- Language-Agnostic Core: Generic refactoring engine that works with any language
- Configuration-Driven: Language-specific behavior defined in YAML/JSON configuration files
- Pluggable Providers: Language-specific adapters for Rust, TypeScript, Python, and generic fallback
- Storage Integration: Uses
ricecoder-storagefor configuration management - Safe by Default: Automatic backups, validation, and rollback capabilities
§Provider Priority Chain
The engine implements a provider priority chain for language support:
- External LSP Servers (language-specific, maintained by language communities)
- Configured Refactoring Rules (YAML/JSON configuration files)
- Built-in Language-Specific Providers (Rust, TypeScript, Python)
- Generic Text-Based Refactoring (fallback for any language)
§Example
ⓘ
use ricecoder_refactoring::RefactoringEngine;
use ricecoder_refactoring::config::ConfigManager;
// Create configuration manager
let config_manager = ConfigManager::new(storage);
// Create refactoring engine
let engine = RefactoringEngine::new(config_manager);
// Perform refactoring
let result = engine.refactor(code, language, refactoring_type)?;Re-exports§
pub use adapters::GenericRefactoringProvider;pub use adapters::PythonRefactoringProvider;pub use adapters::RustRefactoringProvider;pub use adapters::TypeScriptRefactoringProvider;pub use config::ConfigLoader;pub use config::ConfigManager;pub use config::LanguageConfig;pub use config::StorageConfigLoader;pub use error::RefactoringError;pub use error::Result;pub use impact::Dependency;pub use impact::DependencyGraph;pub use impact::DependencyType;pub use impact::ImpactAnalyzer;pub use impact::Symbol;pub use impact::SymbolType;pub use patterns::PatternApplication;pub use patterns::PatternExporter;pub use patterns::PatternMatcher;pub use patterns::PatternParameter;pub use patterns::PatternScope;pub use patterns::PatternStore;pub use patterns::PatternValidator;pub use patterns::RefactoringPattern;pub use preview::DiffHunk;pub use preview::PreviewGenerator;pub use preview::UnifiedDiff;pub use providers::LspProvider;pub use providers::LspProviderRegistry;pub use providers::ProviderRegistry;pub use providers::RefactoringProvider;pub use safety::RollbackHandler;pub use safety::SafetyChecker;pub use types::ChangeType;pub use types::FileChange;pub use types::Refactoring;pub use types::RefactoringOptions;pub use types::RefactoringResult;pub use types::RefactoringTarget;pub use types::RefactoringType;pub use types::ValidationResult;pub use validation::ValidationEngine;
Modules§
- adapters
- Language-specific refactoring adapters
- config
- Configuration management for the refactoring engine
- error
- Error types for the refactoring engine
- impact
- Impact analysis for refactoring operations
- patterns
- Refactoring patterns for reusable transformations
- preview
- Preview generation for refactoring operations
- providers
- Provider traits and implementations for language-specific refactoring
- safety
- Safety checks and rollback for refactoring operations
- types
- Core data types for the refactoring engine
- validation
- Validation engine for refactoring operations
Structs§
- Refactoring
Engine - The main refactoring engine