unfault-core
Core parsing, semantics extraction, and graph building for unfault.
Overview
This crate provides language-agnostic code analysis capabilities:
- Parsing: Tree-sitter based parsing for Python, Go, Rust, TypeScript, etc.
- Semantics: Extract semantic information (functions, imports, classes, call sites, etc.)
- Graph: Build code dependency graphs with import/call relationships
- Types: Common types for language identification, source files, and profiles
Features
- Multi-language support: Python, Go, Rust, TypeScript
- Framework detection: FastAPI, Express, Gin, and more
- Graph construction: Build import graphs, call graphs, and dependency graphs
Usage
use parse_python_file;
use PyFileSemantics;
use build_code_graph;
use ;
use FileId;
// Parse a Python file
let source = SourceFile ;
let parsed = parse_python_file.unwrap;
let semantics = from_parsed;
println!;
println!;
Architecture
unfault-core/
├── src/
│ ├── lib.rs # Public API exports
│ ├── error.rs # Error types
│ ├── parse/ # Tree-sitter parsing
│ │ ├── ast.rs # AST types and FileId
│ │ ├── python.rs # Python parser
│ │ ├── go.rs # Go parser
│ │ └── ...
│ ├── semantics/ # Semantic analysis
│ │ ├── common/ # Language-agnostic types
│ │ ├── python/ # Python-specific semantics
│ │ ├── go/ # Go-specific semantics
│ │ └── ...
│ ├── graph/ # Code graph construction
│ │ └── mod.rs # CodeGraph, GraphNode, GraphEdgeKind
│ └── types/ # Common types
│ ├── context.rs # SourceFile, Language
│ ├── profile.rs # Analysis profiles
│ └── ...
License
MIT