From a4e2e80c1c398c7ad7d37d9c222631a16c206620 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Thu, 17 Dec 2015 12:56:49 +0100 Subject: [PATCH] Let importLibrary use `Sketch.SKETCH_EXTENSIONS` For determining if the current file was a sketch file, it previously (indirectly) used a hardcoded "ino" comparison. Now, it uses `SKETCH_EXTENSIONS` so it also applies to .pde files and the hardcoded "ino" (and the methods leading up to it) can be removed. --- app/src/processing/app/SketchController.java | 15 +++------------ arduino-core/src/processing/app/Sketch.java | 7 ------- 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/app/src/processing/app/SketchController.java b/app/src/processing/app/SketchController.java index 902c9e333..34958886a 100644 --- a/app/src/processing/app/SketchController.java +++ b/app/src/processing/app/SketchController.java @@ -800,9 +800,10 @@ public class SketchController { // import statements into the main sketch file (code[0]) // if the current code is a .java file, insert into current //if (current.flavor == PDE) { - if (hasDefaultExtension(editor.getCurrentTab().getSketchCode())) { + SketchCode code = editor.getCurrentTab().getSketchCode(); + if (code.isExtension(Sketch.SKETCH_EXTENSIONS)) editor.selectTab(0); - } + // could also scan the text in the file to see if each import // statement is already in there, but if the user has the import // commented out, then this will be a problem. @@ -1043,16 +1044,6 @@ public class SketchController { // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - // Breaking out extension types in order to clean up the code, and make it - // easier for other environments (like Arduino) to incorporate changes. - - /** - * True if the specified code has the default file extension. - */ - private boolean hasDefaultExtension(SketchCode code) { - return code.isExtension(sketch.getDefaultExtension()); - } - /** * Create the data folder if it does not exist already. As a convenience, * it also returns the data folder, since it's likely about to be used. diff --git a/arduino-core/src/processing/app/Sketch.java b/arduino-core/src/processing/app/Sketch.java index a598841ab..fd312b7a0 100644 --- a/arduino-core/src/processing/app/Sketch.java +++ b/arduino-core/src/processing/app/Sketch.java @@ -155,13 +155,6 @@ public class Sketch { return codes.toArray(new SketchCode[0]); } - /** - * Returns the default extension for this editor setup. - */ - public String getDefaultExtension() { - return "ino"; - } - /** * Returns a file object for the primary .pde of this sketch. */