Abstract Syntax Tree Source Code Search

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Current source code editing systems lack robust searching capabilities, as they treat source code as unstructured text, failing to understand the problem domain and unable to perform structured searches due to the absence of code structure.

Innovation Solution

The architecture transforms source code into an abstract syntax tree, allowing for structured searches using XML and Xpath, enabling richer querying criteria and improved productivity.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Ease of operation

If source code is treated as unstructured text for searching, then simple text-based searches can be performed, but the system cannot understand the problem domain or perform structured searches

Engineering Contradiction:
Improvesearching capabilityVSAvoidcode structure information
Core Design Contradiction:
Ease of operationVSLoss of information

Solution Approach 1:

The patent introduces an abstract syntax tree (AST) as an intermediary representation between the original source code and the search mechanism. The AST preserves the structural information of the code while enabling sophisticated queries. The system transforms source code into an AST, then performs searches on this structured representation, allowing domain-aware searching without losing the original code's structural semantics

Inventive Principle:
Principle #24Intermediary (Mediator)

Solution Approach 2:

The patent changes the representation parameter of source code from unstructured text to a structured abstract syntax tree. This parameter transformation enables the search system to access structural information (such as statement types, variable declarations, control flow) that is invisible in plain text form, thereby enabling domain-specific structured searches

Inventive Principle:
Principle #35Parameter changes

2Adaptability or versatility

If source code is transformed into an abstract syntax tree for structured searching, then richer querying criteria can be expressed, but the system complexity increases

Engineering Contradiction:
Improvequerying capabilityVSAvoidsystem architecture
Core Design Contradiction:
Adaptability or versatilityVSDevice complexity

Solution Approach 1:

The patent segments the search system into distinct functional components: a code parser that generates the abstract syntax tree, a query processor that interprets structured search criteria, and a result mapper that translates AST results back to source code locations. This segmentation allows each component to handle specific tasks, making the overall complex system manageable and maintainable while enabling versatile querying

Inventive Principle:
Principle #1Segmentation

3Productivity

If conventional text-based searching is used, then the system is simple to implement, but it cannot answer questions about code structure or behavior

Engineering Contradiction:
Improveprogrammer productivityVSAvoidcode analysis accuracy
Core Design Contradiction:
ProductivityVSReliability

Solution Approach 1:

The patent replaces the mechanical text-matching search mechanism with a semantic search approach based on abstract syntax trees. Instead of merely matching character sequences, the system understands code structure and semantics by operating on the AST representation, enabling accurate answers about code structure, variable declarations, control flow, and other program properties

Inventive Principle:
Principle #28Mechanics substitution (Replace mechanical system)

Data Source

PatentUS8312437B2Structured search in source code
Publication Date: 2012.11.13 MICROSOFT TECHNOLOGY LICENSING LLC
  • US8312437B2 patent drawing
  • US8312437B2 patent drawing
  • US8312437B2 patent drawing

AI summary

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).