Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.
Python aicode-complexitycode-healthcode-intelligencecode-qualitydead-codedeveloper-toolsdocumentationgit-analyticsmcpopen-sourcepythonrefactoringstatic-analysistechnical-debt
fix(objectivec): preserve C calls in local initializers (#2877)
Luochenchen0b0a02b409ed
diff --git a/packages/core/src/repowise/core/ingestion/lang_helpers/objc.py b/packages/core/src/repowise/core/ingestion/lang_helpers/objc.pyindex 378931e11..88c24a7af 100644--- a/packages/core/src/repowise/core/ingestion/lang_helpers/objc.py+++ b/packages/core/src/repowise/core/ingestion/lang_helpers/objc.py@@ -210,13 +210,18 @@ def _objc_declares_name(node: Node, name: str, src: str) -> bool:A declarator nests (``void (^block)(int)``, ``Handler done = ^{}``), soevery identifier under the node is checked rather than only the direct- children. The node is a parameter or a declaration, never a body, so the+ children, excluding initializer values that reference rather than bind+ names. The node is a parameter or a declaration, never a body, so thewalk stays small; a nested block body is skipped for the same reason."""stack = [node]while stack:current = stack.pop()- if current.type in ("identifier", "field_identifier"):+ if current.type == "init_declarator":+ declarator = current.child_by_field_name("declarator")+ if declarator is not None:+ stack.append(declarator)+ elif current.type in ("identifier", "field_identifier"):if node_text(current, src).strip() == name:return Trueelif current.type != "compound_statement":diff --git a/tests/unit/ingestion/parser/test_objectivec.py b/tests/unit/ingestion/parser/test_objectivec.pyindex e757821ba..c25c74eb7 100644--- a/tests/unit/ingestion/parser/test_objectivec.py+++ b/tests/unit/ingestion/parser/test_objectivec.py@@ -424,6 +424,35 @@ BLOCK_INVOCATION = b"""\class TestObjectiveCBlockInvocation:+ def test_a_c_call_in_a_local_initializer_survives(self, parser: ASTParser) -> None:+ src = b"""\+int MakeCount(void) { return 1; }+void caller(void) {+ int count = MakeCount();+}+"""+ result = parser.parse_file(_objc("Count.m"), src)+ assert result.parse_errors == []+ assert [(c.target_name, c.caller_symbol_id) for c in result.calls] == [+ ("MakeCount", "Count.m::caller")+ ]++ def test_an_initializer_reference_does_not_shadow_a_c_function(+ self, parser: ASTParser+ ) -> None:+ src = b"""\+int MakeCount(void) { return 1; }+void caller(void) {+ int count = MakeCount();+ MakeCount();+}+"""+ result = parser.parse_file(_objc("Count.m"), src)+ assert [(c.target_name, c.caller_symbol_id) for c in result.calls] == [+ ("MakeCount", "Count.m::caller"),+ ("MakeCount", "Count.m::caller"),+ ]+def test_a_block_parameter_call_is_not_an_edge(self, parser: ASTParser) -> None:# `completionBlock(YES)` invokes the method's own block parameter. It# is a call_expression on a bare identifier, indistinguishable from a