Skip to content

AST SImilarity

Carter Davis edited this page Mar 5, 2026 · 6 revisions

Project Idea

We are investigating how structural analysis of source code can be used to better understand and summarize changes between versions of a program. Our goal is to build a pipeline that takes two versions of a codebase—such as a previous and current commit from Git—and analyzes their differences using abstract syntax trees (ASTs) rather than traditional line-based diffs. The system will first parse the source code using Tree-sitter to generate AST representations of each version of the program. These trees will then be compared using GumTree to detect structural edits such as node insertions, deletions, updates, and moves. Finally, we will design a rule-based classification layer that groups these edits into meaningful change categories (e.g., function modifications, variable updates, or control-flow changes) and converts them into human-readable summaries. This project explores how AST-based differencing and semantic classification can provide deeper insights into program evolution than traditional text-based version control comparisons. The trigger for this process to run will be when a commit is pushed from a local repository to GitHub, and results will be returned as an update to the sender as a notification from GitHub.

Pipeline:

  • Git commit
  • Git push
  • Extract old/new file
  • Parse with Tree-sitter
  • Run GumTree
  • Get edit script
  • Apply classification rules
  • Generate human-readable summary
  • Return summary as a notification from GitHub to user

Target Audience

  • Software developers and code reviewers: The tool helps developers better understand how code changes between versions by analyzing structural differences instead of only line-by-line diffs from tools like Git, making it easier to quickly identify meaningful updates such as modified functions, changed data structures, or altered control flow.

  • Software engineering researchers: Researchers studying program evolution, static analysis, or code similarity can use the system as a platform to analyze structural changes in programs by combining parsing with Tree-sitter and structural differencing using GumTree.

  • Computer science students learning program analysis: The project can serve as an educational tool that demonstrates how code can be parsed into Abstract Syntax Trees (ASTs), structurally compared, and automatically summarized, helping students better understand concepts like AST-based analysis and automated code change detection.

Tech Stack

  • Tree-sitter – Parses source code into Abstract Syntax Trees (ASTs) for each program version.

  • GumTree – Compares the two ASTs and detects structural edits such as node insertions, deletions, updates, and moves.

  • Python – Implements the pipeline that orchestrates parsing, comparison, and classification of changes.

  • Git – Provides the two program versions (previous commit vs. current commit) to analyze changes.

  • Rule-based classification module – Interprets GumTree edit operations and converts them into human-readable summaries of code changes.

What Defines Success?

  • The system successfully parses two versions of a program, compares their ASTs, and generates structural change information using GumTree.

  • The tool accurately classifies common change patterns (e.g., function modification, conditional addition, variable updates, or structural refactoring).

  • It produces clear human-readable summaries of code changes that provide more insight than traditional text diffs.

  • Effectiveness can be demonstrated by running the pipeline on real Git commits and verifying that the generated summaries correctly describe the structural changes in the code.

Papers

Here are the papers that inform our investigation:

  • Kumar, R., Talton, J. O., Ahmad, S., Roughgarden, T., & Klemmer, S. R. (2011). Flexible tree matching. In Proceedings of the International Joint Conference on Artificial Intelligence (IJCAI).

  • Meqdadi, O., & Aljawarneh, S. (2020). A study of code change patterns for adaptive maintenance with AST analysis. International Journal of Electrical and Computer Engineering, 10(3), 2719–2733. https://doi.org/10.11591/ijece.v10i3.pp2719-2733

  • CEUR-WS. (2023). Paper 6. In CEUR Workshop Proceedings, Vol. 3542. https://ceur-ws.org/Vol-3542/paper6.pdf

Group Members

The group members are:

Clone this wiki locally