2. BACKGROUND AND PROBLEM STATEMENT
2.1 Related Work
Over the years, several code search engines have been made to support dif-ferent code search needs. They differ on various aspects such as underlying code search technology, types of input supported, types of output produced etc. Tradi-tional code search engines are the ones that usually do full-text search on the source code documents. Chromium 1, Krugle2 and Koders3 are examples of such engines.
These engines also allow searching for limited structural information. Chromium and Koders allow searching for method name and class name. Krugle can search for method definition and class definition along with name. However, these search en-gines are not ideal for structural information search. We mention a couple of reasons for that. Firstly, these engines usually allow searching for a predefined limited set of types, namely class, method etc. There are many other types such as array, enum, constructor etc. that cannot be directly searched. Secondly, relationships among these types can hardly be searched. For example, we may search for class name but
1http://code.google.com/p/chromium/source/search
2http://opensearch.krugle.org/
3http://www.koders.com/
we may not search for subclass-superclass relationship. So there remain limitations that gave further scopes to improve source code search.
Codase 4 and Merobase5 are two search engines with more advanced structure based search along with full-text search. Both engines added method search based on method signature and class search based on class type. Additionally, Codase can distinguish among class field declaration, field reference and a variable. Although these engines have shown slightly broader capability for structural search, specifying a particular structural information in the search query is still difficult. The developer needs to use the query syntax for that specific engine to write a query. This criterion may not be desired for the developer. There are other advanced languages like .QL [12]
and JQuery [13] for searching fine grained structural information from the source code.
.QL allows an OOP programming model to find complex structural relationships.
JQuery uses the Abstract Syntax Tree to find such information from the code. The system in [14] uses a visual query editor to easily form complex queries to find code based on structural relationship from the source code. However, developers may not be interested to learn a new language or even a new query syntax for searching the source code. Although learning the syntax for some of those engines might be easier than learning a new language, still this learning factor may discourage the user from using that search engine.
In order to help users to avoid learning a new language or a new syntax, some code search engines support searching for structural relationships using a free from query. Sourcerer [3] is a source code search engine which has created an infrastructure for structural search on source code collected from open source software repositories.
Their keyword based search engine allows free form queries. Although this engine
4http://www.codase.com/
5http://merobase.com/#main
has structural relationship search capability, specifying the relation’s name as part of the free form query is not possible. While searching, the user may have to look into each of the returned search results and find out the one that actually shows the relationship she is looking for. There is a possibility that none of the returned results would contain the relationship she is looking for. This makes it difficult for the user to find an exact structural relationship quickly and easily. Other related works are the tool in [15] and strathcona [16]. [15] is a system that uses keyword query along with class type, method signature, test case, contract, security constraint to find a relevant code snippet. Strathcona [16] uses structural context from the code written by the user to retrieve relevant code example. To get better output, a user needs to write a code snippet in a convention suitable for understanding of strathcona. This may not be desired by the developer.
Several other code search tools have concentrated on finding limited number of structural informations to satisfy needs for the corresponding research context.
[4] is an improvement to conventional text based code search to find more relevant method examples. It considers the location of the keyword match whether it is in the method name or in the method body, semantic role of the matched word, fre-quency of occurrence of the matched keyword in the document etc. on top of the text-based search result to find relevant code examples. SE-CodeSearch [17] is a tool which uses Abstract Syntax Tree based approach to find a few structural relations from an uncompilable piece of code. Their main focus is on finding information from an uncompilable piece of code rather than supporting a greater number of relations.
Portfolio [18] is a code search tool which accepts free form query and finds a relevant call graph. Codegenie [19] uses test cases to search it’s repository to find an imple-mentation for the method for which the test case may be a good fit. PARSEWeb [20]
can find code example given a source object and a target object. The code snippet
will consist of a method sequence that will be able to generate the target object start-ing with the source object. Other relevant approaches may be useful while lookstart-ing for particular use of an API or to find examples to accomplish a task. [21] and [22]
are free form form query based tools which find relevant API usage examples.
None of the aforementioned work exactly matches our approach. Our system has an easy to use free form query interface to relieve the user from learning any new query language or syntax. Also our system allows specifying structural relation’s name as part of the query and it takes the relation name into account while searching for relevant answers.