use crate::error::SurgeonError;
use pathfinder_common::types::{SemanticPath, SymbolScope};
use std::path::Path;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum AccessLevel {
#[default]
Public,
Protected,
Package,
Private,
}
#[derive(Debug, Clone)]
pub struct ExtractedSymbol {
pub name: String,
pub semantic_path: String,
pub kind: SymbolKind,
pub byte_range: std::ops::Range<usize>,
pub start_line: usize,
pub end_line: usize,
pub name_column: usize,
pub access_level: AccessLevel,
pub children: Vec<Self>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SymbolKind {
Test,
Function,
Method,
Class,
Struct,
Impl,
Constant,
Interface,
Enum,
Module,
Zone,
Component,
HtmlElement,
CssSelector,
CssAtRule,
}
#[async_trait::async_trait]
pub trait Surgeon: Send + Sync {
async fn read_symbol_scope(
&self,
workspace_root: &Path,
semantic_path: &SemanticPath,
) -> Result<SymbolScope, SurgeonError>;
async fn extract_symbols(
&self,
workspace_root: &Path,
file_path: &Path,
) -> Result<Vec<ExtractedSymbol>, SurgeonError>;
async fn enclosing_symbol(
&self,
workspace_root: &Path,
file_path: &Path,
line: usize,
) -> Result<Option<String>, SurgeonError>;
async fn node_type_at_position(
&self,
workspace_root: &Path,
file_path: &Path,
line: usize,
column: usize,
) -> Result<String, SurgeonError>;
async fn generate_skeleton(
&self,
workspace_root: &Path,
path: &Path,
config: &crate::repo_map::SkeletonConfig<'_>,
) -> Result<crate::repo_map::RepoMapResult, SurgeonError>;
async fn read_source_file(
&self,
workspace_root: &Path,
file_path: &Path,
) -> Result<(String, String, Vec<ExtractedSymbol>), SurgeonError>;
}