Skip to content

Commit fdfa1d7

Browse files
corvid-agentclaude
andcommitted
fix: resolve clippy and spec-check CI failures
- Replace closures with char arrays in python.rs trim_start/end_matches - Add #[allow(clippy::type_complexity)] to 3 functions in ast/typescript.rs - Document ast module, sub-modules, get_exported_symbols_full in exports spec - Document ParseMode enum in types spec Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 2d1e809 commit fdfa1d7

4 files changed

Lines changed: 28 additions & 3 deletions

File tree

specs/exports/exports.spec.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ files:
1515
- src/exports/csharp.rs
1616
- src/exports/php.rs
1717
- src/exports/ruby.rs
18+
- src/exports/ast/mod.rs
19+
- src/exports/ast/typescript.rs
20+
- src/exports/ast/python.rs
21+
- src/exports/ast/rust_lang.rs
1822
db_tables: []
1923
tracks: [60]
2024
depends_on:
@@ -25,7 +29,7 @@ depends_on:
2529

2630
## Purpose
2731

28-
Language-aware export extraction from source files. Auto-detects the programming language from file extension and extracts public/exported symbol names using regex-based parsing (no AST required). Supports 11 languages: TypeScript/JS, Rust, Go, Python, Swift, Kotlin, Java, C#, Dart, PHP, and Ruby.
32+
Language-aware export extraction from source files. Auto-detects the programming language from file extension and extracts public/exported symbol names using regex-based parsing or tree-sitter AST analysis. Supports 11 languages: TypeScript/JS, Rust, Go, Python, Swift, Kotlin, Java, C#, Dart, PHP, and Ruby.
2933

3034
## Public API
3135

@@ -40,6 +44,23 @@ Language-aware export extraction from source files. Auto-detects the programming
4044
| `has_extension` | `file_path: &Path, extensions: &[String]` | `bool` | Check if file matches specific extensions, or any supported language if extensions is empty |
4145
| `extract_exports` | `content: &str` | `Vec<String>` | Per-language backend function that parses source text and returns exported symbol names (one per backend file) |
4246
| `extract_exports_with_resolver` | `content: &str, resolver: Option<&ImportResolver>` | `Vec<String>` | TypeScript-specific: extract exports with optional wildcard re-export resolution via file resolver callback |
47+
| `get_exported_symbols_full` | `file_path: &Path, level: ExportLevel, parse_mode: ParseMode` | `Vec<String>` | Extract exports with full control over granularity and parse mode (Regex or Ast) |
48+
49+
### Exported Modules
50+
51+
| Module | Source | Description |
52+
|--------|--------|-------------|
53+
| `ast` | `src/exports/mod.rs` | Tree-sitter based AST export extraction backends |
54+
55+
### Exported AST Sub-modules
56+
57+
Tree-sitter based export extraction backends for TypeScript, Python, and Rust. Used when `ParseMode::Ast` is selected. Falls back to regex extraction for unsupported languages or when AST parsing fails.
58+
59+
| Sub-module | File | Description |
60+
|------------|------|-------------|
61+
| `typescript` | `ast/typescript.rs` | Tree-sitter based TypeScript/JS export extraction with wildcard resolver support |
62+
| `python` | `ast/python.rs` | Tree-sitter based Python export extraction using `__all__` and top-level definitions |
63+
| `rust_lang` | `ast/rust_lang.rs` | Tree-sitter based Rust `pub` item extraction |
4364

4465
### Language Backend Functions
4566

specs/types/types.spec.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Core data structures and enums shared across the entire spec-sync codebase. Defi
2727
| `ExportLevel` | Export extraction granularity: Type (top-level declarations only) or Member (all public symbols, default) |
2828
| `SpecStatus` | Spec lifecycle status: draft, stable, deprecated. Parsed from frontmatter `status` field |
2929
| `EnforcementMode` | Graduated enforcement level: Warn (always exit 0), EnforceNew (exit 1 for unspecced files), Strict (exit 1 on any error) |
30+
| `ParseMode` | Export parsing strategy: Regex (default, all languages) or Ast (tree-sitter, supports TypeScript/Python/Rust with regex fallback) |
3031

3132
### Exported Structs
3233

src/exports/ast/python.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ fn extract_string_list(node: &tree_sitter::Node, src: &[u8]) -> Vec<String> {
110110
let text = child.utf8_text(src).unwrap_or_default();
111111
// Strip surrounding quotes
112112
let trimmed = text
113-
.trim_start_matches(|c| c == '\'' || c == '"')
114-
.trim_end_matches(|c| c == '\'' || c == '"');
113+
.trim_start_matches(['\'', '"'])
114+
.trim_end_matches(['\'', '"']);
115115
if !trimmed.is_empty() {
116116
names.push(trimmed.to_string());
117117
}

src/exports/ast/typescript.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pub fn extract_exports(content: &str) -> Vec<String> {
2424
}
2525

2626
/// Extract exports, optionally resolving wildcard re-exports via a file resolver.
27+
#[allow(clippy::type_complexity)]
2728
pub fn extract_exports_with_resolver(
2829
content: &str,
2930
resolver: Option<&dyn Fn(&str) -> Option<String>>,
@@ -42,6 +43,7 @@ pub fn extract_exports_with_resolver(
4243
symbols
4344
}
4445

46+
#[allow(clippy::type_complexity)]
4547
fn collect_exports(
4648
node: &tree_sitter::Node,
4749
src: &[u8],
@@ -71,6 +73,7 @@ fn collect_exports(
7173
}
7274
}
7375

76+
#[allow(clippy::type_complexity)]
7477
fn handle_export_statement(
7578
node: &tree_sitter::Node,
7679
src: &[u8],

0 commit comments

Comments
 (0)