pub mod cpp;
pub mod csharp;
pub mod go;
pub mod java;
pub mod parser;
pub mod python;
pub mod rust;
pub mod treesitter;
pub mod typescript;
pub use parser::{ParseOptions, ParseResult, ParseStats, Parser};
use std::collections::HashMap;
use std::path::{Path, PathBuf};
use crate::types::{AcbResult, CodeUnitType, Language, Span, Visibility};
#[derive(Debug, Clone)]
pub struct RawCodeUnit {
pub temp_id: u64,
pub unit_type: CodeUnitType,
pub language: Language,
pub name: String,
pub qualified_name: String,
pub file_path: PathBuf,
pub span: Span,
pub signature: Option<String>,
pub doc: Option<String>,
pub visibility: Visibility,
pub is_async: bool,
pub is_generator: bool,
pub complexity: u32,
pub references: Vec<RawReference>,
pub children: Vec<u64>,
pub parent: Option<u64>,
pub metadata: HashMap<String, String>,
}
impl RawCodeUnit {
pub fn new(
unit_type: CodeUnitType,
language: Language,
name: String,
file_path: PathBuf,
span: Span,
) -> Self {
let qualified_name = name.clone();
Self {
temp_id: 0,
unit_type,
language,
name,
qualified_name,
file_path,
span,
signature: None,
doc: None,
visibility: Visibility::Unknown,
is_async: false,
is_generator: false,
complexity: 0,
references: Vec::new(),
children: Vec::new(),
parent: None,
metadata: HashMap::new(),
}
}
}
#[derive(Debug, Clone)]
pub struct RawReference {
pub name: String,
pub kind: ReferenceKind,
pub span: Span,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ReferenceKind {
Import,
Call,
TypeUse,
Inherit,
Implement,
Access,
}
#[derive(Debug, Clone)]
pub struct ParseFileError {
pub path: PathBuf,
pub span: Option<Span>,
pub message: String,
pub severity: Severity,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Severity {
Error,
Warning,
Info,
}
pub trait LanguageParser: Send + Sync {
fn extract_units(
&self,
tree: &tree_sitter::Tree,
source: &str,
file_path: &Path,
) -> AcbResult<Vec<RawCodeUnit>>;
fn is_test_file(&self, path: &Path, source: &str) -> bool;
}