Skip to content

feat: extract php symbols with structure awareness - #91

Open
GrzegorzDrozd wants to merge 2 commits into
zvec-ai:mainfrom
GrzegorzDrozd:feat/php-language-support
Open

GrzegorzDrozd wants to merge 2 commits into
zvec-ai:mainfrom
GrzegorzDrozd:feat/php-language-support

Conversation

@GrzegorzDrozd

Copy link
Copy Markdown

PHP files fell back to plain-text chunks. Every PHP declaration carries a name
field and the shared classifier already maps trait, enum and namespace nodes
correctly, so the adapter only adds what PHP does differently.

Properties and constants declare several names per statement, and promoted
constructor parameters declare properties from inside a signature. Both are
handled by resolveEntities, which keeps promoted properties on the class
breadcrumb rather than the constructor's, since the walk never descends into an
entity node.

Modifiers read PHP's modifier nodes rather than the shared signature regex,
which otherwise reports a promoted parameter's visibility as the constructor's
own.

Covers namespaces, classes, interfaces, traits, enums, methods, functions,
properties, constants, enum cases and promoted constructor properties.

Third, and final, step to support php in code extraction. See issue #88.

This branch requires and contains code from #90. It should be updated when it is
merged into main.

web-tree-sitter 0.20.8 rejects grammars built with tree-sitter CLI 0.24 and
newer ("Incompatible language version 15. Compatibility range 13 through 14"),
which pins every grammar to its 2024 revision.

Move the runtime to 0.27 and take grammars from @repomix/tree-sitter-wasms,
a maintained fork of tree-sitter-wasms whose last release still ships
tree-sitter-php 0.22 and tree-sitter-cli 0.20.8. All ten formats the extractor
supports are present in the fork with the same output layout.

The 0.25 module restructure renames SyntaxNode to Node and moves Language out
of the Parser namespace. Go renamed the interface method node from method_spec
to method_elem, which the extraction test for Go scopes covers.

Second step to support more languages in code extraction. See issue zvec-ai#88.
PHP files fell back to plain-text chunks. Every PHP declaration carries a name
field and the shared classifier already maps trait, enum and namespace nodes
correctly, so the adapter only adds what PHP does differently.

Properties and constants declare several names per statement, and promoted
constructor parameters declare properties from inside a signature. Both are
handled by resolveEntities, which keeps promoted properties on the class
breadcrumb rather than the constructor's, since the walk never descends into an
entity node.

Modifiers read PHP's modifier nodes rather than the shared signature regex,
which otherwise reports a promoted parameter's visibility as the constructor's
own.

Covers namespaces, classes, interfaces, traits, enums, methods, functions,
properties, constants, enum cases and promoted constructor properties.

Third, and final, step to support php in code extraction. See issue zvec-ai#88.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant