Multi-language refactoring tool implemented in Java, an experimental spin-off of MenderBot.
untangler get functions
: List function definitions in a fileuntangler get references
: Show symbol and declarations and reference in a fileuntangler rename
: Rename a symbol and all references to it a fileuntangler add comment
: Add a comment at a given lineuntangler remove comment
: Remove a comment at a given line
All commands output text by default but can output machine-readable formats with arguments -o json
or -o yaml
.
Arguments to each subcommand can be printed with untangler <COMMAND> --help
.
Prototype, not ready for production use.
Action | Python | C / C++ | Java | C# | js / ts |
---|---|---|---|---|---|
get functions | Beta | Beta | Beta | Beta | - |
get references | Beta | Beta | Beta | Beta | - |
rename | - | Beta | Beta | - | - |
add comment | - | Beta | Beta | - | - |
remove comment | - | Beta | Beta | - | - |
extract variable | - | - | - | - | - |
extract parameter | - | - | - | - | - |
extract field | - | - | - | - | - |
- Java 16+ (GraalVM JDK20 to build static exe (Homebrew tap)
GraalVM will allow us to ship untangler static executable that does not require Java to be installed for the end user.
# Set your GraalVM JDK instalation if you're using it
export JAVA_HOME=...
./gradlew installDist
build/install/untangler/bin/untangler
For easy rebuilding and running with the un
shortcut, use:
alias un="./gradlew installDist -q && build/install/untangler/bin/untangler"
un get functions -f src/test/resources/hello.c
Just the unit tests:
./gradlew test
Everything:
./gradlew spotlessApply check
Coverage report in open build/reports/jacoco/test/html/index.html
- Support each of the core 6 refactorings identified by Arlo Belshee
- Support the Menderbot target languages with reliable syntax tree manipulation
- Operate independent of a language server
- Be automation-friendly, commands should have an option to output json and indicate success with exit codes, for instance
- Rename
- Inline
- Extract Method
- Introduce Local Variable
- Introduce Parameter
- Introduce Field
- Python
- C / C++
- Java
- C#
- JavaScript / TypeScript
This build is slower, but the resulting static executable is fast and shippable!
# Your GraalVM JDK 20 instalation
export JAVA_HOME=...
./gradlew nativeCompile
# Run with:
build/native/nativeCompile/untangler
During development, you might alias this nun
for native untangler.
alias nun="build/native/nativeCompile/untangler"
If you get a reflection error, META-INF may need to be updated.
Check the Gradle native image docs for more info.
So far what's been needed is for META-INF/native-image/reflect-config.json
to list all the classes that we will serialize to Json.
Try running GenerateReflectConfig to get new json (this should eventually be a build step).
👤 Ray Myers
- YouTube: Craft vs Cruft
- Twitter: @lambdapocalypse
- GitHub: @raymyers
- LinkedIn: @cadrlife
- Antlr - the leading parser generator
- JavaParser - analyze and transform Java Code
- picocli - a mighty tiny command line interface
Copyright © 2024 Ray Myers.
This project is Apache 2 licensed.