Skip to content

Xanonymous-GitHub/gumtree

This branch is 1 commit ahead of main.

Folders and files

NameName
Last commit message
Last commit date
Dec 28, 2024
Aug 21, 2024
Jul 14, 2024
Aug 31, 2024
Jan 9, 2025
Aug 4, 2024
Jul 21, 2024
Jul 14, 2024
Jul 14, 2024
Aug 31, 2024
Dec 28, 2024
Aug 21, 2024
Jul 14, 2024
Dec 28, 2024
Aug 16, 2024
Jul 14, 2024
Aug 4, 2024

Repository files navigation

GumTree

codecov

Description:

GumTree is a Kotlin library for implementing the GumTree algorithm.

The origin paper can be found at here

Getting Started

  1. Prerequisites:

    • JDK: Gumtree requires JDK 21 to build and run.
  2. Clone the Repository:

    git clone [email protected]:Xanonymous-GitHub/gumtree.git
  3. Build the Project:

    ./gradlew build

Note

This also runs the tests.

  1. Run Unit Tests:
    ./gradlew test

Tip

Human-readable unit tests report generated by Kover can be found in build/reports/kover/html/index.html. The build folder is generated in each Gradle subproject after running the test task.

Usages

This project currently supports converting ANTLR's parse tree to GumTree. Assume we have a file, and UrlLexer and UrlParser are the lexer and parser for URLs. Then we can convert the file to a GumTree as follows:

// This API is defined in the `antlr-bridge` module.

val file = File("src/test/kotlin/data/urls.txt")
val inputStream = file.inputStream()
runBlocking {
    GumTreeConverter.convertFrom(inputStream, ::UrlLexer, ::UrlParser, UrlParser::url)
}

You can use the DiffCalculator class to compute the edit script between two GumTrees.

val (tree1, tree2) = treePair
val calculator = DiffCalculator()

runBlocking {
    val editScript = calculator.computeEditScriptFrom(tree1 to tree2)
    assertEquals(7, editScript.size)
}