Skip to content

Commit a4e2e80

Browse files
matthijskooijmanfacchinm
authored andcommitted
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.
1 parent 5e68b66 commit a4e2e80

File tree

2 files changed

+3
-19
lines changed

2 files changed

+3
-19
lines changed

app/src/processing/app/SketchController.java

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -800,9 +800,10 @@ public void importLibrary(UserLibrary lib) throws IOException {
800800
// import statements into the main sketch file (code[0])
801801
// if the current code is a .java file, insert into current
802802
//if (current.flavor == PDE) {
803-
if (hasDefaultExtension(editor.getCurrentTab().getSketchCode())) {
803+
SketchCode code = editor.getCurrentTab().getSketchCode();
804+
if (code.isExtension(Sketch.SKETCH_EXTENSIONS))
804805
editor.selectTab(0);
805-
}
806+
806807
// could also scan the text in the file to see if each import
807808
// statement is already in there, but if the user has the import
808809
// commented out, then this will be a problem.
@@ -1043,16 +1044,6 @@ private boolean sketchFilesAreReadOnly() {
10431044

10441045
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10451046

1046-
// Breaking out extension types in order to clean up the code, and make it
1047-
// easier for other environments (like Arduino) to incorporate changes.
1048-
1049-
/**
1050-
* True if the specified code has the default file extension.
1051-
*/
1052-
private boolean hasDefaultExtension(SketchCode code) {
1053-
return code.isExtension(sketch.getDefaultExtension());
1054-
}
1055-
10561047
/**
10571048
* Create the data folder if it does not exist already. As a convenience,
10581049
* it also returns the data folder, since it's likely about to be used.

arduino-core/src/processing/app/Sketch.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,6 @@ public SketchCode[] getCodes() {
155155
return codes.toArray(new SketchCode[0]);
156156
}
157157

158-
/**
159-
* Returns the default extension for this editor setup.
160-
*/
161-
public String getDefaultExtension() {
162-
return "ino";
163-
}
164-
165158
/**
166159
* Returns a file object for the primary .pde of this sketch.
167160
*/

0 commit comments

Comments
 (0)