Bug 541139

Summary: Search should honor project hierarchy and favor resources from nested projects
Product: [Eclipse Project] Platform Reporter: Peter Palaga <ppalaga>
Component: SearchAssignee: Platform-Search-Inbox <platform-search-inbox>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3 CC: gautier.desaintmartinlacaze, karsten.thoms, mistria
Version: 4.10   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Peter Palaga CLA 2018-11-14 05:34:23 EST
Steps to reproduce:

1. Clone and import a Maven project with several modules in a hierarchy, e.g. https://github.com/wildfly-extras/wildfly-camel

2. Activate the hierarchic project representation in Project Explorer

3. Search for a string that occurs in a pom.xml file at some lower level in the hierarchy: 

3.1 Select the root module in Project Explorer by clicking it

3.2 In the main menu Search > File... 

3.3 In the Search dialog: 
  Containing text (e.g.): <project
  File name patterns: pom.xml
  Scope: Selected resource in Project Explorer
  Click the Search button

4. Search results view opens

Expected: The matches in files that are under submodules are presented as such. E.g. the ancestor nodes of archetypes/archetype-cdi/pom.xml shoud be presented as Eclipse project nodes, rather than bare folder nodes. Note that archetypes and archetype-cdi are present in the workspace as eclipse projects.

Actual: The matches in files that are under submodules are presented as matches under bare folders.

Why this is important:

If I open a match from the results view by double clicking it, it opens an editor with an improper source (the plain path archetypes/archetype-cdi/pom.xml). In editors opened in this way, many actions do not work as expected. E.g. for XML and Java files, context menu > show in > Project Explorer does not work. For Java files, if the project is not set properly, there is no Java assist, no CTRL-Click navigation, etc.
Comment 1 Mickael Istria CLA 2018-11-14 06:19:03 EST
For backward compatibility, I think it has to be an option in the Search dialog.
The option could be titled "Prefer showing equivalent resources from nested projects".
This can most likely be implemented directly in the Search API or view as a transformation of the result. I believe having it in the Search API would be more powerful and reusable.

Then, that option could be pre-set according to whether end-users already uses hierarchical view.

Note that while it's related in term of user-story, there is no technical relationship between this case and how the projects are presented in the view (flat vs hierarchical).