-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated readme
- Loading branch information
Showing
101 changed files
with
2,635 additions
and
269 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# This workflow will build a Java project with Gradle | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle | ||
|
||
name: Java CI with Gradle | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: 11 | ||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
- name: Build with Gradle | ||
run: ./gradlew build |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Lomboker | ||
|
||
## Purpose | ||
|
||
This command supports migrating a large code base to lombok. | ||
Eclipse/IntelliJ can migrate one class in a few clicks but that may not be fast enough for you. | ||
Lomboker helps you scale. | ||
|
||
## Usage | ||
|
||
Running from source | ||
``` | ||
lomboker$ cp ./lib/src/test/resources/ClassAInput.java ./lib/src/test/resources/ClassAOutput.java | ||
lomboker$ ./gradlew :app:run --args=".reduce getter ./lib/src/test/resources/ClassAInput.java" | ||
``` | ||
Building from source | ||
``` | ||
lomboker$ ./gradlew :app:assemble | ||
``` | ||
Converting a project | ||
``` | ||
alias lomboker='java -jar ./app/build/libs/lomboker.jar' | ||
#analysis | ||
find . -name '*.java' | lomboker count > counts.txt | ||
cat counts.txt | awk '{gt+=$2; gf+=$3; st+=$4; sf+=$5} END {printf " trivial fuzzy\ngetter %5d %5d\nsetter %5d %5d\n", gt,gf,st, sf}' | ||
# reduce getters | ||
cat counts.txt | awk '{print $1, $2}' | grep " 0$" | awk '{print $1}' > getterClasses.txt | ||
while read f; do lomboker reduce getter "$f"; done < getterClasses.txt; | ||
# put annotations on their own lines // capture first annotation (1) and white space before it (2) | ||
cat counts.txt | xargs sed 's/^\(\(\s\s*\)@\w\w*(\([0-9a-zA-Z", ])\)?\) @Getter/\1\n\2@Getter/' | ||
# reduce setters | ||
cat counts.txt | awk '{print $1, $4}' | grep " 0$" | awk '{print $1}' > setterClasses.txt | ||
while read f; do lomboker reduce setter "$f"; done < setterClasses.txt; | ||
# put annotations on their own lines // capture first annotation (1) and white space before it (2) | ||
cat counts.txt | xargs sed 's/^\(\(\s\s*\)@\w\w*(\([0-9a-zA-Z", ])\)?\) @Setter/\1\n\2@Setter/' | ||
# mark fuzzy getters | ||
cat counts.txt | awk '{print $1, $3}' | grep " 0$" | awk '{print $1}' > fuzzyGetters.txt | ||
while read f; do lomboker mark getter "$f"; done < fuzzyGetters.txt; | ||
# mark fuzzy setters | ||
cat counts.txt | awk '{print $1, $5}' | grep " 0$" | awk '{print $1}' > fuzzySetters.txt | ||
while read f; do lomboker mark setter "$f"; done < fuzzySetters.txt; | ||
``` | ||
|
||
|
||
## TODO | ||
- github actions | ||
- test required for push | ||
- build jars | ||
- getter setter shall have their own line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* This Java source file was generated by the Gradle 'init' task. | ||
*/ | ||
package de.lomboker.app; | ||
|
||
import picocli.CommandLine; | ||
import picocli.CommandLine.Command; | ||
|
||
@Command(name = "lomboker", | ||
subcommands = { | ||
CounterApp.class, | ||
Reduce.class, | ||
Mark.class, | ||
Summarize.class, | ||
Version.class | ||
}) | ||
public class App implements Runnable { | ||
public static void main(String[] args) { | ||
new CommandLine(new App()).execute(args); | ||
} | ||
|
||
@Override | ||
public void run() { | ||
|
||
System.out.println("I'm lomboker. you need to cal a subcommand like count|reduce|mark|summarize|Version"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* This Java source file was generated by the Gradle 'init' task. | ||
*/ | ||
package de.lomboker.app; | ||
|
||
import de.lomboker.lib.FuzzyGetters; | ||
import de.lomboker.lib.FuzzySetters; | ||
import de.lomboker.lib.TrivialGetters; | ||
import de.lomboker.lib.TrivialSetters; | ||
import picocli.CommandLine; | ||
import picocli.CommandLine.Command; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
@Command(name = "count", description = "no options or positional parameters") | ||
public class CounterApp implements Runnable { | ||
|
||
public static void main(String[] args) { | ||
int exitCode = new CommandLine(new CounterApp()).execute(args); | ||
System.exit(exitCode); | ||
} | ||
|
||
@Override | ||
public void run() { | ||
InputStreamReader isReader = new InputStreamReader(System.in); | ||
BufferedReader bufReader = new BufferedReader(isReader); | ||
String inputStr = ""; | ||
while(inputStr != null){ | ||
String count; | ||
try { | ||
inputStr = bufReader.readLine(); | ||
if (inputStr == null) | ||
break; | ||
|
||
count = evaluateFile(inputStr); | ||
|
||
} catch (IOException e) { | ||
count = "IOException while reading line from stdin"; | ||
} | ||
System.out.println(inputStr + " " + count); | ||
} | ||
|
||
} | ||
|
||
private static String evaluateFile(String fname) { | ||
String code; | ||
try { | ||
code = Files.readString(Path.of(fname)); | ||
} catch (IOException e) { | ||
return fname + " ioexception reading file"; | ||
} | ||
int trivialGetters = TrivialGetters.countTrivialGetters(code); | ||
int fuzzyGetters = FuzzyGetters.countFuzzyGetters(code); | ||
|
||
int trivialSetters = TrivialSetters.countTrivialSetters(code); | ||
int fuzzySetters = FuzzySetters.countFuzzySetters(code); | ||
|
||
return String.format("%d %d %d %d", | ||
trivialGetters, | ||
fuzzyGetters, | ||
trivialSetters, | ||
fuzzySetters ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package de.lomboker.app; | ||
|
||
import de.lomboker.app.getter.MarkGetter; | ||
import de.lomboker.app.getter.ReduceGetter; | ||
import de.lomboker.app.setter.MarkSetter; | ||
import de.lomboker.app.setter.ReduceSetter; | ||
import picocli.CommandLine.Command; | ||
|
||
@Command(name = "mark", | ||
subcommands = { | ||
MarkGetter.class, | ||
MarkSetter.class}, | ||
description = "mark non trivial setters") | ||
public class Mark implements Runnable { | ||
|
||
@Override | ||
public void run() { | ||
System.out.println("I'm Mark. You need to call a subcommand like getter|setter"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package de.lomboker.app; | ||
|
||
import de.lomboker.app.constructor.ReduceNoArgsConstructor; | ||
import de.lomboker.app.equalsAndHashCode.ReduceFuzzyEaH; | ||
import de.lomboker.app.getter.ReduceGetter; | ||
import de.lomboker.app.setter.ReduceSetter; | ||
import de.lomboker.app.toString.ReduceFuzzyToString; | ||
import picocli.CommandLine.Command; | ||
|
||
@Command(name = "reduce", | ||
subcommands = { | ||
ReduceGetter.class, | ||
ReduceSetter.class, | ||
ReduceFuzzyEaH.class, | ||
ReduceFuzzyToString.class, | ||
ReduceNoArgsConstructor.class}, | ||
description = "no options or positional parameters") | ||
public class Reduce implements Runnable { | ||
|
||
@Override | ||
public void run() { | ||
System.out.println("I'm Reduce. You need to call a subcommand like getter|setter"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package de.lomboker.app; | ||
|
||
import de.lomboker.app.constructor.ReduceNoArgsConstructor; | ||
import de.lomboker.app.getter.ReduceGetter; | ||
import de.lomboker.app.setter.ReduceSetter; | ||
import de.lomboker.app.summarize.SummarizeGetterSetter; | ||
import picocli.CommandLine.Command; | ||
|
||
@Command(name = "summarize", | ||
subcommands = { | ||
SummarizeGetterSetter.class}, | ||
description = "no options or positional parameters") | ||
public class Summarize implements Runnable { | ||
|
||
@Override | ||
public void run() { | ||
System.out.println("I'm Summarize. You need to call a subcommand like gs"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* This Java source file was generated by the Gradle 'init' task. | ||
*/ | ||
package de.lomboker.app; | ||
|
||
import de.lomboker.lib.FuzzyGetters; | ||
import de.lomboker.lib.FuzzySetters; | ||
import de.lomboker.lib.TrivialGetters; | ||
import de.lomboker.lib.TrivialSetters; | ||
import picocli.CommandLine; | ||
import picocli.CommandLine.Command; | ||
|
||
import java.io.*; | ||
import java.nio.charset.StandardCharsets; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.Enumeration; | ||
import java.util.Objects; | ||
import java.util.Properties; | ||
import java.util.Scanner; | ||
import java.util.stream.Collectors; | ||
|
||
@Command(name = "version", description = "no options or positional parameters") | ||
public class Version implements Runnable { | ||
|
||
public static void main(String[] args) { | ||
int exitCode = new CommandLine(new Version()).execute(args); | ||
System.exit(exitCode); | ||
} | ||
|
||
@Override | ||
public void run() { | ||
String version = readWithScanner(); | ||
|
||
if(version == null) | ||
version = " - error retrieving version"; | ||
|
||
System.out.println("Lomboker " + version); | ||
} | ||
|
||
public Version() { | ||
} | ||
|
||
private String readWithScanner(){ | ||
String fileName = "/version.txt"; | ||
|
||
InputStream is = getClass().getResourceAsStream(fileName); | ||
if (is == null) { | ||
System.out.println("resource not found"); | ||
return "resource not found"; | ||
} | ||
String text = new Scanner(is, StandardCharsets.UTF_8) | ||
.useDelimiter("\\A") //no delimiter, read all at once | ||
.next(); | ||
|
||
return text; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
app/src/main/java/de/lomboker/app/constructor/ReduceNoArgsConstructor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* This Java source file was generated by the Gradle 'init' task. | ||
*/ | ||
package de.lomboker.app.constructor; | ||
|
||
import picocli.CommandLine.Command; | ||
import picocli.CommandLine.Parameters; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
|
||
import static de.lomboker.lib.NoArgsConstructor.reduceNoArgsConstructor; | ||
import static de.lomboker.lib.TrivialGetters.reduceGetters; | ||
|
||
@Command(name = "no-args-constructor", description = "reduce no args constructor") | ||
public class ReduceNoArgsConstructor implements Runnable { | ||
|
||
@Parameters(index = "0") | ||
File file; | ||
|
||
@Override | ||
public void run() { | ||
try { | ||
String code = Files.readString(file.toPath()); | ||
String converted = reduceNoArgsConstructor(code); | ||
Files.writeString(file.toPath(), converted); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.