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 64392 - Find in Projects... ignores project's specific SearchInfo objects
Summary: Find in Projects... ignores project's specific SearchInfo objects
Alias: None
Product: utilities
Classification: Unclassified
Component: Search (show other bugs)
Version: 4.x
Hardware: All All
: P2 blocker (vote)
Assignee: Marian Petras
Depends on:
Reported: 2005-09-15 00:52 UTC by Thomas Preisler
Modified: 2007-02-02 22:21 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:

diff of apichanges.xml - describes the API change (1.32 KB, text/plain)
2007-01-12 13:03 UTC, Marian Petras
diff of apichanges.xml - updated (2.34 KB, patch)
2007-01-12 21:49 UTC, Marian Petras
Details | Diff
diff of Javadoc for Project.getLookup() (1.35 KB, patch)
2007-01-12 21:54 UTC, Marian Petras
Details | Diff
diff of Javadoc for SearchInfo (1.92 KB, patch)
2007-01-12 21:54 UTC, Marian Petras
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Preisler 2005-09-15 00:52:42 UTC
Find dialog makes some assumption on project logical view that is true only for
Java projects. Find looks at the first level of nodes in a project's logical
view and traverses only nodes associated with disk files. This may work for Java
projects but if the first level nodes are for instance logical folders like in
our Make Projects, this heurheurist fails.

Need a way to specify to find what files should be search in a project.
Comment 1 Marian Petras 2005-09-15 15:54:14 UTC
It is possible to define how a given node should be searched. To do so, just add
a SearchInfo object to the node's lookup. Introduction to the SearchAPI and
use-cases is available at

Does the SearchAPI (specifically interfaces SearchInfo and FileObjectFilter and
factory class SearchInfoFactory) fulfil your needs?
Comment 2 Marian Petras 2005-10-13 13:06:23 UTC
Since I consider the reporter's claim invalid and the reporter did not object
against my reply for almost a month, I close this bug report as INVALID.

Feel free to reopen if you actually need some change in the Search API.
Comment 3 Jan Lahoda 2006-01-05 12:53:41 UTC
Cannnot fully speak for the reporter, but adding SearchInfo into the projects
node helps only for the Find... action. There is another action "Find in
Projects...", which takes SourceGroup(s) of all opened projects and searches
recursively the roots of these SourceGroups, without paying attention to
"SourceGroup.contain". I think this is not correct behaviour.

I can provide you a SourceGroup based SearchInfo that can be used to fix the
"Find in Projects..." action.

Maybe a completely different approach can be taken after the actions redesign,
but I am not sure what is the status of the redesign.
Comment 4 Marian Petras 2006-01-05 14:56:35 UTC

It will be fixed in the version after 5.0.
Comment 5 Milan Kubec 2006-01-05 15:15:15 UTC
Then please send waiver request. Thanks.
Comment 6 Jan Lahoda 2006-01-05 15:23:50 UTC
Well, I do no think this is a P2...
Comment 7 Thomas Preisler 2006-12-15 21:56:18 UTC
Raising to p2. We would like this fixed and backported to 5.5.1.
Comment 8 Marian Petras 2007-01-09 16:09:27 UTC
The core of this issue is that action Find in Projects does not respect lookup
of the projects' root nodes. So I plan to fix this issue simply by passing the
projects' root nodes to the Find action so that their lookup can be taken into
   Unfortunately, it is not possible to get the root nodes displayed in the
Projects view - one can only ask for new copies. So the Find in Projects action
will create a new copy of each project's root node and use these copies for
grabbing information used for searching. This should work but it might increase
memory consumption - this is still to be determined.
Comment 9 Marian Petras 2007-01-09 17:34:12 UTC
I implemented the described changed and ... it does not work. The problem is
that most projects' nodes' lookups do not contain the SearchInfo until the
project's root node is added to the Projects view in the IDE.

I do not have any alternative idea, yet.
Comment 10 Jesse Glick 2007-01-09 21:31:26 UTC
"most projects' nodes' lookups do not contain the SearchInfo until the project's
root node is added to the Projects view in the IDE" - really? why?

Anyway I think it would be better for F.i.P. to continue to use SourceGroup but
to pay attention to SG.contains(). (Which, BTW, will be even more important with
issue #49026.)
Comment 11 Thomas Preisler 2007-01-09 22:01:13 UTC
Please note that not all projects are 'root' based. Native projects don't have a
source root and don't use SourceGroups. We do create a SearchInfo object (when
the node is displayed!) and sticks it into the lookup and it works well with
Find. Find in Project is the action that doesn't work for us and looking for a
solution that supports something like SearchInfo.
Comment 12 Marian Petras 2007-01-10 13:05:00 UTC
My new idea is to get SearchInfo from the project itself (i.e. not from its root
node) and if the project's lookup does not contain SearchInfo, fallback to the
current implementation, i.e. to the search over SearchGroups.
   Let me know if this is an acceptable way of solving this issue. If so, I will
implement and integrate the described change as soon as possible.
Comment 13 Thomas Preisler 2007-01-10 16:46:22 UTC
yes, I think this solution would work. 
Comment 14 Marian Petras 2007-01-10 18:12:57 UTC
I just integrated the change described in my previous post.

I integrated this in two phases because I forgot to update the copyright period
in the first commit.

Modified files:
   utilities/src/org/netbeans/modules/search/   (1.40/1.41)

Comment 15 Thomas Preisler 2007-01-10 19:54:00 UTC
Great. Please not this is one of the fixes we would like backported to 5.5.1.
Comment 16 Tomas Zezula 2007-01-11 12:43:49 UTC
The patch seems OK.
Comment 17 Jesse Glick 2007-01-11 16:26:48 UTC
This is an API change. It needs to be documented, in SearchInfo and also in
Comment 18 Marian Petras 2007-01-12 13:03:35 UTC
Created attachment 37317 [details]
diff of apichanges.xml - describes the API change
Comment 19 Marian Petras 2007-01-12 13:40:12 UTC
I increased specification version of the Utilities module (1.22 -> 1.23).

Modified file:

   utilities/   (1.64)

Comment 20 Jaroslav Tulach 2007-01-12 14:03:56 UTC
Y01 Please try to use hyperlinks to classes you talk about - SourceGroups, 
Project, etc. Also make a note in Project's own JavaDoc:

Y02 Is there a test to verify that this contract works for ever? It should be, 
otherwise random commits can break this contract in future.
Comment 21 Marian Petras 2007-01-12 21:49:37 UTC
Created attachment 37339 [details]
diff of apichanges.xml - updated
Comment 22 Marian Petras 2007-01-12 21:54:06 UTC
Created attachment 37340 [details]
diff of Javadoc for Project.getLookup()
Comment 23 Marian Petras 2007-01-12 21:54:40 UTC
Created attachment 37341 [details]
diff of Javadoc for SearchInfo
Comment 24 Jesse Glick 2007-01-12 22:00:35 UTC
Better, thanks.
Comment 25 Marian Petras 2007-01-19 13:10:19 UTC
I just committed the documentation and also a test of the Find in Projects action.

Added and modified files:
    openidex/   (1.39)
    openidex/api/apichanges.xml   (1.7)
    openidex/src/org/openidex/search/   (1.8)
    projects/projectapi/src/org/netbeans/api/project/   (1.16)
                              (1.1 - new)

Comment 26 Thomas Preisler 2007-01-29 20:15:39 UTC
The fix has been backported to 551, correct? Shouldn't it be marked with the
Whiteboard keyword '551_HR_FIX' then?
Comment 27 Jesse Glick 2007-01-29 20:21:22 UTC
I think you just need to set TM=5.5.1 if it has already been backported, but I'm
not sure. If it has been backported, was there a commit log somewhere?
Comment 28 Thomas Preisler 2007-01-29 23:13:32 UTC
I just checked the 551 sources and it doesn't look like it has been backported
yet. But that's the plan, correct?
Comment 29 Antonin Nebuzelsky 2007-01-30 12:41:20 UTC
> I just checked the 551 sources and it doesn't look like it has been
> backported yet. But that's the plan, correct?

Definitely. I talked to mpetras before the weekend and he was starting
preparations of 551 integration. This will be integrated soon.
Comment 30 Thomas Preisler 2007-01-30 18:49:33 UTC
Very good. Thanks.
Comment 31 Marian Petras 2007-02-02 19:30:33 UTC
I backported the functionality and tests to the 'release551' branch.

Modified and added files:
utilities/   (
utilities/src/org/netbeans/modules/search/ (
utilities/project/   (
utilities/project/nbproject/   (
                    ( - new on branch)
                    ( - new on branch)
                    ( - new on b.)
                           org.netbeans.spi.project.ProjectFactory   (
Comment 32 Marian Petras 2007-02-02 22:21:50 UTC
Additional commit to branch 'release551':

    openidex/   (