Intelligent file search for windows that can ignore whitespace and search in code?

给你一囗甜甜゛ 提交于 2019-12-10 18:03:36

问题


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.


回答1:


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.




回答2:


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.




回答3:


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.




回答4:


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.




回答5:


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.




回答6:


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.




回答7:


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.



来源:https://stackoverflow.com/questions/1654533/intelligent-file-search-for-windows-that-can-ignore-whitespace-and-search-in-cod

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!