Skip to content

Commit

Permalink
Merge pull request #5049 from kwvanderlinde/refactor/5048-google-java…
Browse files Browse the repository at this point in the history
…-format-1.24.0

Bump google-java-format version to 1.24.0
  • Loading branch information
cwisniew authored Nov 19, 2024
2 parents 9d81d22 + 2e87da1 commit 58e0ed7
Show file tree
Hide file tree
Showing 25 changed files with 183 additions and 168 deletions.
2 changes: 1 addition & 1 deletion buildSrc/shared.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ spotless {
licenseHeaderFile rootProject.file('spotless.license.java')
toggleOffOn()
// Now using the Google Java style guide
googleJavaFormat("1.17.0")
googleJavaFormat("1.24.0")
}

format 'misc', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public Object childEvaluate(
return switch (diceName) {
case "sw" -> new GenesysDiceRolls().roll(DiceType.StarWars, diceExpression, resolver);
case "gs" -> new GenesysDiceRolls().roll(DiceType.Genesys, diceExpression, resolver);
default -> throw new ParserException(
I18N.getText("advanced.roll.unknownDiceType", diceName));
default ->
throw new ParserException(I18N.getText("advanced.roll.unknownDiceType", diceName));
};
} catch (IllegalArgumentException e) {
throw new ParserException(e.getMessage());
Expand Down
72 changes: 36 additions & 36 deletions src/main/java/net/rptools/maptool/client/MapToolLineParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,9 @@ public String parseLine(
*/
switch (option.getOptionType()) {

///////////////////////////////////////////////////
// OUTPUT FORMAT OPTIONS
///////////////////////////////////////////////////
///////////////////////////////////////////////////
// OUTPUT FORMAT OPTIONS
///////////////////////////////////////////////////
case HIDDEN:
output = Output.NONE;
break;
Expand All @@ -331,9 +331,9 @@ public String parseLine(
text = option.getStringParam(0);
break;

///////////////////////////////////////////////////
// VISIBILITY OPTIONS
///////////////////////////////////////////////////
///////////////////////////////////////////////////
// VISIBILITY OPTIONS
///////////////////////////////////////////////////
case GM:
outputOpts.add("g");
break;
Expand All @@ -360,19 +360,19 @@ public String parseLine(
}
break;

///////////////////////////////////////////////////
// TOOLTIP VISIBILITY OPTIONS
///////////////////////////////////////////////////
///////////////////////////////////////////////////
// TOOLTIP VISIBILITY OPTIONS
///////////////////////////////////////////////////
case GMTT:
outputOpts.add("gt");
break;
case SELFTT:
outputOpts.add("st");
break;

///////////////////////////////////////////////////
// LOOP OPTIONS
///////////////////////////////////////////////////
///////////////////////////////////////////////////
// LOOP OPTIONS
///////////////////////////////////////////////////
case COUNT:
// COUNT(num [, sep])
loopType = LoopType.COUNT;
Expand Down Expand Up @@ -485,9 +485,9 @@ public String parseLine(
loopSep = option.getStringParam(1);
break;

///////////////////////////////////////////////////
// BRANCH OPTIONS
///////////////////////////////////////////////////
///////////////////////////////////////////////////
// BRANCH OPTIONS
///////////////////////////////////////////////////
case IF:
// IF(condition)
branchType = BranchType.IF;
Expand All @@ -499,9 +499,9 @@ public String parseLine(
branchCondition = option.getObjectParam(0);
break;

///////////////////////////////////////////////////
// DIALOG AND FRAME OPTIONS
///////////////////////////////////////////////////
///////////////////////////////////////////////////
// DIALOG AND FRAME OPTIONS
///////////////////////////////////////////////////
case FRAME:
codeType = CodeType.CODEBLOCK;
frameName = option.getParsedParam(0, resolver, tokenInContext, this).toString();
Expand Down Expand Up @@ -532,9 +532,9 @@ public String parseLine(
frameOpts = option.getParsedParam(1, resolver, tokenInContext, this).toString();
outputTo = OutputLoc.OVERLAY;
break;
///////////////////////////////////////////////////
// CODE OPTIONS
///////////////////////////////////////////////////
///////////////////////////////////////////////////
// CODE OPTIONS
///////////////////////////////////////////////////
case MACRO:
// MACRO("macroName@location")
codeType = CodeType.MACRO;
Expand All @@ -543,9 +543,9 @@ public String parseLine(
case CODE:
codeType = CodeType.CODEBLOCK;
break;
///////////////////////////////////////////////////
// MISC OPTIONS
///////////////////////////////////////////////////
///////////////////////////////////////////////////
// MISC OPTIONS
///////////////////////////////////////////////////
case TOKEN:
if (!isMacroTrusted()) {
throw new ParserException(I18N.getText("macro.function.roll.noPerm"));
Expand Down Expand Up @@ -591,9 +591,9 @@ public String parseLine(
}

switch (loopType) {
/*
* TODO: If you're adding a new looping option, add a new case to handle the iteration
*/
/*
* TODO: If you're adding a new looping option, add a new case to handle the iteration
*/
case NO_LOOP:
if (iteration > 0) { // stop after first iteration
doLoop = false;
Expand Down Expand Up @@ -710,9 +710,9 @@ public String parseLine(

// Extract the branch to use
switch (branchType) {
/*
* TODO: If you're adding a new branching option, add a new case to extract the branch text
*/
/*
* TODO: If you're adding a new branching option, add a new case to extract the branch text
*/
case NO_BRANCH:
{
// There's only one branch, so our regex is very simple
Expand Down Expand Up @@ -814,9 +814,9 @@ public String parseLine(
// If none of the code options are active, any of the formatting options can be
// used.
switch (output) {
/*
* TODO: If you're adding a new formatting option, add a new case to build the output
*/
/*
* TODO: If you're adding a new formatting option, add a new case to build the output
*/
case NONE:
parseExpression(resolver, tokenInContext, rollBranch, false);
break;
Expand Down Expand Up @@ -874,9 +874,9 @@ public String parseLine(
expressionBuilder.append(rollString(outputOpts, output_text));
} // end of switch(output) statement
break; // end of case NO_CODE in switch(codeType) statement
/*
* TODO: If you're adding a new code option, add a new case to execute the code
*/
/*
* TODO: If you're adding a new code option, add a new case to execute the code
*/
case MACRO:
// [MACRO("macroName@location"): args]
result = parseExpression(resolver, tokenInContext, macroName, false);
Expand Down
18 changes: 10 additions & 8 deletions src/main/java/net/rptools/maptool/client/TransferableHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -447,14 +447,16 @@ private static boolean checkValidType(MediaType mediaType) {
String subType = mediaType.getSubtype();
return switch (contentType) {
case "audio", "image" -> true;
case "text" -> switch (subType) {
case "html", "markdown", "x-web-markdown", "plain", "javascript", "css" -> true;
default -> false;
};
case "application" -> switch (subType) {
case "pdf", "json", "javascript", "xml" -> true;
default -> false;
};
case "text" ->
switch (subType) {
case "html", "markdown", "x-web-markdown", "plain", "javascript", "css" -> true;
default -> false;
};
case "application" ->
switch (subType) {
case "pdf", "json", "javascript", "xml" -> true;
default -> false;
};
default -> false;
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ private Object broadcast(VariableResolver resolver, List<Object> param) throws P
I18N.getText("macro.function.general.notEnoughParam", "broadcast", 1, 0));
case 3:
delim = param.get(2).toString();
// FALLTHRU
// FALLTHRU
case 2:
String temp = param.get(1).toString().trim();
if ("json".equals(delim) || temp.charAt(0) == '[') {
Expand All @@ -165,7 +165,7 @@ private Object broadcast(VariableResolver resolver, List<Object> param) throws P
return ""; // dont send to empty lists
}

// FALLTHRU
// FALLTHRU
case 1:
message = checkForCheating(param.get(0).toString());
if (message != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,9 @@ public Object childEvaluate(
}
return new MTScriptDataConversion().convertToMTScriptDereferenceType(dataValue);
}
default -> throw new ParserException(
I18N.getText("macro.function.general.unknownFunction", functionName));
default ->
throw new ParserException(
I18N.getText("macro.function.general.unknownFunction", functionName));
}
} catch (InterruptedException | ExecutionException e) {
throw new ParserException(e);
Expand All @@ -190,8 +191,9 @@ private JsonArray listData(DataStore dataStore, String type, String namespace)
case BOOLEAN -> jobj.addProperty("value", data.asBoolean());
case JSON_OBJECT -> jobj.add("value", data.asJsonObject());
case JSON_ARRAY -> jobj.add("value", data.asJsonArray());
case ASSET -> jobj.addProperty(
"value", "asset://" + data.asAsset().getMD5Key().toString());
case ASSET ->
jobj.addProperty(
"value", "asset://" + data.asAsset().getMD5Key().toString());
}
jarray.add(jobj);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@ public Object childEvaluate(
}
}

default -> throw new ParserException(
I18N.getText("macro.function.general.unknownFunction", functionName));
default ->
throw new ParserException(
I18N.getText("macro.function.general.unknownFunction", functionName));
}
} catch (InterruptedException | ExecutionException e) {
throw new ParserException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ private static void doOutput(
break;
case SELF_AND_GM:
MapTool.addLocalMessage(MessageUtil.getFormattedToGmSender(line));
// Intentionally falls through
// Intentionally falls through
case GM:
MapTool.addMessage(
TextMessage.gm(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,10 +406,11 @@ public Object childEvaluate(
switch (parameters.get(0).toString().toLowerCase()) {
case "off" -> MapTool.serverCommand().setVisionType(currentZR.getId(), Zone.VisionType.OFF);
case "day" -> MapTool.serverCommand().setVisionType(currentZR.getId(), Zone.VisionType.DAY);
case "night" -> MapTool.serverCommand()
.setVisionType(currentZR.getId(), Zone.VisionType.NIGHT);
default -> throw new ParserException(
I18N.getText("macro.function.general.argumentTypeInvalid", functionName));
case "night" ->
MapTool.serverCommand().setVisionType(currentZR.getId(), Zone.VisionType.NIGHT);
default ->
throw new ParserException(
I18N.getText("macro.function.general.argumentTypeInvalid", functionName));
}
return "";
} else if ("getMapVision".equalsIgnoreCase(functionName)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ public Object childEvaluate(
FunctionUtil.blockUntrustedMacro(functionName);
yield players.getDatabasePlayers().thenApply(this::playersAsJson).get();
}
default -> throw new ParserException(
I18N.getText("macro.function.general.unknownFunction", functionName));
default ->
throw new ParserException(
I18N.getText("macro.function.general.unknownFunction", functionName));
};
} catch (InterruptedException | ExecutionException e) {
throw new ParserException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ public Object childEvaluate(

String fName = functionName.toLowerCase();
return switch (fName) {
case "server.isserver" -> MapTool.isHostingServer() || MapTool.isPersonalServer()
? BigDecimal.ONE
: BigDecimal.ZERO;
case "server.isserver" ->
MapTool.isHostingServer() || MapTool.isPersonalServer()
? BigDecimal.ONE
: BigDecimal.ZERO;
case "server.ishosting" -> MapTool.isHostingServer() ? BigDecimal.ONE : BigDecimal.ZERO;
case "server.ispersonal" -> MapTool.isPersonalServer() ? BigDecimal.ONE : BigDecimal.ZERO;
case "getmovelock" -> MapTool.getServerPolicy().isMovementLocked();
Expand All @@ -72,8 +73,9 @@ public Object childEvaluate(
}
yield "";
}
default -> throw new ParserException(
I18N.getText("macro.function.general.unknownFunction", functionName));
default ->
throw new ParserException(
I18N.getText("macro.function.general.unknownFunction", functionName));
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ public Object childEvaluate(
case "slash.setalias" -> setSlashAlias(parameters);
case "slash.getaliases" -> getSlashAliases();
case "slash.clearalias" -> clearSlashAlias(parameters);
default -> throw new ParserException(
I18N.getText("macro.function.general.unknownFunction", functionName));
default ->
throw new ParserException(
I18N.getText("macro.function.general.unknownFunction", functionName));
};
}

Expand Down
15 changes: 8 additions & 7 deletions src/main/java/net/rptools/maptool/client/macro/MacroManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ public static Map<String, String> getAliasCommandMap() {
for (var details : entry.getValue()) {
switch (details.scope()) {
case CLIENT, CAMPAIGN -> aliases.put(entry.getKey(), details.command());
case ADDON -> aliases.put(
details.addOnNamespace() + ":" + details.name(), details.command());
case ADDON ->
aliases.put(details.addOnNamespace() + ":" + details.name(), details.command());
}
}
}
Expand Down Expand Up @@ -414,11 +414,12 @@ private static void printAmbiguousAliasMessage(String alias) {
for (var details : def) {
switch (details.scope()) {
case CLIENT -> sb.append("<li>/:").append(details.command()).append("</li>");
case ADDON -> sb.append("<li>/")
.append(details.addOnNamespace())
.append(":")
.append(details.name())
.append("</li>");
case ADDON ->
sb.append("<li>/")
.append(details.addOnNamespace())
.append(":")
.append(details.name())
.append("</li>");
case CAMPAIGN -> {} // Do nothing
}
}
Expand Down
27 changes: 15 additions & 12 deletions src/main/java/net/rptools/maptool/client/ui/AppMenuBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -379,18 +379,21 @@ protected JMenu createHelpMenu() {
for (String key : helpArray) {
OpenUrlAction temp = new AppActions.OpenUrlAction(key);
switch (key) {
case "action.helpurl.01" -> temp.putValue(
Action.SMALL_ICON, RessourceManager.getSmallIcon(Icons.MENU_DOCUMENTATION));
case "action.helpurl.02" -> temp.putValue(
Action.SMALL_ICON, RessourceManager.getSmallIcon(Icons.MENU_TUTORIALS));
case "action.helpurl.03" -> temp.putValue(
Action.SMALL_ICON, RessourceManager.getSmallIcon(Icons.MENU_FORUMS));
case "action.helpurl.04" -> temp.putValue(
Action.SMALL_ICON, RessourceManager.getSmallIcon(Icons.MENU_NETWORK_SETUP));
case "action.helpurl.05" -> temp.putValue(
Action.SMALL_ICON, RessourceManager.getSmallIcon(Icons.MENU_SCRIPTING));
case "action.helpurl.06" -> temp.putValue(
Action.SMALL_ICON, RessourceManager.getSmallIcon(Icons.MENU_FRAMEWORKS));
case "action.helpurl.01" ->
temp.putValue(
Action.SMALL_ICON, RessourceManager.getSmallIcon(Icons.MENU_DOCUMENTATION));
case "action.helpurl.02" ->
temp.putValue(Action.SMALL_ICON, RessourceManager.getSmallIcon(Icons.MENU_TUTORIALS));
case "action.helpurl.03" ->
temp.putValue(Action.SMALL_ICON, RessourceManager.getSmallIcon(Icons.MENU_FORUMS));
case "action.helpurl.04" ->
temp.putValue(
Action.SMALL_ICON, RessourceManager.getSmallIcon(Icons.MENU_NETWORK_SETUP));
case "action.helpurl.05" ->
temp.putValue(Action.SMALL_ICON, RessourceManager.getSmallIcon(Icons.MENU_SCRIPTING));
case "action.helpurl.06" ->
temp.putValue(
Action.SMALL_ICON, RessourceManager.getSmallIcon(Icons.MENU_FRAMEWORKS));
}
menu.add(new JMenuItem(temp));
}
Expand Down
Loading

0 comments on commit 58e0ed7

Please sign in to comment.