Thursday, July 10, 2008

Code Search: Improved browsing and new search operators



Software engineers who work with huge code bases always wish searching thousands lines of code and navigating through the file and code structures was easier. They may use powerful IDEs for the local sources on their development workstations, but until recently they have been unable to efficiently browse huge amounts of the open source code in repositories and archives on the Internet. The latest Google Code Search updates add a few features that improve code browsing and searching. The first one is Code Outline which shows you the structure of code written Java, C, C++, C#, Python, JavaScript and Pascal. You can find it under a new "Outline" tab next to the existing "Files" tab.
The second feature we added allows you to click on include and import statements in Java, C, C++ and Python code and jump directly to the included file, if it is in the same package. In the case where the included file comes from a third-party library or, say, from Linux headers, a search is performed for the included file in the indexed code base.


But what if the include list is too large and you can't guess where a class or method is defined? To help we added two new search operators, class: and function: which allow you to restrict your regular expression to the names of classes and functions only. Together with the package: operator and new radio button "Search in ..." that restricts search to the files from the specified package, these are powerful ways to find exactly what you are looking for. Compare the results of searching for "Shell" in the whole code base with the results of searching for class:Shell inside SWT.

We continue improving Code Search and look forward for your feedback at our discussion group.

2 comments:

  1. Cool!

    So what will it take to add support for additional languages? Do you need a full grammar or do you just use a set of regular expressions?

    ReplyDelete
  2. is there any way to use this code in PHP ? because i am familiar with PHP

    ReplyDelete