vi-eclipse / Eclipse-Platform

Umbrella repository for managing a backlog of features/issues related to the Eclipse Platform
2 stars 0 forks source link

Add Additional Full-Text Search Scope for Referenced Libraries #17

Open HeikoKlare opened 1 year ago

HeikoKlare commented 1 year ago

Current Behavior

The Eclipse full-text search search does only provide the ability to search in files within the workspace. It does not provide the ability to search within, e.g., included libraries either placed as JARs within a project or provided via the target platform.

Expected Behavior

It shall be possible to search for contents of Java files within references libraries of a Java / plug-in project via the full-text search. Important scopes for us are:

To this end, there shall be an additional Search In option within the File Search that allows to search within additional resources referenced by a project, such as libraries used by a Java or plug-in project. What exactly shall be included in these referenced resources is a matter of the type of project and matter of further discussion when providin the feature as a PR. Also the name of this search option has to be defined is mocked as "project-referenced resources" in the follow image:

Image

The semantics of that option shall be that for all projects contained within the search scope, their references resources shall be searched as well. To this end, a Project has to be extended to provide its referenced resources (or it has to be provided via a project nature). Basically, this should be everything that is represented under the project in the project tree (such as the project explorer). As an example, a Java project should provide everything referenced via the classpath, and a plug-in project should provide the plug-in dependencies provided via the target platform.

The search within these referenced resource should behave as if they were contained as folders within the project tree, as also defined for searching within archives in #18. This feature should thus depend on #18 and reuse the functionality for searching within archives for, e.g., searching within referenced Java libraries.

Problem Analysis

The problem can be split up into two parts:

  1. Searching in Archives: Referenced libraries / JARs are archive files, which the full-text search can currently only process as binary files but of which it cannot consider its contents. As a preliminary for the extended search, functionality has to be provided to search within archive files:

    18

  2. Search Scope for Referenced Libraries: On top of that basic search-in-archives functionality, the full-text search has to be extended by an additional scope for referenced libraries that is capable of considering other places than the what is directly contained in projects within the workspace and also to consider those artifacts as archives. One challenge here is to define what shall be considered a "reference library", as this depends on the project type, such as Maven dependencies in Maven projects, JRE and other classpath-referenced libraries in Java projects or Plug-in dependencies in Plug-in projects.

This issue requires the first part as a preliminary realized by #18 and focuses on realizing the second part on top of it.

Solution Increments

  1. Realize a prototype that is capable of searching within referenced libraries of a plug-in project (i.e., in the JRE library in the target platform dependencies), i.e., mock the provision of referenced resources for this step.
  2. Extend the project API (or (re-)use project natures) to provide referenced resources, implement this for plug-in projects and apply the prototype search.
  3. Provide the search extension together with whatever is required as project extension to make it work.
  4. Provide implementations of referenced resource provision for common projects / natures, such as plug-in or Java.

Additional Information

There is a project that has already developed a search function that potentially covered the explained use case: https://github.com/ajermakovics/eclipse-instasearch

CodeLtDave commented 1 year ago

Objective:

Extend the Eclipse File Search to include the ability to search within dependencies.

Approach Used:

  1. Existing Java Search Method:

    • Instead of extending File Search directly, we leveraged the Java Search approach which utilizes the Abstract Syntax Tree (AST).
    • Java Search has built-in capability to probe into included libraries, making it an appropriate avenue for our goal.
  2. Attempt at a Workaround:

    • Goal: Enable Java Search to find String literals.
    • Challenge: Java Search doesn't build ASTs for each compilation unit. Instead, it leverages an indexing mechanism to identify relevant compilation units.
      • Why is this significant? Without indexing, searching would be infeasible due to extended search times.

Findings:

  1. Effort vs Reward:

    • Extending the JavaSearch with StringLiterals would require considerable effort:
      1. Significant amendments to the current indexing mechanism.
      2. Or accept highly inconvenient runtimes, making the solution impractical for real-world use.
  2. Limitation of Direct Extension:

    • It's not viable to directly extend Java Search for string literals without addressing the indexing challenge.

Conclusion:

The path to extending the Eclipse File Search to include searching within dependencies, though conceivable, presents substantial challenges in terms of implementation and efficiency. There is not apparent easy solution using existing functionality provided by the Java Search to achieve a similar workaround solution. A viable solution would require much in depth work, especially in understanding and adapting the File Search Engine.