From f7fdd08695e8cd6c67c17d96357a94c43a4c54cf Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Wed, 9 Dec 2015 11:18:38 +0100 Subject: [PATCH] Do not show invalid sketch filename warnings on reload With this commit, any warnings about invalid sketch filenames are not shown when the sketch is reloaded. This reloading happens whenever the IDE window is focused, so re-logging warnings all the time isn't really helpful, so this hides them. --- arduino-core/src/processing/app/SketchData.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/arduino-core/src/processing/app/SketchData.java b/arduino-core/src/processing/app/SketchData.java index bfd44168c..02309707e 100644 --- a/arduino-core/src/processing/app/SketchData.java +++ b/arduino-core/src/processing/app/SketchData.java @@ -74,7 +74,7 @@ public class SketchData { folder = new File(file.getParent()); codeFolder = new File(folder, "code"); dataFolder = new File(folder, "data"); - codes = listSketchFiles(); + codes = listSketchFiles(true); } static public File checkSketchFile(File file) { @@ -109,7 +109,7 @@ public class SketchData { * not. */ public boolean reload() throws IOException { - List reloaded = listSketchFiles(); + List reloaded = listSketchFiles(false); if (!reloaded.equals(codes)) { codes = reloaded; return true; @@ -122,13 +122,16 @@ public class SketchData { * part of this sketch. Doesn't modify this SketchData instance, just * returns a filtered and sorted list of File objects ready to be * passed to the SketchCode constructor. + * + * @param showWarnings + * When true, any invalid filenames will show a warning. */ - private List listSketchFiles() throws IOException { + private List listSketchFiles(boolean showWarnings) throws IOException { Set result = new TreeSet<>(CODE_DOCS_COMPARATOR); for (File file : FileUtils.listFiles(folder, false, EXTENSIONS)) { if (BaseNoGui.isSanitaryName(file.getName())) { result.add(new SketchCode(file, file.equals(primaryFile))); - } else { + } else if (showWarnings) { System.err.println(I18n.format(tr("File name {0} is invalid: ignored"), file.getName())); } }