Skip to content

Commit 1838322

Browse files
GertLclaude
andauthored
feat: Rewrite Python extractor on tree-sitter AST with Django support (#28)
* Enhance Python extractor with Django support and update tests * Add Python AST extraction and related tests for improved fact generation * Enhance Python AST extractor for Django support and improve route handling - Added handling for assignment nodes in the AST to capture Django urlpatterns at the module level. - Updated the expression statement handler to also process Django urlpatterns. - Enhanced the decorated definition handler to back-fill route facts with the corresponding handler names. - Improved dependency tracking by changing the target format in import statements. - Modified the function handling to distinguish between methods and top-level functions. - Updated tests to use a unified extraction function and removed redundant file handling code. - Cleaned up unused helper tests and ensured consistent handling of class and function definitions. * Fix stale pointer bug in pyWalker and skip @overload stubs Replace ownerStack/pendingRouteIndices pointer captures with slice indices to prevent silently lost call edges and handler back-fills when w.out reallocates its backing array during body traversal. Skip @overload-decorated function definitions to avoid emitting duplicate symbol facts for type-checker-only stubs that have no runtime behaviour. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Update tree-sitter-python dependency to v0.23.6 in go.mod and go.sum --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 7d4c54b commit 1838322

6 files changed

Lines changed: 1690 additions & 515 deletions

File tree

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ require (
66
github.com/modelcontextprotocol/go-sdk v1.3.0
77
github.com/tree-sitter-grammars/tree-sitter-kotlin v1.1.0
88
github.com/tree-sitter/go-tree-sitter v0.24.0
9+
github.com/tree-sitter/tree-sitter-python v0.23.6
910
github.com/tree-sitter/tree-sitter-typescript v0.23.2
1011
gopkg.in/yaml.v3 v3.0.1
1112
)

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ github.com/tree-sitter/tree-sitter-json v0.21.1-0.20240818005659-bdd69eb8c8a5 h1
3636
github.com/tree-sitter/tree-sitter-json v0.21.1-0.20240818005659-bdd69eb8c8a5/go.mod h1:GbMKRjLfk0H+PI7nLi1Sx5lHf5wCpLz9al8tQYSxpEk=
3737
github.com/tree-sitter/tree-sitter-php v0.22.9-0.20240819002312-a552625b56c1 h1:ZXZMDwE+IhUtGug4Brv6NjJWUU3rfkZBKpemf6RY8/g=
3838
github.com/tree-sitter/tree-sitter-php v0.22.9-0.20240819002312-a552625b56c1/go.mod h1:UKCLuYnJ312Mei+3cyTmGOHzn0YAnaPRECgJmHtzrqs=
39-
github.com/tree-sitter/tree-sitter-python v0.21.1-0.20240818005537-55a9b8a4fbfb h1:EXEM82lFM7JjJb6qiKZXkpIDaCcbV2obNn82ghwj9lw=
40-
github.com/tree-sitter/tree-sitter-python v0.21.1-0.20240818005537-55a9b8a4fbfb/go.mod h1:lXCF1nGG5Dr4J3BTS0ObN4xJCCICiSu/b+Xe/VqMV7g=
39+
github.com/tree-sitter/tree-sitter-python v0.23.6 h1:qHnWFR5WhtMQpxBZRwiaU5Hk/29vGju6CVtmvu5Haas=
40+
github.com/tree-sitter/tree-sitter-python v0.23.6/go.mod h1:cpdthSy/Yoa28aJFBscFHlGiU+cnSiSh1kuDVtI8YeM=
4141
github.com/tree-sitter/tree-sitter-ruby v0.21.1-0.20240818211811-7dbc1e2d0e2d h1:fcYCvoXdcP1uRQYXqJHRy6Hec+uKScQdKVtMwK9JeCI=
4242
github.com/tree-sitter/tree-sitter-ruby v0.21.1-0.20240818211811-7dbc1e2d0e2d/go.mod h1:T1nShQ4v5AJtozZ8YyAS4uzUtDAJj/iv4YfwXSbUHzg=
4343
github.com/tree-sitter/tree-sitter-rust v0.21.3-0.20240818005432-2b43eafe6447 h1:o9alBu1J/WjrcTKEthYtXmdkDc5OVXD+PqlvnEZ0Lzc=

0 commit comments

Comments
 (0)