Skip to content

Add Java projects to classpath container org.eclipse.pde.core.externaJavaSearch#2270

Closed
trancexpress wants to merge 1 commit intoeclipse-pde:masterfrom
trancexpress:gh2269
Closed

Add Java projects to classpath container org.eclipse.pde.core.externaJavaSearch#2270
trancexpress wants to merge 1 commit intoeclipse-pde:masterfrom
trancexpress:gh2269

Conversation

@trancexpress
Copy link
Copy Markdown
Contributor

The classpath container org.eclipse.pde.core.externalJavaSearch skips adding plug-ins if a respective project is found in the workspace. This can result in unexpected behavior when browsing code from the container, such as wrong syntax highlighting, navigation and search results.

This change adjusts the classpath container to contain also projects found in the workspace.

Fixes: #2269

@trancexpress
Copy link
Copy Markdown
Contributor Author

Are there tests for this container? I'm not sure what to search for, I'm not finding any.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 23, 2026

Test Results

  147 files  ±0    147 suites  ±0   33m 1s ⏱️ - 2m 24s
3 498 tests +1  3 444 ✅ +1   54 💤 ±0  0 ❌ ±0 
9 315 runs  +3  9 185 ✅ +3  130 💤 ±0  0 ❌ ±0 

Results for commit ba914fa. ± Comparison against base commit 4808f71.

♻️ This comment has been updated with latest results.

@laeubi
Copy link
Copy Markdown
Contributor

laeubi commented Mar 24, 2026

The classpath container org.eclipse.pde.core.externalJavaSearch skips adding plug-ins if a respective project is found in the workspace.

From the naming and from the code it looks like it is intentional... So I think you should do some research what was the reason for this. At a minimum one need to revise the javadoc of the class (and possible other documentations as well).

@trancexpress
Copy link
Copy Markdown
Contributor Author

From the naming and from the code it looks like it is intentional... So I think you should do some research what was the reason for this.

The project is used to be able to browse target platform code, search in it and so on. I'm sure its intentional, otherwise you woyld e.g. get double search results - one for the project in the workspace, one for the External Plug-in Libraries project.

I'll see if I can find something in the git history, maybe there is a Bugzilla ticket.

@trancexpress
Copy link
Copy Markdown
Contributor Author

trancexpress commented Mar 24, 2026

The source plug-in was omitted for: https://bugs.eclipse.org/bugs/show_bug.cgi?id=197817

I20070724-0800

Has already been reported as fixed in bug 56501, but apparently, no regression test caught the reappearance of this problem.

  • new workspace
  • Plug-ins view
  • Select All
  • Add to Java Search
  • import org.eclipse.core.expressions as source
  • Navigate > Open Type, enter "AndExpression"
    => two matches for same class (from source and from External Plug-in Libraries)

With this PR, I don't see multiple matches for: org.eclipse.core.expressions.AndExpression

image

Unfortunately no test was added for the problem: https://bugs.eclipse.org/bugs/attachment.cgi?id=75349&action=diff

I'm not sure how complicated a test is... I'll check if there are tests for the PDE plug-in container, maybe we can mimic those.

@trancexpress
Copy link
Copy Markdown
Contributor Author

trancexpress commented Mar 24, 2026

I added a test, unfortunately its quite slow... ~18 seconds on my laptop. Most of the time is spent indexing the container.

@trancexpress
Copy link
Copy Markdown
Contributor Author

trancexpress commented Apr 10, 2026

@iloveeclipse can you take a look here? Whenever I try to use the external plug-ins project, half the time it doesn't work:

image

All the non-highlighted text is useless, cannot use call hierarchy, navigation and so on.

The only way to work with Eclipse code seems to be to import sources...

…lJavaSearch

The classpath container org.eclipse.pde.core.externalJavaSearch
skips adding plug-ins if a respective project is found in the workspace.
This can result in unexpected behavior when browsing code from the container,
such as wrong syntax highlighting, navigation and search results.

This change adjusts the classpath container to contain
also projects found in the workspace.

A test is also added for the initial bug fix, due to which workspace projects are skipped:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=197817

Fixes: eclipse-pde#2269
@iloveeclipse
Copy link
Copy Markdown
Member

This change adjusts the classpath container to contain also projects found in the workspace.

Just from the name alone external java search means, the original idea was to reference only sources that are not in the workspace. So the proposal to add the projects in the workspace to that container doesn't make sense for me, it just does the opposite of what it should be done. See the javadoc of the SearchablePluginsManager class.

If this PR fixes the problem, it is likely it fixes some bug in a different place, like indexer not properly triggered after dependencies update etc.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adjusts the PDE “External Plug-in Libraries” (externalJavaSearch) classpath container so that when a plug-in exists as a Java project in the workspace, that project is added to the container (instead of skipping the plug-in entirely), addressing IDE navigation/highlighting/search inconsistencies (Fixes #2269).

Changes:

  • Update SearchablePluginsManager to add workspace Java projects as CPE_PROJECT entries when available.
  • Add a regression UI test validating Java type search returns a single, correct match before and after importing a plug-in project.
  • Register the new test in the PDE UI test suite.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/SearchablePluginsManager.java Adds workspace Java projects to the externalJavaSearch container entries when present.
ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/core/tests/internal/classpath/ExternalJavaSearchClasspathContainerTests.java New regression test for Java search behavior with imported workspace plug-in projects.
ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/AllPDETests.java Includes the new test in the overall PDE test suite.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +75 to +79
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject proxyProject = root.getProject(SearchablePluginsManager.PROXY_PROJECT_NAME);
assertNotNull("Adding " + SearchablePluginsManager.PROXY_PROJECT_NAME + " failed", proxyProject);
IJavaProject javaProject = JavaCore.create(proxyProject);

Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

IWorkspaceRoot#getProject(String) never returns null (it returns a project handle even if the project doesn’t exist), so assertNotNull here won’t actually verify that the command created/opened the proxy project. Consider asserting proxyProject.exists()/proxyProject.isOpen() (and optionally PluginProject.isJavaProject(proxyProject) or javaProject.exists()) to make test failures clearer and more accurate.

Copilot uses AI. Check for mistakes.
List<String> matches = performSearch(javaProject, fqn);
assertSingleMatch(expected, matches);

IPluginModelBase plugin = PluginRegistry.findModel(pluginId);
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

PluginRegistry.findModel(pluginId) can return null (e.g., if the bundle isn’t present in the running target for the test), which would cause a confusing NPE later in the import. Add an assertNotNull for plugin (with a helpful message) before building the plugins array.

Suggested change
IPluginModelBase plugin = PluginRegistry.findModel(pluginId);
IPluginModelBase plugin = PluginRegistry.findModel(pluginId);
assertNotNull("Required plug-in model not found for '" + pluginId
+ "'. The test target may be missing this bundle.", plugin);

Copilot uses AI. Check for mistakes.
Comment on lines +82 to +85
// expect a match like this:
// .../plugins/org.eclipse.equinox.common_3.20.300.v20251111-0312.jar|org/eclipse/core/runtime/IProgressMonitor.class
String expected = ".*.jar\\|" + fqn.replace('.', '/') + ".class";

Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

The expected-path regex is very permissive because . isn’t escaped in .*.jar and .class. This can lead to accidental matches and flaky tests. Consider using .*\\.jar\\| and \\.class, or build the fixed parts using Pattern.quote(...).

Copilot uses AI. Check for mistakes.

// expect a match like this:
// /org.eclipse.core.expressions/org.eclipse.core.expressions_3.9.500.v20250608-0434.jar|org/eclipse/core/expressions/AndExpression.class
expected = pluginProject.getFullPath() + ".*.jar\\|" + fqn.replace('.', '/') + ".class";
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

pluginProject.getFullPath() contains dots which are regex metacharacters; concatenating it directly into the regexp can match unintended paths. Use Pattern.quote(pluginProject.getFullPath().toString()) (and escape \\.jar/\\.class) to make the assertion precise and resilient.

Suggested change
expected = pluginProject.getFullPath() + ".*.jar\\|" + fqn.replace('.', '/') + ".class";
expected = Pattern.quote(pluginProject.getFullPath().toString()) + ".*\\.jar\\|" + fqn.replace('.', '/') + "\\.class";

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

@iloveeclipse iloveeclipse left a comment

Choose a reason for hiding this comment

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

I believe this is the wrong place to fix the issue. I would propose to close the PR.

@trancexpress
Copy link
Copy Markdown
Contributor Author

Just from the name alone external java search means, the original idea was to reference only sources that are not in the workspace. So the proposal to add the projects in the workspace to that container doesn't make sense for me, it just does the opposite of what it should be done. See the javadoc of the SearchablePluginsManager class.

If this PR fixes the problem, it is likely it fixes some bug in a different place, like indexer not properly triggered after dependencies update etc.

The problem is explained here: #2269 (comment)

For anything not found in the container, there is a 2nd search with relaxed criteria. But for things found in the container (and they are searched by string-search), that type is used for whichever functionality. So navigation stops working.

@trancexpress
Copy link
Copy Markdown
Contributor Author

I believe this is the wrong place to fix the issue. I would propose to close the PR.

Sure.

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.

Navigation problems in IDEApplication from External Plug-in Libraries project

4 participants