Skip to content

Add project-only reference search scope - #3850

Open
mielientiev wants to merge 5 commits into
eclipse-jdtls:mainfrom
mielientiev:feature/project-only-search-scope
Open

Add project-only reference search scope#3850
mielientiev wants to merge 5 commits into
eclipse-jdtls:mainfrom
mielientiev:feature/project-only-search-scope

Conversation

@mielientiev

Copy link
Copy Markdown

Fixes #3821.

When projectOnly is 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.4s
  • projectOnly: ~1.9s
  • Speedup: ~14.5x

@eclipse-ls-bot

Copy link
Copy Markdown
Contributor

Can one of the admins verify this patch?

@angelozerr

Copy link
Copy Markdown

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.

@angelozerr

Copy link
Copy Markdown

@datho7561 please review the PR. Thanks!

@datho7561

Copy link
Copy Markdown
Contributor

@angelozerr were you hoping for the new scope to be used anywhere, or were you planning on doing that yourself somewhere through an extension?

@angelozerr

Copy link
Copy Markdown

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 datho7561 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@angelozerr

Copy link
Copy Markdown

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.

When this PR will be merged, is there a way to download jdtls with this feature?

@datho7561

Copy link
Copy Markdown
Contributor

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

@angelozerr

Copy link
Copy Markdown

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 !

@mielientiev

Copy link
Copy Markdown
Author

@datho7561 done!

@datho7561
datho7561 self-requested a review July 17, 2026 20:53
@mielientiev

Copy link
Copy Markdown
Author

@datho7561 please review when you have time

@datho7561 datho7561 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I will fix in a couple of days!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add "projectOnly" scope to java.search.scope setting to exclude JDK and library references

4 participants