-
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.
- Loading branch information
Showing
31 changed files
with
795 additions
and
81 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 |
---|---|---|
@@ -1,19 +1,23 @@ | ||
# Lomboker | ||
|
||
Usage | ||
## Purpose | ||
|
||
``` | ||
lomboker$ cp ./lib/src/test/resources/ClassAInput.java ./lib/src/test/resources/ClassAOutput.java | ||
lomboker$ ./gradlew :app-getter:run --args="../lib/src/test/resources/ClassAInput.java" | ||
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. | ||
|
||
lomboker$ #./gradlew :app-getter:jar | ||
lomboker$ #java -jar ./app-getter/build/libs/app-getter.jar | ||
## Usage | ||
|
||
lomboker$ ./gradlew :app-getter:assemble | ||
lomboker$ java -jar ./app-getter/build/libs/app-getter.jar lib/src/test/resources/ClassAInput.jav | ||
``` | ||
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" | ||
``` | ||
lomboker$ #./gradlew :app-getter:assemble | ||
lomboker$ #java -jar ./app-getter/build/libs/lomboker.jar reduce getter lib/src/test/resources/ClassAInput.java | ||
``` | ||
|
||
``` | ||
``` | ||
|
||
## TODO | ||
- github actions | ||
- test required for push | ||
- build jars |
This file was deleted.
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
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,66 @@ | ||
/* | ||
* This Java source file was generated by the Gradle 'init' task. | ||
*/ | ||
package de.lomboker.app; | ||
|
||
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 = TrivialGetters.countFuzzyGetters(code); | ||
|
||
int trivialSetters = TrivialSetters.countTrivialSetters(code); | ||
int fuzzySetters = TrivialSetters.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,19 @@ | ||
package de.lomboker.app; | ||
|
||
import de.lomboker.app.getter.ReduceGetter; | ||
import de.lomboker.app.setter.ReduceSetter; | ||
import picocli.CommandLine.Command; | ||
|
||
@Command(name = "reduce", | ||
subcommands = { | ||
ReduceGetter.class, | ||
ReduceSetter.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,32 @@ | ||
/* | ||
* This Java source file was generated by the Gradle 'init' task. | ||
*/ | ||
package de.lomboker.app.getter; | ||
|
||
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.FuzzyGetterMarker.markFuzzyGetters; | ||
|
||
@Command(name = "getter", description = "mark non-trivial getters") | ||
public class MarkGetter implements Runnable { | ||
|
||
@Parameters(index = "0") | ||
File file; | ||
|
||
@Override | ||
public void run() { | ||
try { | ||
String code = Files.readString(file.toPath()); | ||
String converted = markFuzzyGetters(code); | ||
Files.writeString(file.toPath(), converted); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
} | ||
} |
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,38 @@ | ||
/* | ||
* This Java source file was generated by the Gradle 'init' task. | ||
*/ | ||
package de.lomboker.app.setter; | ||
|
||
import picocli.CommandLine; | ||
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.FuzzySetterMarker.markFuzzySetters; | ||
|
||
@Command(name = "setter", description = "mark non-trivial setters") | ||
public class MarkSetter implements Runnable { | ||
|
||
@Parameters(index = "0") | ||
File file; | ||
|
||
public static void main(String[] args) { | ||
int exitCode = new CommandLine(new MarkSetter()).execute(args); | ||
System.exit(exitCode); | ||
} | ||
|
||
@Override | ||
public void run() { | ||
try { | ||
String code = Files.readString(file.toPath()); | ||
String converted = markFuzzySetters(code); | ||
Files.writeString(file.toPath(), converted); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
app/src/main/java/de/lomboker/app/setter/ReduceSetter.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,38 @@ | ||
/* | ||
* This Java source file was generated by the Gradle 'init' task. | ||
*/ | ||
package de.lomboker.app.setter; | ||
|
||
import picocli.CommandLine; | ||
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.TrivialSetters.reduceSetters; | ||
|
||
@Command(name = "setter", description = "reduce trivial setters") | ||
public class ReduceSetter implements Runnable { | ||
|
||
@Parameters(index = "0") | ||
File file; | ||
|
||
public static void main(String[] args) { | ||
int exitCode = new CommandLine(new ReduceSetter()).execute(args); | ||
System.exit(exitCode); | ||
} | ||
|
||
@Override | ||
public void run() { | ||
try { | ||
String code = Files.readString(file.toPath()); | ||
String converted = reduceSetters(code); | ||
Files.writeString(file.toPath(), converted); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
} | ||
} |
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,2 @@ | ||
const val VERSION = "0.0.0-SNAPSHOT" | ||
|
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,30 @@ | ||
package de.lomboker.lib; | ||
|
||
import com.github.javaparser.StaticJavaParser; | ||
import com.github.javaparser.ast.CompilationUnit; | ||
import com.github.javaparser.ast.body.FieldDeclaration; | ||
import com.github.javaparser.ast.body.MethodDeclaration; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
public class ClassWrapper { | ||
|
||
public CompilationUnit cu; | ||
|
||
public List<FieldDeclaration> fields; | ||
|
||
public List<MethodDeclaration> methods; | ||
|
||
public Set<String> fieldNames; | ||
|
||
public ClassWrapper(String code) { | ||
this.cu = StaticJavaParser.parse(code); | ||
this.fields = cu.findAll(FieldDeclaration.class); | ||
this.methods = cu.findAll(MethodDeclaration.class); | ||
this.fieldNames = fields.stream() | ||
.map(f -> f.getVariable(0).getName().asString()) | ||
.collect(Collectors.toSet()); | ||
} | ||
} |
Oops, something went wrong.