1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-12-01 12:24:14 +01:00

Refactor: removed useless parameter from StringReplacer.formatAndSplit

This commit is contained in:
Cristian Maglie 2018-11-09 14:40:08 +01:00 committed by Cristian Maglie
parent 0a0d3c88e0
commit 5428420e0a
6 changed files with 10 additions and 13 deletions

View File

@ -405,7 +405,7 @@ public class Compiler implements MessageConsumer {
String[] cmdArray; String[] cmdArray;
String cmd = prefs.getOrExcept(recipe); String cmd = prefs.getOrExcept(recipe);
try { try {
cmdArray = StringReplacer.formatAndSplit(cmd, dict, true); cmdArray = StringReplacer.formatAndSplit(cmd, dict);
} catch (Exception e) { } catch (Exception e) {
throw new RunnerException(e); throw new RunnerException(e);
} }

View File

@ -95,7 +95,7 @@ public class GenericNetworkUploader extends Uploader {
pattern = prefs.get("upload.network_pattern"); pattern = prefs.get("upload.network_pattern");
if(pattern == null) if(pattern == null)
pattern = prefs.getOrExcept("upload.pattern"); pattern = prefs.getOrExcept("upload.pattern");
String[] cmd = StringReplacer.formatAndSplit(pattern, prefs, true); String[] cmd = StringReplacer.formatAndSplit(pattern, prefs);
uploadResult = executeUploadCommand(cmd); uploadResult = executeUploadCommand(cmd);
} catch (RunnerException e) { } catch (RunnerException e) {
throw e; throw e;

View File

@ -165,7 +165,7 @@ public class SSHUploader extends Uploader {
} }
String pattern = prefs.getOrExcept("upload.pattern"); String pattern = prefs.getOrExcept("upload.pattern");
String command = StringUtils.join(StringReplacer.formatAndSplit(pattern, prefs, true), " "); String command = StringUtils.join(StringReplacer.formatAndSplit(pattern, prefs), " ");
if (verbose) { if (verbose) {
System.out.println(command); System.out.println(command);
} }

View File

@ -108,7 +108,7 @@ public class SerialUploader extends Uploader {
boolean uploadResult; boolean uploadResult;
try { try {
String pattern = prefs.getOrExcept("upload.pattern"); String pattern = prefs.getOrExcept("upload.pattern");
String[] cmd = StringReplacer.formatAndSplit(pattern, prefs, true); String[] cmd = StringReplacer.formatAndSplit(pattern, prefs);
uploadResult = executeUploadCommand(cmd); uploadResult = executeUploadCommand(cmd);
} catch (Exception e) { } catch (Exception e) {
throw new RunnerException(e); throw new RunnerException(e);
@ -200,7 +200,7 @@ public class SerialUploader extends Uploader {
boolean uploadResult; boolean uploadResult;
try { try {
String pattern = prefs.getOrExcept("upload.pattern"); String pattern = prefs.getOrExcept("upload.pattern");
String[] cmd = StringReplacer.formatAndSplit(pattern, prefs, true); String[] cmd = StringReplacer.formatAndSplit(pattern, prefs);
uploadResult = executeUploadCommand(cmd); uploadResult = executeUploadCommand(cmd);
} catch (RunnerException e) { } catch (RunnerException e) {
throw e; throw e;
@ -330,7 +330,7 @@ public class SerialUploader extends Uploader {
try { try {
String pattern = prefs.getOrExcept("program.pattern"); String pattern = prefs.getOrExcept("program.pattern");
String[] cmd = StringReplacer.formatAndSplit(pattern, prefs, true); String[] cmd = StringReplacer.formatAndSplit(pattern, prefs);
return executeUploadCommand(cmd); return executeUploadCommand(cmd);
} catch (RunnerException e) { } catch (RunnerException e) {
throw e; throw e;
@ -394,12 +394,12 @@ public class SerialUploader extends Uploader {
new LoadVIDPIDSpecificPreferences().load(prefs); new LoadVIDPIDSpecificPreferences().load(prefs);
String pattern = prefs.getOrExcept("erase.pattern"); String pattern = prefs.getOrExcept("erase.pattern");
String[] cmd = StringReplacer.formatAndSplit(pattern, prefs, true); String[] cmd = StringReplacer.formatAndSplit(pattern, prefs);
if (!executeUploadCommand(cmd)) if (!executeUploadCommand(cmd))
return false; return false;
pattern = prefs.getOrExcept("bootloader.pattern"); pattern = prefs.getOrExcept("bootloader.pattern");
cmd = StringReplacer.formatAndSplit(pattern, prefs, true); cmd = StringReplacer.formatAndSplit(pattern, prefs);
return executeUploadCommand(cmd); return executeUploadCommand(cmd);
} }
} }

View File

@ -60,7 +60,7 @@ public class Sizer implements MessageConsumer {
int r = 0; int r = 0;
try { try {
String pattern = prefs.get("recipe.size.pattern"); String pattern = prefs.get("recipe.size.pattern");
String cmd[] = StringReplacer.formatAndSplit(pattern, prefs, true); String cmd[] = StringReplacer.formatAndSplit(pattern, prefs);
exception = null; exception = null;
textSize = -1; textSize = -1;

View File

@ -27,16 +27,13 @@ import java.util.Map;
public class StringReplacer { public class StringReplacer {
public static String[] formatAndSplit(String src, Map<String, String> dict, public static String[] formatAndSplit(String src, Map<String, String> dict) throws Exception {
boolean recursive) throws Exception {
String res; String res;
// Recursive replace with a max depth of 10 levels. // Recursive replace with a max depth of 10 levels.
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
// Do a replace with dictionary // Do a replace with dictionary
res = StringReplacer.replaceFromMapping(src, dict); res = StringReplacer.replaceFromMapping(src, dict);
if (!recursive)
break;
if (res.equals(src)) if (res.equals(src))
break; break;
src = res; src = res;