Skip to content

Commit 6f48a40

Browse files
committed
Merge pull request #3227 from ffissore/editor-assembly-support
Allowing editing .S files
2 parents 2afdb8a + 56e0349 commit 6f48a40

File tree

3 files changed

+12
-19
lines changed

3 files changed

+12
-19
lines changed

Diff for: app/src/processing/app/Sketch.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ public boolean addFile(File sourceFile) {
836836
destFile = new File(data.getCodeFolder(), filename);
837837

838838
} else {
839-
for (String extension : data.getExtensions()) {
839+
for (String extension : SketchData.EXTENSIONS) {
840840
String lower = filename.toLowerCase();
841841
if (lower.endsWith("." + extension)) {
842842
destFile = new File(data.getFolder(), filename);
@@ -1345,7 +1345,7 @@ public boolean isDefaultExtension(String what) {
13451345
* extensions.
13461346
*/
13471347
public boolean validExtension(String what) {
1348-
return data.getExtensions().contains(what);
1348+
return SketchData.EXTENSIONS.contains(what);
13491349
}
13501350

13511351

Diff for: arduino-core/src/processing/app/SketchData.java

+8-15
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
package processing.app;
22

3+
import com.google.common.collect.FluentIterable;
4+
35
import static processing.app.I18n._;
46

57
import java.io.File;
68
import java.io.IOException;
7-
import java.util.ArrayList;
8-
import java.util.Arrays;
9-
import java.util.Collections;
10-
import java.util.Comparator;
11-
import java.util.List;
9+
import java.util.*;
1210

1311
public class SketchData {
1412

13+
public static final List<String> SKETCH_EXTENSIONS = Arrays.asList("ino", "pde");
14+
public static final List<String> OTHER_ALLOWED_EXTENSIONS = Arrays.asList("c", "cpp", "h", "s");
15+
public static final List<String> EXTENSIONS = new LinkedList<String>(FluentIterable.from(SKETCH_EXTENSIONS).append(OTHER_ALLOWED_EXTENSIONS).toList());
16+
1517
/** main pde file for this sketch. */
1618
private File primaryFile;
1719

@@ -105,8 +107,6 @@ protected void load() throws IOException {
105107
clearCodeDocs();
106108
// data.setCodeDocs(codeDocs);
107109

108-
List<String> extensions = getExtensions();
109-
110110
for (String filename : list) {
111111
// Ignoring the dot prefix files is especially important to avoid files
112112
// with the ._ prefix on Mac OS X. (You'll see this with Mac files on
@@ -119,7 +119,7 @@ protected void load() throws IOException {
119119
// figure out the name without any extension
120120
String base = filename;
121121
// now strip off the .pde and .java extensions
122-
for (String extension : extensions) {
122+
for (String extension : EXTENSIONS) {
123123
if (base.toLowerCase().endsWith("." + extension)) {
124124
base = base.substring(0, base.length() - (extension.length() + 1));
125125

@@ -173,13 +173,6 @@ public String getDefaultExtension() {
173173
return "ino";
174174
}
175175

176-
/**
177-
* Returns a String[] array of proper extensions.
178-
*/
179-
public List<String> getExtensions() {
180-
return Arrays.asList("ino", "pde", "c", "cpp", "h");
181-
}
182-
183176
/**
184177
* Returns a file object for the primary .pde of this sketch.
185178
*/

Diff for: arduino-core/src/processing/app/debug/Compiler.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,7 @@ public void preprocess(String buildPath, PdePreprocessor preprocessor) throws Ru
12011201
StringBuffer bigCode = new StringBuffer();
12021202
int bigCount = 0;
12031203
for (SketchCode sc : sketch.getCodes()) {
1204-
if (sc.isExtension("ino") || sc.isExtension("pde")) {
1204+
if (sc.isExtension(SketchData.SKETCH_EXTENSIONS)) {
12051205
sc.setPreprocOffset(bigCount);
12061206
// These #line directives help the compiler report errors with
12071207
// correct the filename and line number (issue 281 & 907)
@@ -1272,7 +1272,7 @@ public void preprocess(String buildPath, PdePreprocessor preprocessor) throws Ru
12721272
// 3. then loop over the code[] and save each .java file
12731273

12741274
for (SketchCode sc : sketch.getCodes()) {
1275-
if (sc.isExtension("c") || sc.isExtension("cpp") || sc.isExtension("h")) {
1275+
if (sc.isExtension(SketchData.OTHER_ALLOWED_EXTENSIONS)) {
12761276
// no pre-processing services necessary for java files
12771277
// just write the the contents of 'program' to a .java file
12781278
// into the build directory. uses byte stream and reader/writer

0 commit comments

Comments
 (0)