Skip to content

Commit

Permalink
spotless apply
Browse files Browse the repository at this point in the history
  • Loading branch information
tonykwok1992 committed Mar 14, 2024
1 parent 4985aa8 commit 3fddbda
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public class TruffleJsonFunctionWrapperGenerator extends FunctionWrapperGenerato
public static final String COMMAND_GENERATE = "generate";
public static final String COMMAND_PREFIX = COMMAND_TRUFFLE + " " + COMMAND_GENERATE;


private final String jsonFileLocation;
private final boolean generateBothCallAndSend;

Expand All @@ -82,7 +81,10 @@ public static void main(String[] args) {
args = tail(args);
}
CommandLine cmd = new CommandLine(new PicocliRunner());
cmd.parseWithHandlers(new RunLast().useOut(System.out).useAnsi(Help.Ansi.AUTO), RethrowExceptionHandler.HANDLER, args);
cmd.parseWithHandlers(
new RunLast().useOut(System.out).useAnsi(Help.Ansi.AUTO),
RethrowExceptionHandler.HANDLER,
args);
}

@Command(
Expand Down Expand Up @@ -128,27 +130,29 @@ private static class PicocliRunner implements Callable<Void> {
public Void call() throws Exception {
useJavaNativeTypes = !(useSolidityTypes);
new TruffleJsonFunctionWrapperGenerator(
jsonFileLocation,
destinationDirLocation,
basePackageName,
useJavaNativeTypes,
generateBothCallAndSend)
jsonFileLocation,
destinationDirLocation,
basePackageName,
useJavaNativeTypes,
generateBothCallAndSend)
.generate();
return null;
}
}

public static class RethrowExceptionHandler implements CommandLine.IExceptionHandler2<List<Object>>{
public static class RethrowExceptionHandler
implements CommandLine.IExceptionHandler2<List<Object>> {

public final static RethrowExceptionHandler HANDLER = new RethrowExceptionHandler();
public static final RethrowExceptionHandler HANDLER = new RethrowExceptionHandler();

@Override
public List<Object> handleParseException(ParameterException ex, String[] args) {
throw ex;
}

@Override
public List<Object> handleExecutionException(ExecutionException ex, ParseResult parseResult) {
public List<Object> handleExecutionException(
ExecutionException ex, ParseResult parseResult) {
throw ex;
}
}
Expand Down Expand Up @@ -189,7 +193,8 @@ public void generate() throws IOException, ClassNotFoundException {
} else {
addresses = Collections.EMPTY_MAP;
}
new SolidityFunctionWrapper(useJavaNativeTypes, Address.DEFAULT_LENGTH, generateBothCallAndSend)
new SolidityFunctionWrapper(
useJavaNativeTypes, Address.DEFAULT_LENGTH, generateBothCallAndSend)
.generateJavaFiles(
contractName,
c.getBytecode(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,23 @@ private void testCodeGenerationSolidtyTypes(String contractName, String inputFil
}

private void testCodeGeneration(
String contractName, String inputFileName, String packageName, String types, boolean generateBothCallAndSend)
String contractName,
String inputFileName,
String packageName,
String types,
boolean generateBothCallAndSend)
throws Exception {

List<String> argList = new ArrayList<>(Arrays.asList(
types,
ContractJsonParseTest.jsonFileLocation(
contractBaseDir, contractName, inputFileName),
"-p",
packageName,
"-o",
tempDirPath));
List<String> argList =
new ArrayList<>(
Arrays.asList(
types,
ContractJsonParseTest.jsonFileLocation(
contractBaseDir, contractName, inputFileName),
"-p",
packageName,
"-o",
tempDirPath));

if (generateBothCallAndSend) {
argList.add("-B");
Expand Down

0 comments on commit 3fddbda

Please sign in to comment.