feat: add .xs file support and fix Perl call extraction#80
Open
potatogim wants to merge 2 commits intotirth8205:mainfrom
Open
feat: add .xs file support and fix Perl call extraction#80potatogim wants to merge 2 commits intotirth8205:mainfrom
potatogim wants to merge 2 commits intotirth8205:mainfrom
Conversation
- Map .xs extension to C parser (Perl XS files contain C code) - Add ambiguous_function_call_expression to _CALL_TYPES["perl"] to capture built-in calls like print, bless, die, warn - Add Perl method_call_expression handling in _get_call_name() to extract method names from $obj->method() calls - Add tests/fixtures/sample.xs with struct, C functions, and XS macros - Add TestXSParsing class with 6 tests (language detection, structs, functions, includes, calls, contains) - Update CLAUDE.md to mention XS in test description Signed-off-by: Jihyeon Gim <potatogim@potatogim.net>
- Add explicit return None after method_call_expression loop in _get_call_name() to clarify intent when no method child is found - Update sample.pl bark() to use $self->speak() (method_call_expression) so the new OOP call path is directly exercised by tests - Strengthen TestPerlParsing.test_finds_calls: assert "speak" and "bless" are in call targets (covers method_call_expression and ambiguous_function_call_expression respectively) - Strengthen TestXSParsing assertions: assert "_add" in call targets and >= 3 CONTAINS edges (Point, _add, compute_distance) Signed-off-by: Jihyeon Gim <potatogim@potatogim.net>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.xs(Perl XS) extension to the C parser — XS files are predominantlyC code, so tree-sitter-c captures functions, structs, and
#includedirectivescorrectly while gracefully ignoring XS-specific macros (
MODULE,CODE:, etc.)to be dropped from the call graph
TestXSParsingtest class and strengthenTestPerlParsingassertionsBug Fixes
$obj->method()calls were silently ignored_get_call_name()assumed all languages use anidentifierchild for callexpressions. Perl's
method_call_expressionuses amethodchild instead,so the function returned
Nonefor every OOP method call — noCALLSedgeswere produced for arrow-operator calls.
Built-in calls (
print,bless,die,warn) were not capturedtree-sitter-perl parses Perl built-ins as
ambiguous_function_call_expressionnodes, which were missing from
_CALL_TYPES["perl"]. These calls weresilently skipped during graph construction.
Changes
code_review_graph/parser.py.xs → ctoEXTENSION_TO_LANGUAGEcode_review_graph/parser.pyambiguous_function_call_expressionto_CALL_TYPES["perl"]code_review_graph/parser.pymethod_call_expressionin_get_call_name()tests/fixtures/sample.xstests/fixtures/sample.pl$self->speak()to exercise method call pathtests/test_multilang.pyTestXSParsing(6 tests); strengthen Perl call assertionsTest Plan
TestXSParsing— 6 new tests: language detection, struct, functions,includes, calls, contains
TestPerlParsing.test_finds_callsnow asserts specific targets(
speakvia method call,blessvia ambiguous call)