Fix PHP find_symbol: handle flat SymbolInformation#1097
Open
EarthmanWeb wants to merge 7 commits into
Open
Conversation
opcode81
requested changes
Mar 1, 2026
Member
|
@opcode81 @EarthmanWeb what's the status here? |
opcode81
force-pushed
the
main
branch
4 times, most recently
from
April 6, 2026 21:08
fee8b1c to
d165272
Compare
…mation Three related fixes for PHP symbol resolution: 1. ls_manager.get_language_server(): route to language server by file extension (via get_source_fn_matcher) instead of is_ignored_path, so PHP files are correctly dispatched to Intelephense. 2. ls.get_symbols_overview(): when a file is explicitly requested but matches an ignore pattern, warn and proceed instead of returning an empty list. 3. symbol.iter_name_path_components_reversed(): add containerName fallback for flat SymbolInformation responses (Intelephense returns these for some PHP files), enabling name-path patterns like "ClassName/method" to match.
Intelephense can return flat SymbolInformation[] (no parent-child links) instead of DocumentSymbol[] for some PHP files. The previous fix placed a containerName fallback inside LanguageServerSymbol.iter_name_path_components_reversed, polluting the generic symbol layer with a language-server-specific quirk. Moved the fix to the correct layer per reviewer feedback: - intelephense.py: Override _request_document_symbols to detect flat SymbolInformation[] (identified by a top-level "location" key) and reconstruct a proper DocumentSymbol[] tree using containerName to wire up parent-child relationships before the result reaches shared code. - symbol.py: Revert iter_name_path_components_reversed to its original clean form; no Intelephense-specific knowledge belongs here. - test_symbol.py: Remove TestLanguageServerSymbolFlatContainerName, which tested the now-removed containerName fallback in the generic class. - test_php_basic.py: Add TestIntelephenseReconstructDocumentSymbols with four unit tests covering _reconstruct_document_symbols directly (root symbols, method-to-class attachment, orphan handling, two-class separation). The existing integration test test_find_symbol_class_method continues to cover the end-to-end path through Intelephense.
The _request_document_symbols override now reconstructs flat SymbolInformation[] into DocumentSymbol[], changing the cached data format. Bump version to invalidate stale cache entries.
EarthmanWeb
force-pushed
the
fix/php-symbol-routing
branch
from
May 7, 2026 09:38
024d71e to
8e9402e
Compare
Contributor
Author
|
Rebased on current main and added the cache invalidation fix.
The |
MischaPanch
force-pushed
the
main
branch
2 times, most recently
from
May 26, 2026 11:45
420a0ba to
016ccbe
Compare
MischaPanch
force-pushed
the
main
branch
6 times, most recently
from
June 28, 2026 20:38
ee32c5e to
ebe7646
Compare
opcode81
force-pushed
the
fix/php-symbol-routing
branch
from
July 17, 2026 16:05
edb6fd7 to
93bdb5b
Compare
Conflicts: src/solidlsp/language_servers/intelephense.py src/solidlsp/ls.py
opcode81
force-pushed
the
fix/php-symbol-routing
branch
from
July 17, 2026 16:07
93bdb5b to
d324e6d
Compare
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.
Problem
Two related issues cause
find_symbolto fail or return wrong results in PHP projects:1. Incorrect language server routing
In multi-language projects,
get_language_server()routed files usingis_ignored_path()— a method that checks gitignore and unsupportedextension filters. A PHP file could pass or fail this check for the
wrong language server depending on configuration order, causing PHP
files to be routed to the Python LS (or vice versa).
2. Flat
SymbolInformation[]from IntelephenseFor some PHP files, Intelephense returns
SymbolInformation[](theolder LSP format) instead of
DocumentSymbol[]. These symbols have noparent-child hierarchy — methods appear as root-level symbols with only
a
containerNamestring field linking them to their class.find_symbol("ClassName/method")failed silently becauseiter_name_path_components_reversed()never yielded the container,so the name-path match never succeeded.
3. Hard error on explicitly-requested ignored file
When
get_symbols_overview()was called on a file that happened tomatch an ignore pattern, it raised a hard error and returned
[]instead of proceeding. This broke workflows where the caller explicitly
requested a specific file.
Fix
ls_manager.py: Route byfn_matcher.is_relevant_filename()—checks the file extension against the language's known extensions —
instead of
is_ignored_path().symbol.py: AddedcontainerNamefallback initer_name_path_components_reversed(). When a symbol has noancestors (flat
SymbolInformation), yield thecontainerNamevalueso name-path patterns like
"ClassName/method"still match.ls.py: Downgraded hard error to a warning when an explicitlyrequested file is ignored; proceed with the symbol request anyway.
Example
Before:
After: