Skip to main content

ProjectResolutionEnhancer

Trait ProjectResolutionEnhancer 

Source
pub trait ProjectResolutionEnhancer: Send + Sync {
    // Required method
    fn enhance_import_path(
        &self,
        import_path: &str,
        from_file: FileId,
    ) -> Option<String>;

    // Provided method
    fn get_import_candidates(
        &self,
        import_path: &str,
        from_file: FileId,
    ) -> Vec<String> { ... }
}
Expand description

Project-specific resolution enhancement

This trait allows languages to enhance their import resolution with project configuration (tsconfig.json, pyproject.toml, go.mod, etc.)

Required Methods§

Source

fn enhance_import_path( &self, import_path: &str, from_file: FileId, ) -> Option<String>

Transform an import path using project-specific rules

Returns None if no transformation is needed (use original path) Returns Some(enhanced_path) if the import should be resolved differently

§Examples
  • TypeScript: “@app/utils” -> “src/app/utils”
  • Python: “.utils” -> “mypackage.submodule.utils”
  • Go: “old/pkg” -> “../new/pkg”
  • PHP: “App\Utils” -> “src/Utils.php”

Provided Methods§

Source

fn get_import_candidates( &self, import_path: &str, from_file: FileId, ) -> Vec<String>

Get all possible candidate paths for an import

Some project configs support multiple target paths (e.g., TypeScript paths)

Implementors§