Skip to main content

icb_common/
lib.rs

1//! Common types shared across all ICB crates.
2//!
3//! # Language support
4//!
5//! [`Language`] enumerates all source languages that ICB can analyse.
6//! For C++ two backends are available:
7//!
8//! * [`Cpp`] – full Clang parser (requires LLVM installation).
9//! * [`CppTreeSitter`] – lightweight tree‑sitter‑cpp parser, no external
10//!   dependencies.
11//!
12//! The caller chooses the variant; the rest of the system is agnostic.
13
14use serde::{Deserialize, Serialize};
15
16#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
17pub enum Language {
18    Python,
19    Cpp,
20    CppTreeSitter,
21    Rust,
22    JavaScript,
23    Go,
24    Java,
25    Ruby,
26    Php,
27    Swift,
28    Kotlin,
29    Scala,
30    CSharp,
31    Lua,
32    R,
33    Bash,
34    Perl,
35    Tcl,
36    Dart,
37    Unknown,
38}
39
40#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
41pub enum NodeKind {
42    Function,
43    Class,
44    Variable,
45    Parameter,
46    CallSite,
47    Namespace,
48    Enum,
49}
50
51#[derive(Debug, thiserror::Error)]
52pub enum IcbError {
53    #[error("I/O error: {0}")]
54    Io(#[from] std::io::Error),
55    #[error("Parse error: {0}")]
56    Parse(String),
57    #[error("Unsupported language: {0}")]
58    UnsupportedLanguage(String),
59    #[error("Graph error: {0}")]
60    Graph(String),
61    #[error("Serialisation error: {0}")]
62    Serialization(String),
63}