Fix PHP symbol retrieval: declare missing Intelephense client capabilities#1099
Fix PHP symbol retrieval: declare missing Intelephense client capabilities#1099EarthmanWeb wants to merge 3 commits intooraios:mainfrom
Conversation
docs/sample.php
Outdated
| @@ -0,0 +1,665 @@ | |||
| <?php | |||
There was a problem hiding this comment.
If it shall provide the basis for tests (which it probably should), please move this the PHP test repository.
If it shall not provide the basis for tests, delete it.
There was a problem hiding this comment.
Removed and provided a new sample file and test
opcode81
left a comment
There was a problem hiding this comment.
Tests should be added which validate that the changes result in the improvements described.
In particular, we should explicitly inspect the hierarchical structure in tests.
Two related fixes: 1. intelephense.py: Add missing client capability declarations for documentSymbol (with hierarchical support), references, hover, and workspace symbol. Without these, Intelephense does not advertise documentSymbolProvider and returns empty results for get_symbols_overview. 2. symbol.py (LanguageServerSymbolRetriever.find_symbols): When searching within a specific file, route to the file-type-appropriate language server via get_language_server() instead of querying all servers. This ensures PHP files are served by Intelephense and not silently skipped. Add generic PHP sample to test repository for use as test basis.
9fee2ac to
0472f4d
Compare
- test_document_symbols_hierarchical_structure: verifies Intelephense returns DocumentSymbol[] with class/method hierarchy (not flat SymbolInformation[]) when hierarchicalDocumentSymbolSupport is declared - test_full_symbol_tree_within_file: verifies request_full_symbol_tree scoped to sample.php returns Dog/Animal/greet/fetch with Dog containing greet as a child (not at root level) - test_find_symbol_within_php_file: verifies find_symbol with a PHP file path (relative_path=) routes to the PHP language server via get_language_server() rather than iterating all servers
All 19 PHP tests pass. Summary of what was added: test/solidlsp/php/test_php_basic.py — 2 new tests: test_document_symbols_hierarchical_structure — directly validates the hierarchicalDocumentSymbolSupport fix: asserts Dog class has greet, fetch, getBreed, describe as children (not disconnected root-level symbols), and that those methods do NOT appear at root level test_find_symbol_within_php_file — validates the symbol.py routing fix: calls find_symbol(name_path_pattern="Dog/greet", relative_path="sample.php") and asserts the symbol is found (would return empty before the fix, as non-PHP servers would reject the file) |
Problem
Intelephense's LSP server conditionally enables certain features based
on what the client declares it supports in the
initializerequest.Serena's Intelephense client was missing several capability declarations:
textDocument.documentSymbol(withhierarchicalDocumentSymbolSupport)textDocument.referencestextDocument.hoverworkspace.symbolWithout
hierarchicalDocumentSymbolSupport: true, Intelephense fallsback to returning flat
SymbolInformation[]instead of the nestedDocumentSymbol[]tree. This means symbol retrieval works partiallyor not at all — classes and their methods appear as disconnected
root-level symbols with no parent-child relationship.
Additionally, when
find_symbolis called with a specific PHP filepath, it iterated all language servers rather than routing to the
correct one, causing PHP files to be rejected by non-PHP servers.
Fix
intelephense.py: Added missing client capability declarationsfor
documentSymbol(with fullhierarchicalDocumentSymbolSupportand
symbolKindrange),references,hover, and workspacesymbol. Also added assertion that the server confirmsdocumentSymbolProvidersupport after initialization.symbol.py: Whenfind_symbolsis called with a specific filepath, route to the appropriate language server via
get_language_server()instead of iterating all servers.Example
Before:
After: