# US 2010/0169871 A1 · Structured search in source code

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2010/0169871 A1
- Document ID: US20100169871A1
- Status: Published application
- Kind: A1
- Application number: 12/345,691
- Filed: 2008-12-30
- Published: 2010-07-01
- Earliest claimed: 2008-12-30
- Assignees: Microsoft Corporation
- Inventors: Peter Villadsen
- Web page: https://patentgrep.com/patent/US20100169871A1

## CPC

- G06F 8/75: Structural analysis for program understanding
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Architecture allows a programmer to answer questions about the source code the programmer is authoring, questions that cannot be answered by other means. A searching mechanism is provided over a much more structured presentation of the source code. The architecture utilizes components that provide an intimate knowledge about the structure of the text, namely, the source code of some particular programming language. The search mechanism employs an abstract syntax tree representation of the code over which the search is conducted. The program source code (as edited by the programmer) is transformed into the abstract syntax tree to embody the structure of the program. If the syntax tree is provided in XML, for example, an XML search mechanism such as Xpath can be utilized to perform the actual searching. This tree is then queried, allowing richer searching criteria to be expressed (by virtue of the structured format of the tree).

## Claims

### Claim 1

A computer-implemented search system, comprising:
a conversion component for representing a grammar of a program code as an abstraction; and
a search component for searching the abstraction based on a code-related query to obtain code results.

### Claim 2 (depends on 1)

The system of claim 1, wherein the abstraction is an abstract syntax tree.

### Claim 3 (depends on 2)

The system of claim 2, wherein the abstract syntax tree is represented in XML.

### Claim 4 (depends on 2)

The system of claim 2, wherein the search component processes the query over the abstract syntax tree according to an XML query language.

### Claim 5 (depends on 1)

The system of claim 1, wherein the query is in a form of an expression.

### Claim 6 (depends on 5)

The system of claim 5, wherein the query expression is in a form of a grammatical unit the processing of which initiates the search for program code statements.

### Claim 7 (depends on 1)

The system of claim 1, wherein the abstraction is stored in a cache and the search component performs the search on the abstraction in the cache.

### Claim 8 (depends on 1)

The system of claim 1, wherein the query is in a form of a natural language expression.

### Claim 9

A computer-implemented search system, comprising:
a conversion component for representing a syntax of a program code as an abstract syntax tree; and
a search component for searching the abstract syntax tree based on a code-based query.

### Claim 10 (depends on 9)

The system of claim 9, wherein the abstract syntax tree is represented in XML, and the search component processes the query over the abstract syntax tree according to an XML query language.

### Claim 11 (depends on 9)

The system of claim 9, wherein the query is in a form of an expression that is a grammatical unit, a processing of which initiates the search for program code statements.

### Claim 12 (depends on 9)

The system of claim 9, wherein the abstract syntax tree is stored in a cache and the search component performs the search on the abstract syntax tree in the cache.

### Claim 13 (depends on 9)

The system of claim 9, wherein the query is in a form of a natural language expression.

### Claim 14

A computer-implemented method of searching code, comprising:
representing a grammar of a program code as an abstraction;
searching the abstraction based on a code-related query; and
presenting code results.

### Claim 15 (depends on 14)

The method of claim 14, wherein the abstraction is an abstract syntax tree.

### Claim 16 (depends on 14)

The method of claim 14, further comprising representing the abstraction in XML.

### Claim 17 (depends on 16)

The method of claim 16, further comprising searching the XML abstraction representation using an Xpath language.

### Claim 18 (depends on 14)

The method of claim 14, further comprising composing the query as an expression structured as a grammatical unit.

### Claim 19 (depends on 14)

The method of claim 14, further comprising mapping a relationship between the abstraction and the program code.

### Claim 20 (depends on 19)

The method of claim 19, further comprising presenting a portion of the abstraction associated with a section of the program code in which the code results are found.
