Skip to content

Commit 61f8a9d

Browse files
committed
feat(native): port Objective-C extractor to Rust
Mirrors `src/extractors/objc.ts` in `crates/codegraph-core/src/extractors/objc.rs`. Adds the `tree-sitter-objc` dependency, wires `LanguageKind::ObjC` (`.m`) in the Rust `parser_registry` and `file_collector`, adds `.m` to `NATIVE_SUPPORTED_EXTENSIONS` on the JS side, and registers `OBJC_AST_TYPES` / `OBJC_AST_CONFIG` so the native and WASM engines extract identical `ast_nodes` for Objective-C source. Handles class interfaces / implementations (with `: Superclass`), protocols, instance and class method declarations/definitions with multi-part selectors assembled from leading identifiers and `method_parameter` children, C-level function declarations/definitions, `#import`/`@import` imports, and message expression call extraction.
1 parent 6ef7dc6 commit 61f8a9d

11 files changed

Lines changed: 825 additions & 5 deletions

File tree

Cargo.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/codegraph-core/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ tree-sitter-dart = "0.0.4"
3535
tree-sitter-zig = "1"
3636
tree-sitter-haskell = "0.23"
3737
tree-sitter-ocaml = "0.24"
38+
tree-sitter-objc = "3"
3839
rayon = "1"
3940
ignore = "0.4"
4041
globset = "0.4"

crates/codegraph-core/src/extractors/helpers.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,19 @@ pub const OCAML_AST_CONFIG: LangAstConfig = LangAstConfig {
360360
string_prefixes: &[],
361361
};
362362

363+
/// Objective-C string literals use the `@"..."` prefix. The shared
364+
/// `build_string_node` strips a leading `@` before applying prefixes, so we
365+
/// don't need to list it explicitly here.
366+
pub const OBJC_AST_CONFIG: LangAstConfig = LangAstConfig {
367+
new_types: &[],
368+
throw_types: &["throw_statement"],
369+
await_types: &[],
370+
string_types: &["string_literal"],
371+
regex_types: &[],
372+
quote_chars: &['"'],
373+
string_prefixes: &[],
374+
};
375+
363376
// ── Generic AST node walker ──────────────────────────────────────────────────
364377

365378
/// Node types that represent identifiers across languages.

crates/codegraph-core/src/extractors/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pub mod java;
1212
pub mod javascript;
1313
pub mod kotlin;
1414
pub mod lua;
15+
pub mod objc;
1516
pub mod ocaml;
1617
pub mod php;
1718
pub mod python;
@@ -126,5 +127,8 @@ pub fn extract_symbols_with_opts(
126127
LanguageKind::Ocaml | LanguageKind::OcamlInterface => {
127128
ocaml::OcamlExtractor.extract_with_opts(tree, source, file_path, include_ast_nodes)
128129
}
130+
LanguageKind::ObjC => {
131+
objc::ObjCExtractor.extract_with_opts(tree, source, file_path, include_ast_nodes)
132+
}
129133
}
130134
}

0 commit comments

Comments
 (0)