Add searchParticipant extension point for javaDerivedSource indexing#4938
Add searchParticipant extension point for javaDerivedSource indexing#4938arcivanov wants to merge 1 commit intoeclipse-jdt:masterfrom
Conversation
1692a79 to
f0228b3
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds a new org.eclipse.jdt.core.searchParticipant extension point so external bundles can contribute SearchParticipant implementations for indexing/searching non-Java files registered under the javaDerivedSource content type (e.g., Kotlin/Scala/Groovy), and wires derived-source indexing into JDT Core’s indexing and delta processing pipelines.
Changes:
- Introduces
SearchParticipantRegistryto load/search participants by file extension and react to registry changes. - Routes
javaDerivedSourcefiles through contributed participants during initial indexing, folder indexing, and resource delta processing. - Adds new public API
SearchEngine.getSearchParticipants()(default + contributed) and adds tests validating registry behavior and derived-source indexing.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/SearchParticipantRegistry.java | New registry for discovering/caching participants and mapping them by extension. |
| org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexManager.java | Adds addDerivedSource() to schedule derived-source indexing via a contributed participant. |
| org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexAllProject.java | Extends full-project indexing to discover/index derived-source files in source folders. |
| org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddFolderToIndex.java | Extends folder indexing to include derived-source files with registered participants. |
| org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/BasicSearchEngine.java | Adds internal helper returning default + contributed participants. |
| org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchEngine.java | New public API getSearchParticipants() exposing default + contributed participants. |
| org.eclipse.jdt.core/schema/searchParticipant.exsd | Defines the new searchParticipant extension point schema. |
| org.eclipse.jdt.core/pom.xml | Bumps bundle Maven version to 3.46.0-SNAPSHOT. |
| org.eclipse.jdt.core/plugin.xml | Registers the new searchParticipant extension point. |
| org.eclipse.jdt.core/plugin.properties | Adds translatable name for the new extension point. |
| org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessor.java | Handles add/change/remove deltas for derived-source files (mirrors CU behavior). |
| org.eclipse.jdt.core/META-INF/MANIFEST.MF | Bumps OSGi bundle version to 3.46.0.qualifier. |
| org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TestDerivedSourceSearchParticipant.java | Test participant implementation used by indexing tests. |
| org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TestDerivedSearchDocument.java | Test SearchDocument for derived-source files (reads workspace content). |
| org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/DerivedSourceSearchParticipantTests.java | New tests covering registry behavior and derived-source indexing pipeline. |
| org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AllJavaModelTests.java | Registers the new derived-source participant test suite. |
| org.eclipse.jdt.core.tests.model/plugin.xml | Contributes a test javaDerivedSource file association + searchParticipant extension. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
f0228b3 to
d90fdff
Compare
|
An integration demo (that is stubbed out but won't be for long is available here): https://github.com/karellen/karellen-jdtls-kotlin |
d90fdff to
e08990e
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.searchParticipant` extension point.
Outgoing calls (CalleeMethodWrapper):
When the member has no Java AST (i.e. `getCompilationUnitNode()` returns
null), fall back to `SearchParticipant.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.
Non-standard ICompilationUnit handling (CallHierarchyCore):
Catch `ClassCastException` in `getCompilationUnitNode()` for non-standard
`ICompilationUnit` implementations (e.g. from contributed search
participants) that do not implement the internal compiler interface
(`org.eclipse.jdt.internal.compiler.env.ICompilationUnit`) required by
`ASTParser.createAST()`. Returns null to fall through to the participant
path.
Dependency:
Bump `org.eclipse.jdt.core` dependency to `[3.46.0,4.0.0)` for the
`SearchEngine.getSearchParticipants()` and `SearchParticipant.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.
57b2ef4 to
33b60c0
Compare
Extend JDT Core's indexing pipeline to discover and index files registered under the javaDerivedSource content type (e.g. .kt, .scala, .groovy) via contributed SearchParticipant implementations. Changes: - New org.eclipse.jdt.core.searchParticipant extension point with schema - SearchParticipantRegistry: loads contributed participants by file extension from the extension registry, listens for dynamic bundle load/unload via IRegistryEventListener to invalidate cached state automatically - IndexManager.addDerivedSource(): routes derived files to their registered participant instead of the default JavaSearchParticipant - IndexAllProject: discovers javaDerivedSource files alongside Java files in source folders and indexes them via addDerivedSource() - AddFolderToIndex: same derived file discovery for folder additions - DeltaProcessor: handles add/change/remove deltas for derived source files - SearchEngine.getSearchParticipants(): new API returning the default participant plus all contributed participants - SearchParticipant.locateCallees(): new default method enabling contributed participants to report outgoing call sites for non-Java members, used by the call hierarchy engine when Java AST-based callee analysis is not available - OrPattern.getPatterns(): new public accessor so contributed participants can decompose OrPattern (e.g. REFERENCES + DECLARATIONS) for correct pattern-type dispatch in locateMatches() - SearchParticipantRegistry.getLanguageId(): new API returning the LSP language identifier for a given file extension, from the optional languageId attribute on the extension point registration - Fully backwards-compatible: no registered participants = identical behavior
33b60c0 to
8b7f31e
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.searchParticipant` 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 `SearchParticipant.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 `SearchParticipant.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.
Summary
org.eclipse.jdt.core.searchParticipantextension point allowing external OSGi bundles to registerSearchParticipantimplementations for non-Java source files (e.g..kt,.scala,.groovy) that are registered under thejavaDerivedSourcecontent typeSearchParticipantRegistryeagerly loads contributed participants by file extension from the extension registry, and listens for dynamic bundle load/unload viaIRegistryEventListenerto reload automaticallyIndexManager.addDerivedSource()routes derived files to their registered participant instead of the defaultJavaSearchParticipantIndexAllProjectandAddFolderToIndexdiscoverjavaDerivedSourcefiles alongside Java files in source folders and index them viaaddDerivedSource()DeltaProcessorhandles add/change/remove deltas for derived source files, mirroring the compilation unit indexing patternSearchEngine.getSearchParticipants()new API returning the default participant plus all contributed participantsSearchParticipant.locateCallees()new default method enabling contributed participants to report outgoing call sites for non-Java members, used by the call hierarchy engine (inorg.eclipse.jdt.core.manipulation) when Java AST-based callee analysis is not availableOrPattern.getPatterns()new public accessor so contributedSearchParticipantimplementations can decomposeOrPattern(e.g. REFERENCES + DECLARATIONS combined byReferencesHandlerwhenincludeDeclaration=true) for correct pattern-type dispatch inlocateMatches()SearchParticipantRegistry.getLanguageId()new API returning the LSP language identifier for a given file extension, from the optionallanguageIdattribute on the extension point registration; enables language server handlers to tag hover content with the correct language (e.g."kotlin"instead of"java")Companion PRs
SearchEngine.getSearchParticipants()instead of hardcoding only the default Java participantCallerMethodWrapperto usegetSearchParticipants()for incoming call hierarchy searches, andCalleeMethodWrapperto fall back tolocateCallees()for outgoing call hierarchy when no Java AST is availableTest plan
DerivedSourceSearchParticipantTestscovering:SearchEngine.getSearchParticipants()returns default + contributed participants