views:

296

answers:

7

Does anybody know a Windows based searching tool that is easy to use and is programmer friendly.

The functions I am looking for:

Ignore white space in search

= capable to find

myTestFunction ( $parameter, $another_parameter, $yet_another_parameter )
{ doThis();

using the query

myTestFunction($parameter,$another_parameter,$yet_another_parameter){doThis();

without Regexes.

Search code "semantically" (for me, it would have to be PHP):

  • Search in comments only
  • Search in function names only
  • Search for parameters that are named $xyz
  • Search in (insert code construct here) only

If there is none around, it's high time somebody developed it! :) I have opened a bounty for this.

A: 

Take a look at Google Desktop API, it has very powerful set of methods to do what you're looking for.

Of course it requires you to have the Google Desktop installed.

After reviewing it a little, it provides some functionality but not that specific as what you require.

Jorge Córdoba
Google Desktop looks interesting and simple, but unfortunately doesn't come with what I'm looking for out-of-the-box. On the other hand, it can be pluginized. Hmmm... Maybe I'll take a look at it.
Pekka
+2  A: 

I use ack really successfully for this kind of thing, particularly when trying to find things in large codebases. I run it linux myself but I don't see any reason why it won't run on windows or in Cygwin at the very least. Check it out, I think you'll find it is exactly what you're looking for.

sgargan
Having looked at the docs, yes it runs on windows fine!
sgargan
Thanks, will check it out!
Pekka
A: 

I really like Crimson Editor and it allows RegEx searches. It has helped me a bunch over the past six years. I think it will fit your needs. Try it.

0A0D
I have used Crimson Editor, its search function is fine, but I would prefer a stand-alone tool and to be able to pre-set it a bit so I don't have to conjure a regex on every search. (They are not really my strong suit.)
Pekka
+1  A: 

Search code "semantically" (for me, it would have to be PHP):

For this you could (and I think should) use some custom code using token_get_all()

See also the available tokens

Ignore white space in search

A simple regex should be sufficient. It depends on your regex-library, but most come with a whitespace modifier/flag.

Exception e
You mean, actually using PHP to search in PHP code? Hadn't thought of that! I would just fear that it's a little slow. Will try it out.
Pekka
Yes, just use php. I don't think it is too slow. You need to imagine that the php interpreter needs to do the same tokenising. If you need to do this repeatedly in a fast way, you could cache the results per file. When a file has changed the cache becomes invalid.
Exception e
+1  A: 

For my Windows desktop search, I use Agent Ransack. I use this as a replacement for the windows search.

You can use regular expressions, but there is a nice entry screen if you want to avoid entering them directly.

MatthieuF
Agent Ransack is still around? Will check it out.
Pekka
+2  A: 

See our SD Search Engine. This is a language-sensitive search engine designed to search large code bases, with special language classifiers for C, C++, Java, C#, COBOL, JavaScript, Ada, Python, Ruby and lot of other languages, including your specific target langauge PHP (PHP4 and PHP5).

I think it does everything you requested.

It indexes the language elements so search across large code bases are extremely fast (Linux Kernal ~~ 7.5 Million lines --> 2.5 seconds). (The indexing step runs on Windows, but the display engine is in Java.)

Search hits are shown in one-line context hit window showing the file and line number, as well as the line with the hit highlighted. Clicks on hits bring up the source code, tabs expanded appropriately, and the line count right even for languages which have odd line counting rules (such as GCC WRT form characters), with the hit line and hit text highlighted. Clicking in the source window will launch your favorite editor on the file.

Because it understands language elements, it ignores language-specific whitespace. It skips over comments unless you insist they be inspected. Searches thus ignore whitespace, comments and lineboundaries (if the language thinks lineboundaries are whitespace, which is why there are langauge-specific scanners). The query language allows you to specify which language tokens you want (specific tokens in quotes, or generic tokens such as identifiers I, numbers N, strings S, operators O and punctuation P) with constraints on the token value as well as a series of tokens.

Your example search:

 myTestFunction($parameter,$another_parameter,$yet_another_parameter){doThis(); 

would be expressed to the search engine precisely as:

 I=myTestFunction '(' I ',' I ',' I ')' '{' I=dothis '(' ')' ';'

but it would probably be easier (less typing) to find it as:

 I=myTest* ... I=dothis

where I=myTest* means an identifier starting with myTest and ... means "near".

The Search Engine also offer regular expressions searches on the text, if you insist. So you still have grep-like searches (a lot slower than indexed searches) but with the hit window and source display windows too.

Ira Baxter
Hi Ira, nice to meet you again here. We have E-mailed years back about your site. Well this looks like the mother of all code searching solutions :) What's the price tag for this? I can't find it on the site.
Pekka
Contact SD for pricing at the website. I'm just the CTO :-} There is a demo download at the site. The downloaddoesn't come equipped for PHP, but there is PHP module.
Ira Baxter
A: 

I use TextPad for searching code files in Windows. It has a very handy find-in-files function (Search / Find In Files) and you can use regex which should meet any search requirements. In the search results it will list the file location, line number and a snippet from that line.

Stuntbeaver