Skip to content

AST analyzer: tree-sitter parse into FileAst model (v0.1.1)#8

Merged
s1rry merged 1 commit into
mainfrom
feature/ast-analyzer
Jul 4, 2026
Merged

AST analyzer: tree-sitter parse into FileAst model (v0.1.1)#8
s1rry merged 1 commit into
mainfrom
feature/ast-analyzer

Conversation

@s1rry

@s1rry s1rry commented Jul 4, 2026

Copy link
Copy Markdown
Owner

What

AST analyzer — parses a source file into a structural internal JSON model. No AI.

  • New model FileAst (core): functions, classes, interfaces, imports, exports with line ranges and is_async. Serializable → JSON.
  • devpilot-analysis now implements the CodeAnalyzer port on tree-sitter for Rust and TypeScript/JavaScript (incl. TSX/JSX grammars). Pure syntactic extraction via a tree walk; a parse failure is a per-file AnalysisError, never a panic. Blocking parse runs in spawn_blocking.
  • Port refocus: CodeAnalyzer moves from the metrics-oriented analyze_file -> FileAnalysis (unused scaffolding) to parse -> FileAst. The metrics types stay for a later complexity step.
  • Wiring: parse_file Tauri command via DI; typed lib/ipc/ast.ts.
  • Rust mapping: struct/enum → classes (methods attached from impl blocks), trait → interfaces, use → imports, pub items → exports.

Verification

  • cargo fmt --check, clippy -D warnings, full cargo test --workspace: clean. tree-sitter C grammars compile.
    • 3 parse integration tests over real Rust and TypeScript source (functions incl. async, class methods, interfaces/traits, imports, pub/export detection, unsupported-language error).
  • cargo build -p devpilot-desktop and pnpm build (tsc strict): clean.

Scope per plan: internal model + command + tests, no UI (a symbols viewer can follow).

🤖 Generated with Claude Code

No AI, internal model. devpilot-analysis implements the CodeAnalyzer port on
tree-sitter for Rust and TypeScript/JavaScript (incl. TSX/JSX), extracting
functions, classes, interfaces, imports and exports into a serializable
FileAst. Extraction is pure syntax with per-file error handling. The
CodeAnalyzer port is refocused from metrics onto AST parsing; metrics types
stay for a later step. Exposed as the parse_file command via DI with a typed
lib/ipc/ast layer.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@s1rry s1rry merged commit 00a0fa5 into main Jul 4, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant