Add project-only reference search scope - #3850
Conversation
|
Can one of the admins verify this patch? |
|
That's super great @mielientiev ! Thanks so much to have worked on this issue. It will speed up the MCP Server that I am working on it. |
|
@datho7561 please review the PR. Thanks! |
|
@angelozerr were you hoping for the new scope to be used anywhere, or were you planning on doing that yourself somewhere through an extension? |
|
No I would like to use JDT.LS. My plan is to manage settings.json like vscode does to call JDT.LS with vscode java settings. In other words if user will set settings.json with projectOnly (for their project in vscode), my JDT.LS wiill use it. |
datho7561
left a comment
There was a problem hiding this comment.
Code looks good and tests pass. The search scope currently isn't being used anywhere outside of the tests, so I'd appreciate a follow up from Angelo for what his specific plan is.
@mielientiev Do you mind signing the ECA? Unfortunately, we can't accept the PR until you've done that.
When this PR will be merged, is there a way to download jdtls with this feature? |
There will be a nightly build here: https://download.eclipse.org/jdtls/snapshots |
That's super great! Once it will be available I will try it and give you feedback. Thanks @datho7561 ! |
|
@datho7561 done! |
|
@datho7561 please review when you have time |
datho7561
left a comment
There was a problem hiding this comment.
Sorry it took so long to review properly. It's looking pretty good, and it's a very good performance boost for eg. looking for all occurances of System.out.println in a project. Found another spot where I think it'd be helpful to apply the setting.
I'll put up a quick PR in vscode-java for the client side changes necessary to adopt this, which should make it easier to try out for anyone whose curious.
| int includeMask = IJavaSearchScope.SOURCES | IJavaSearchScope.REFERENCED_PROJECTS | IJavaSearchScope.APPLICATION_LIBRARIES; | ||
| if (isInsideJRE(elementToSearch)) { | ||
| includeMask |= IJavaSearchScope.SYSTEM_LIBRARIES; | ||
| SearchScope searchScope = preferenceManager.getPreferences().getSearchScope(); |
There was a problem hiding this comment.
I think it'd be helpful to also use the preference in WorkspaceSymbolHandler. Workspace symbols are used to fuzzy search for classes. It can be opened with Ctrl+T in VS Code
There was a problem hiding this comment.
Thanks, I will fix in a couple of days!
Fixes #3821.
When
projectOnlyis enabled, reference searches include workspace sources, tests, and referenced projects, while excluding external libraries and the JDK. The existing behavior remains unchanged by default.In a small project benchmark, some reference searches were approximately 5x to 15x faster:
all: ~27.4sprojectOnly: ~1.9s