This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 202628

Summary: Search with "grep -A and -B" like options
Product: utilities Reporter: ecerichter
Component: SearchAssignee: Jaroslav Havlin <jhavlin>
Status: RESOLVED FIXED    
Severity: normal CC: markiewb
Priority: P3    
Version: 7.3   
Hardware: All   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:

Description ecerichter 2011-09-25 14:08:37 UTC
When I use grep (Linux, command line), I can specify –A n to show ‘n’ lines after the match; similary I can specify –B n to show ‘n’ lines before the match.
It’s possible to consider add this feature to the search feature of NetBeans, because when I’m searching for something in an annotation, the annotation itself is useless for me.

For example, if I search for “FetchType.EAGER” it brings me all occurrences of FechType.EAGER; then I have to open each file and search again for the term to discover where it’s.
If I can specify –A 1 or –A 3 (or have a option for “Show ‘n’ lines after match”, I’ll see (and be able to “double-click”) the line that have the real information I need.

Thanks,

Edson.
Comment 1 ecerichter 2012-11-15 17:47:09 UTC
A possible solution is to use the tooltip baloon to show a code block from few lines before and few lines after (configurable?). Having a default of at least 3 before and 3 after would help already.

Regards,

Edson
Comment 2 Jaroslav Havlin 2012-11-16 08:43:47 UTC
We'll discuss it for the next release. But it can be difficult, because some users might find the tooltip obtrusive.

Finding the optimal number of surrounding lines is not trivial. Why do you think 3 is appropriate?

Did you try navigating with Ctrl+Comma and Ctrl+Period in the editor. Then you can see the whole file. I usually use it when I need to see the context of matching lines.

Kind regards, and thanks for reporting.
Comment 3 ecerichter 2012-11-16 14:22:08 UTC
The tooltip already exists, and is completely useless: it indicates the line and column of the match. Would be much more useful if it shows the block of code surrounding the match.

Regarding the magic number 3, actually is based on my guess (and experience: 90% of time, I'm interested in one or two lines above and below the match).

Regards,

Edson
Comment 4 Jaroslav Havlin 2012-11-19 08:50:50 UTC
(In reply to comment #3)
> The tooltip already exists, and is completely useless: 
Probably, some users in forums claimed that it should be removed completely.

> Would be much more useful if it shows the block of code surrounding
> the match.
Yes, the question is whether it is better to have nothing, or even
bigger pop-up.

Thank you.
Comment 5 ecerichter 2012-11-19 13:26:51 UTC
(In reply to comment #4)
> (In reply to comment #3)
> > The tooltip already exists, and is completely useless: 
> Probably, some users in forums claimed that it should be removed completely.

It can be easily solved by a "enabled/disabled" option, as well the number of shown lines "before" and "after".

> 
> > Would be much more useful if it shows the block of code surrounding
> > the match.
> Yes, the question is whether it is better to have nothing, or even
> bigger pop-up.

In my case, a bigger popup would save me a lot of opened editors (you can imagine I'm looking for CascadeType annotation in a project with 1000 persistent java classes, and having to open each one to check if they are related or not the what I'm looking for).

> 
> Thank you.
Comment 6 Jaroslav Havlin 2012-11-23 16:16:20 UTC
(In reply to comment #4)
> (In reply to comment #3)
> > The tooltip already exists, and is completely useless: 
> Probably, some users in forums claimed that it should be removed completely.
http://hg.netbeans.org/core-main/rev/e738ab1e42f8
The tool tip was removed.

> In my case, a bigger popup would save me a lot of opened editors (you can
> imagine I'm looking for CascadeType annotation in a project with 1000
> persistent java classes, and having to open each one to check if they are
> related or not the what I'm looking for).
It might be added in the next release.
Comment 7 Quality Engineering 2012-11-24 13:08:57 UTC
Integrated into 'main-golden', will be available in build *201211240959* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/e738ab1e42f8
User: Jaroslav Havlin <jhavlin@netbeans.org>
Log: #202628: Removing useless tooltip from text detail node in Search Results window
Comment 8 Jaroslav Havlin 2013-02-19 16:00:12 UTC
(In reply to comment #1)
> A possible solution is to use the tooltip baloon to show a code block from few
> lines before and few lines after (configurable?). Having a default of at least
> 3 before and 3 after would help already.
I've implemented this solution.
http://hg.netbeans.org/core-main/rev/1dd7928c4418

It's not configurable (yet), I think 3 lines before and after should be sufficient.

Thank you very much for reporting and for your comments!
Comment 9 Quality Engineering 2013-02-23 04:12:14 UTC
Integrated into 'main-golden', will be available in build *201302222300* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/1dd7928c4418
User: Jaroslav Havlin <jhavlin@netbeans.org>
Log: #202628: Search results - show surrounding lines in text detail  tooltip