Skip to content

Commit 61285f2

Browse files
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 968c8ee commit 61285f2

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
@@ -801,9 +801,10 @@ private void importLibrary(File jarPath) throws IOException {
801801
// import statements into the main sketch file (code[0])
802802
// if the current code is a .java file, insert into current
803803
//if (current.flavor == PDE) {
804-
if (hasDefaultExtension(editor.getCurrentTab().getSketchCode())) {
804+
SketchCode code = editor.getCurrentTab().getSketchCode();
805+
if (code.isExtension(Sketch.SKETCH_EXTENSIONS))
805806
editor.selectTab(0);
806-
}
807+
807808
// could also scan the text in the file to see if each import
808809
// statement is already in there, but if the user has the import
809810
// commented out, then this will be a problem.
@@ -1035,16 +1036,6 @@ private boolean sketchFilesAreReadOnly() {
10351036

10361037
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10371038

1038-
// Breaking out extension types in order to clean up the code, and make it
1039-
// easier for other environments (like Arduino) to incorporate changes.
1040-
1041-
/**
1042-
* True if the specified code has the default file extension.
1043-
*/
1044-
private boolean hasDefaultExtension(SketchCode code) {
1045-
return code.isExtension(sketch.getDefaultExtension());
1046-
}
1047-
10481039
/**
10491040
* Create the data folder if it does not exist already. As a convenience,
10501041
* 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)