Use contributed search participants in call hierarchy#2881
Merged
jjohnstn merged 2 commits intoMay 13, 2026
Conversation
6a0934b to
1321bcb
Compare
85f90a6 to
0fc11a2
Compare
jjohnstn
requested changes
May 12, 2026
0fc11a2 to
5130843
Compare
Incoming calls (CallerMethodWrapper):
Replace hardcoded `new SearchParticipant[] { getDefaultSearchParticipant() }`
with `SearchEngine.getSearchParticipants()` so that incoming call searches
include results from contributed search participants registered via the
`org.eclipse.jdt.core.derivedSourceSearchParticipant` extension point. For
contributed (non-Java) elements, accept A_INACCURATE matches since JDT's
MatchLocator cannot resolve type bindings for types not compiled by ECJ.
Outgoing calls (CalleeMethodWrapper):
When the member has no Java AST (i.e. `getCompilationUnitNode()` returns
null), fall back to `DerivedSourceSearchParticipant.locateCallees()` on all
contributed participants. Each participant can report call sites within the
member's body. Returned callees are resolved to full declarations via
`resolveCallee()`, which handles METHOD, FIELD, and TYPE element types.
Outgoing calls from Java to non-Java targets (CalleeAnalyzerVisitor):
When a Java method invocation has a null ECJ binding (receiver type is from
a contributed language, not compiled by ECJ), fall back to resolveViaSearch()
which uses SearchEngine.getSearchParticipants() to find METHOD DECLARATIONS
matching the method name across all contributed participants.
Non-standard ICompilationUnit handling (CallHierarchyCore):
Guard getCompilationUnitNode() with isJavaLikeFileName() check so non-Java
source files (e.g. .kt) are not parsed as Java AST, which would produce
broken results and false positives in outgoing call analysis.
Dependency:
Bump `org.eclipse.jdt.core` dependency to `[3.46.0,4.0.0)` for the
`SearchEngine.getSearchParticipants()` and
`DerivedSourceSearchParticipant.locateCallees()` APIs added in
eclipse-jdt/eclipse.jdt.core#4938.
Depends on eclipse-jdt/eclipse.jdt.core#4938.
Companion to eclipse-jdtls/eclipse.jdt.ls#3732.
5130843 to
7bc2c46
Compare
Contributor
Author
|
I don't understand how suppression isn't necessary as it's a |
jjohnstn
approved these changes
May 13, 2026
Contributor
jjohnstn
left a comment
There was a problem hiding this comment.
Looks good. Getting this in will allow us to properly exercise the code via jdt.ls testing.
Contributor
There is a compiler option to ignore assigning raw types to parameterized ones. This option is set by default for jdt.core because this happens a lot due to legacy code. |
Contributor
Author
Thanks! |
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
Enable cross-language call hierarchy by using contributed search participants in both incoming and outgoing call analysis.
Incoming calls (
CallerMethodWrapper)Replace hardcoded
new SearchParticipant[] { getDefaultSearchParticipant() }withSearchEngine.getSearchParticipants()so that incoming call searches include results from contributed search participants registered via theorg.eclipse.jdt.core.searchParticipantextension point. For contributed (non-Java) elements, acceptA_INACCURATEmatches since JDT'sMatchLocatorcannot resolve type bindings for types not compiled by ECJ.Outgoing calls (
CalleeMethodWrapper)When the member has no Java AST (i.e.
getCompilationUnitNode()returns null), fall back toSearchParticipant.locateCallees()on all contributed participants. Each participant can report call sites within the member's body. Returned callees are resolved to full declarations viaresolveCallee(), which handlesMETHOD,FIELD, andTYPEelement types.Outgoing calls from Java to non-Java targets (
CalleeAnalyzerVisitor)When a Java method invocation has a null ECJ binding (receiver type is from a contributed language, not compiled by ECJ), fall back to
resolveViaSearch()which usesSearchEngine.getSearchParticipants()to findMETHODDECLARATIONSmatching the method name across all contributed participants.Declaration resolution with filtering (
CallHierarchyCore.findFirstDeclaration)Shared utility method
findFirstDeclaration()searches for the first matchingIMemberdeclaration by name, with optional post-filters applied inacceptSearchMatch():Non-standard
ICompilationUnithandling (CallHierarchyCore)getCompilationUnitNode()withisJavaLikeFileName()check so non-Java source files (e.g..kt) are not parsed as Java ASTClassCastExceptionfor non-standardICompilationUnitimplementations that do not implement the internal compiler interface required byASTParser.createAST()Dependency
Bump
org.eclipse.jdt.coredependency to[3.46.0,4.0.0)for theSearchEngine.getSearchParticipants()andSearchParticipant.locateCallees()APIs.Related PRs
searchParticipantextension point,SearchParticipantRegistry,SearchEngine.getSearchParticipants(), andSearchParticipant.locateCallees()SearchEngine.getSearchParticipants()Test plan
CallHierarchyParticipantTest:searchParticipantsIncludesContributed— verifies contributed participant is returned bygetSearchParticipants()outgoingCallsJavaASTPathUnchanged— regression: Java AST callee analysis still worksoutgoingCallsFallBackToParticipants—locateCallees()called for binary members without source, returns 2 calleesoutgoingCallsResolvesExistingCallees— existingIMembercallees resolved directlyoutgoingCallsFallBackOnClassCastException— non-standardICompilationUnittriggersClassCastException, falls back to participant pathincomingCallsUsesAllParticipants— regression: incoming call search with all participants finds Java callers correctlyCallHierarchyTesttests pass (regression)