Bug 199994 - [search] Search for text in Java files (including attached source )
Summary: [search] Search for text in Java files (including attached source )
Status: CLOSED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal with 5 votes (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
: 237159 (view as bug list)
Depends on: 23341
Blocks: 247503 161398
  Show dependency tree
 
Reported: 2007-08-15 04:01 EDT by Martin Aeschlimann CLA
Modified: 2020-03-28 12:41 EDT (History)
8 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Aeschlimann CLA 2007-08-15 04:01:00 EDT
3.3

Often you want to find a string in a comment or string literal which can also be in a class file (resp. its attached source).

We see two approaches:
a.) add it to file search: Extensions can provide source content to archive files and class files. File search then would use these files instead of the binary content to search
b.) add it to Java search: Add a new search option 'Text references'

I believe there are two many problems with a.): How to present matches (file search result view only shows resources), how to open a match, what if the user really wants to search the content of the binary file, how to specify a scope 
b.) has the advantage that the search scope are Java aware, the result view shows Java elements, etc.

The question is, where would b.) be implemented. It could be implemented in the UI, as we know how to visit all Java files and look at their content.
But maybe it would be better if jdt.core does it, as the search could also be useful for other clients.
Comment 1 Martin Aeschlimann CLA 2007-08-15 04:02:53 EDT
Adding Jerome and Frederic for opinions. We have added this item to our (proposed) 3.4 plan.
Comment 2 Frederic Fusier CLA 2007-08-15 06:25:10 EDT
There's already a request on JDT/Core for this kind of search: bug 16426. Not sure that current SearchEngine would allow this kind search of without deep changes...
Comment 3 Martin Aeschlimann CLA 2007-08-15 06:57:09 EDT
I think a brute force text search (no index) would be good enough. That's what we also do in file text search.
Comment 4 Jerome Lanneluc CLA 2007-08-16 04:52:47 EDT
(In reply to comment #3)
> I think a brute force text search (no index) would be good enough. That's what
> we also do in file text search.
> 
How would that scale ?
Comment 5 Martin Aeschlimann CLA 2007-08-16 05:36:52 EDT
Yes, according to our experiences in text search this scales well for common user scenarios.
Comment 6 Dani Megert CLA 2007-08-22 06:11:43 EDT
Besides finding stuff in comments it would be very useful to find where constants are references - something that Java search currently can't do for .class files.

Personally I'd like to see this implemented in JDT Core and not JDT UI.
Comment 7 Philipe Mulet CLA 2007-08-31 13:15:28 EDT
There are 2 issues here.
1. pure text search in attached sources
2. java text search in comment/literals

Comment 8 Dani Megert CLA 2007-09-04 05:42:22 EDT
>There are 2 issues here.
>1. pure text search in attached sources
This is what I would like to see most. Would use this to find constant refs and code patterns.

>2. java text search in comment/literals
What exactly do you mean with 'java text'? Types, members etc? Keywords?

A simple text search where I can select the scope (string literal, documentation comment, traditional comment, end-of-line comment, all) would fit needs.
Comment 9 Martin Aeschlimann CLA 2007-09-06 10:06:28 EDT
Regarding the search scope (only comments, only literals..)

I think we should keep the search as general as possible but offer the possibility to limit matches to
- comments
- literals

But if the user wants, he can also use reg-ex on the code.
Comment 10 Martin Aeschlimann CLA 2007-09-12 11:31:22 EDT
Moving to JDT core as discussed.
Comment 11 Jerome Lanneluc CLA 2007-09-19 09:42:58 EDT
Time permitting for 3.4
Comment 12 Dani Megert CLA 2008-02-11 10:55:15 EST
This involves API. We should decide now whether we do this for 3.4.
Comment 13 Jerome Lanneluc CLA 2008-02-13 10:50:22 EST
Not for 3.4
Comment 14 Jerome Lanneluc CLA 2008-02-13 10:51:36 EST
One idea would be to ask Platform/Resources to have EFS leverage JAR entries as resources
Comment 15 Markus Keller CLA 2008-08-13 09:20:02 EDT
> One idea would be to ask Platform/Resources to have EFS leverage JAR entries as
> resources

That would then be bug 23341, which is blocked by bug 23265.

But I would rather go into the direction of comment 7 and comment 8 and add a source-attachment-aware brute-force textual search.

E.g. add something like SearchEngine.searchText(String pattern, int matchRule, IJavaSearchScope, SearchRequestor, IProgressMonitor), where matchRule supports SearchPattern.R_EXACT_MATCH, R_REGEXP_MATCH, R_CASE_SENSITIVE.

The reported results would be of type TextSearchMatch, which also has queries isInsideLineComment(), isInsideBlockComment(), isInsideStringLiteral(), or even int getEnclosingTokenId() (which returns a constant from ITerminalSymbols) and maybe int[] getCoveredTokenIds() (which returns a set of ids of all tokens that intersect with the match range).
Comment 16 Philipe Mulet CLA 2008-09-10 06:11:23 EDT
Targeting 3.5 for a brute force solution. 
Comment 17 Jerome Lanneluc CLA 2008-09-25 05:11:34 EDT
It seems that the main purpose of this bug is to address the "constant reference in .class files" issue. This is bug 12044. 

Once this is addressed, we can address the pure text search issue providing some support from Platform/Search (e.g. we would implement an extension point to give the source to search to the text search framework).
Comment 18 Dani Megert CLA 2008-09-25 05:33:47 EDT
Suggest to wait for bug 23341.
Comment 19 Jerome Lanneluc CLA 2008-09-25 05:54:01 EDT
Actually this bug is blocked by bug 23341. Moving 23341 from "Blocks:" to "Depends on:".

Also removing this bug from JDT/Core plan for 3.5 (unless bug 23341 is resolved :-) )
Comment 20 Dani Megert CLA 2008-09-25 05:57:01 EDT
>Actually this bug is blocked by bug 23341. Moving 23341 from "Blocks:" to
>"Depends on:".
Right, pasted too fast.
Comment 21 Dani Megert CLA 2012-01-23 03:00:55 EST
*** Bug 237159 has been marked as a duplicate of this bug. ***
Comment 22 Eclipse Genie CLA 2020-03-28 12:41:58 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.