From 0c62ac898530d56f31fc6082ef752c5e91479e4a Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Fri, 18 Dec 2015 16:27:16 +0100 Subject: [PATCH] Do not store the sketch name in Sketch Sketch already stores the sketch folder, and the sketch name should be identical to the folder name. In the case where the filename passed to the sketch constructor is not the primary .ino file (named after the sketch), this will slightly change behaviour. However, the calling code should prevent this from happening, and with the old code, some internal assumptions were probably violated, so this changes makes handling this situation a bit more robust. Since the actual filename passed to Sketch is no longer used, it is no longer required to pass the name of the primary .ino file. At some point, the constructor should probably be changed to accept a folder name instead of a filename, but that would require a lot of changes to trace this back through the code, so this is something for later. --- arduino-core/src/processing/app/Sketch.java | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/arduino-core/src/processing/app/Sketch.java b/arduino-core/src/processing/app/Sketch.java index beb2f3c75..704364b88 100644 --- a/arduino-core/src/processing/app/Sketch.java +++ b/arduino-core/src/processing/app/Sketch.java @@ -25,12 +25,6 @@ public class Sketch { */ private File folder; - /** - * Name of sketch, which is the name of main file (without .pde or .java - * extension) - */ - private String name; - private List files = new ArrayList(); private static final Comparator CODE_DOCS_COMPARATOR = new Comparator() { @@ -49,15 +43,9 @@ public class Sketch { * on disk to get populate the list of files in this sketch. * * @param file - * The primary file for this sketch. + * Any file inside the sketch directory. */ Sketch(File file) throws IOException { - // get the name of the sketch by chopping .pde or .java - // off of the main file name - String mainFilename = primaryFile.getName(); - int suffixLength = getDefaultExtension().length() + 1; - name = mainFilename.substring(0, mainFilename.length() - suffixLength); - folder = new File(file.getParent()); files = listSketchFiles(true); } @@ -195,7 +183,7 @@ public class Sketch { } public String getName() { - return name; + return folder.getName(); } public File getFolder() {