mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-20 14:54:31 +01:00
Let SketchFile figure out if it is primary by itself
Previously, the caller of the constructor did this, but now that SketchFile keeps a reference to its containing sketch, it can figure it out itself.
This commit is contained in:
parent
1d15c434dc
commit
c4e77a7c3c
@ -103,9 +103,7 @@ public class Sketch {
|
||||
Set<SketchFile> result = new TreeSet<>(CODE_DOCS_COMPARATOR);
|
||||
for (File file : FileUtils.listFiles(folder, false, EXTENSIONS)) {
|
||||
if (BaseNoGui.isSanitaryName(file.getName())) {
|
||||
FileUtils.SplitFile split = FileUtils.splitFilename(file);
|
||||
boolean isPrimary = split.basename.equals(folder.getName()) && SKETCH_EXTENSIONS.contains(split.extension);
|
||||
result.add(new SketchFile(this, file, isPrimary));
|
||||
result.add(new SketchFile(this, file));
|
||||
} else if (showWarnings) {
|
||||
System.err.println(I18n.format(tr("File name {0} is invalid: ignored"), file.getName()));
|
||||
}
|
||||
@ -287,7 +285,7 @@ public class Sketch {
|
||||
checkNewFilename(newFile);
|
||||
|
||||
// Add a new sketchFile
|
||||
SketchFile sketchFile = new SketchFile(this, newFile, false);
|
||||
SketchFile sketchFile = new SketchFile(this, newFile);
|
||||
files.add(sketchFile);
|
||||
Collections.sort(files, CODE_DOCS_COMPARATOR);
|
||||
|
||||
|
@ -91,10 +91,12 @@ public class SketchFile {
|
||||
* @param primary
|
||||
* Whether this file is the primary file of the sketch
|
||||
*/
|
||||
public SketchFile(Sketch sketch, File file, boolean primary) {
|
||||
public SketchFile(Sketch sketch, File file) {
|
||||
this.sketch = sketch;
|
||||
this.file = file;
|
||||
this.primary = primary;
|
||||
FileUtils.SplitFile split = FileUtils.splitFilename(file);
|
||||
this.primary = split.basename.equals(sketch.getFolder().getName())
|
||||
&& Sketch.SKETCH_EXTENSIONS.contains(split.extension);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user