mirror of
https://github.com/arduino/Arduino.git
synced 2024-12-01 12:24:14 +01:00
Let SketchFile store a reference to the Sketch it belongs to
This allows simplifying some other things later.
This commit is contained in:
parent
b28f1a479d
commit
74e5228a0f
@ -105,7 +105,7 @@ public class Sketch {
|
||||
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(file, isPrimary));
|
||||
result.add(new SketchFile(this, file, isPrimary));
|
||||
} else if (showWarnings) {
|
||||
System.err.println(I18n.format(tr("File name {0} is invalid: ignored"), file.getName()));
|
||||
}
|
||||
@ -305,7 +305,7 @@ public class Sketch {
|
||||
checkNewFilename(newFile);
|
||||
|
||||
// Add a new sketchFile
|
||||
SketchFile sketchFile = new SketchFile(newFile, false);
|
||||
SketchFile sketchFile = new SketchFile(this, newFile, false);
|
||||
files.add(sketchFile);
|
||||
Collections.sort(files, CODE_DOCS_COMPARATOR);
|
||||
|
||||
|
@ -45,6 +45,11 @@ public class SketchFile {
|
||||
*/
|
||||
private File file;
|
||||
|
||||
/**
|
||||
* The sketch this file belongs to.
|
||||
*/
|
||||
private Sketch sketch;
|
||||
|
||||
/**
|
||||
* Is this the primary file in the sketch?
|
||||
*/
|
||||
@ -79,12 +84,15 @@ public class SketchFile {
|
||||
/**
|
||||
* Create a new SketchFile
|
||||
*
|
||||
* @param sketch
|
||||
* The sketch this file belongs to
|
||||
* @param file
|
||||
* The file this SketchFile represents
|
||||
* @param primary
|
||||
* Whether this file is the primary file of the sketch
|
||||
*/
|
||||
public SketchFile(File file, boolean primary) {
|
||||
public SketchFile(Sketch sketch, File file, boolean primary) {
|
||||
this.sketch = sketch;
|
||||
this.file = file;
|
||||
this.primary = primary;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user