Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xanonymous-github/gumtree
The implementation of GumTree algorithm.
https://github.com/xanonymous-github/gumtree
antlr ast-differencing coroutines gumtree jvm kotlin kotlin-dsl kover ktlint tree-diffing
Last synced: about 1 month ago
JSON representation
The implementation of GumTree algorithm.
- Host: GitHub
- URL: https://github.com/xanonymous-github/gumtree
- Owner: Xanonymous-GitHub
- License: gpl-3.0
- Created: 2024-07-14T21:39:03.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-09-24T01:42:45.000Z (about 2 months ago)
- Last Synced: 2024-09-30T13:03:48.086Z (about 1 month ago)
- Topics: antlr, ast-differencing, coroutines, gumtree, jvm, kotlin, kotlin-dsl, kover, ktlint, tree-diffing
- Language: Kotlin
- Homepage:
- Size: 400 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GumTree
[![codecov](https://codecov.io/github/Xanonymous-GitHub/gumtree/graph/badge.svg?token=APHSDWWVC4)](https://codecov.io/github/Xanonymous-GitHub/gumtree)
**Description:**
GumTree is a Kotlin library for implementing the GumTree algorithm.
The origin paper can be found at [here](https://doi.org/10.1145/2642937.2642982)
**Getting Started**
1. **Prerequisites:**
* **JDK:** Gumtree requires JDK 21 to build and run.2. **Clone the Repository:**
```bash
git clone [email protected]:Xanonymous-GitHub/gumtree.git
```3. **Build the Project:**
```bash
./gradlew build
```> [!NOTE]
> This also runs the tests.4. **Run Unit Tests:**
```bash
./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:```kotlin
// 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 `GumTree`s.
```kotlin
val (tree1, tree2) = treePair
val calculator = DiffCalculator()runBlocking {
val editScript = calculator.computeEditScriptFrom(tree1 to tree2)
assertEquals(7, editScript.size)
}
```