Skip to content

Commit 6a62bf2

Browse files
author
Federico Fissore
committed
Code cleanup
1 parent 5fbf962 commit 6a62bf2

File tree

1 file changed

+19
-25
lines changed

1 file changed

+19
-25
lines changed

app/src/processing/app/Sketch.java

+19-25
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public Sketch(Editor _editor, File file) throws IOException {
104104
* Another exception is when an external editor is in use,
105105
* in which case the load happens each time "run" is hit.
106106
*/
107-
protected void load() throws IOException {
107+
private void load() throws IOException {
108108
load(false);
109109
}
110110

@@ -569,10 +569,8 @@ public boolean save() throws IOException {
569569
// rename .pde files to .ino
570570
File mainFile = new File(getMainFilePath());
571571
File mainFolder = mainFile.getParentFile();
572-
File[] pdeFiles = mainFolder.listFiles(new FilenameFilter() {
573-
public boolean accept(File dir, String name) {
574-
return name.toLowerCase().endsWith(".pde");
575-
}
572+
File[] pdeFiles = mainFolder.listFiles((dir, name) -> {
573+
return name.toLowerCase().endsWith(".pde");
576574
});
577575

578576
if (pdeFiles != null && pdeFiles.length > 0) {
@@ -695,6 +693,7 @@ protected boolean saveAs() throws IOException {
695693
return false;
696694
}
697695
} catch (IOException e) {
696+
//ignore
698697
}
699698

700699
// if the new folder already exists, then need to remove
@@ -939,7 +938,7 @@ public void importLibrary(UserLibrary lib) throws IOException {
939938
* Add import statements to the current tab for all of packages inside
940939
* the specified jar file.
941940
*/
942-
public void importLibrary(File jarPath) throws IOException {
941+
private void importLibrary(File jarPath) throws IOException {
943942
// make sure the user didn't hide the sketch folder
944943
ensureExistence();
945944

@@ -983,7 +982,7 @@ public void setCurrentCode(int which) {
983982
setCurrentCode(which, false);
984983
}
985984

986-
public void setCurrentCode(int which, boolean forceUpdate) {
985+
private void setCurrentCode(int which, boolean forceUpdate) {
987986
// if current is null, then this is the first setCurrent(0)
988987
if (!forceUpdate && (currentIndex == which) && (current != null)) {
989988
return;
@@ -1096,18 +1095,13 @@ public String build(boolean verbose, boolean save) throws RunnerException, Prefe
10961095
*
10971096
* @return null if compilation failed, main class name if not
10981097
*/
1099-
public String build(String buildPath, boolean verbose, boolean save) throws RunnerException, PreferencesMapException {
1098+
private String build(String buildPath, boolean verbose, boolean save) throws RunnerException, PreferencesMapException {
11001099
// run the preprocessor
11011100
editor.status.progressUpdate(20);
11021101

11031102
ensureExistence();
11041103

1105-
ProgressListener pl = new ProgressListener() {
1106-
@Override
1107-
public void progress(int percent) {
1108-
editor.status.progressUpdate(percent);
1109-
}
1110-
};
1104+
ProgressListener pl = editor.status::progressUpdate;
11111105

11121106
return Compiler.build(data, buildPath, tempBuildFolder, pl, verbose, save);
11131107
}
@@ -1120,7 +1114,7 @@ protected boolean exportApplet(boolean usingProgrammer) throws Exception {
11201114
/**
11211115
* Handle export to applet.
11221116
*/
1123-
public boolean exportApplet(String appletPath, boolean usingProgrammer)
1117+
private boolean exportApplet(String appletPath, boolean usingProgrammer)
11241118
throws Exception {
11251119

11261120
prepare();
@@ -1146,7 +1140,7 @@ public boolean exportApplet(String appletPath, boolean usingProgrammer)
11461140
return success;
11471141
}
11481142

1149-
protected boolean upload(String buildPath, String suggestedClassName, boolean usingProgrammer) throws Exception {
1143+
private boolean upload(String buildPath, String suggestedClassName, boolean usingProgrammer) throws Exception {
11501144

11511145
Uploader uploader = Compiler.getUploaderByPreferences(false);
11521146

@@ -1165,7 +1159,7 @@ protected boolean upload(String buildPath, String suggestedClassName, boolean us
11651159
PreferencesData.set(uploader.getAuthorizationKey(), dialog.getPassword());
11661160
}
11671161

1168-
List<String> warningsAccumulator = new LinkedList<String>();
1162+
List<String> warningsAccumulator = new LinkedList<>();
11691163
try {
11701164
success = Compiler.upload(data, uploader, buildPath, suggestedClassName, usingProgrammer, false, warningsAccumulator);
11711165
} finally {
@@ -1191,7 +1185,7 @@ protected boolean upload(String buildPath, String suggestedClassName, boolean us
11911185
* Only checks to see if the main folder is still around,
11921186
* but not its contents.
11931187
*/
1194-
protected void ensureExistence() {
1188+
private void ensureExistence() {
11951189
if (data.getFolder().exists()) return;
11961190

11971191
Base.showWarning(_("Sketch Disappeared"),
@@ -1254,15 +1248,15 @@ public boolean isReadOnly() {
12541248
/**
12551249
* True if the specified code has the default file extension.
12561250
*/
1257-
public boolean hasDefaultExtension(SketchCode code) {
1251+
private boolean hasDefaultExtension(SketchCode code) {
12581252
return code.isExtension(getDefaultExtension());
12591253
}
12601254

12611255

12621256
/**
12631257
* True if the specified extension is the default file extension.
12641258
*/
1265-
public boolean isDefaultExtension(String what) {
1259+
private boolean isDefaultExtension(String what) {
12661260
return what.equals(getDefaultExtension());
12671261
}
12681262

@@ -1271,7 +1265,7 @@ public boolean isDefaultExtension(String what) {
12711265
* Check this extension (no dots, please) against the list of valid
12721266
* extensions.
12731267
*/
1274-
public boolean validExtension(String what) {
1268+
private boolean validExtension(String what) {
12751269
return SketchData.EXTENSIONS.contains(what);
12761270
}
12771271

@@ -1324,7 +1318,7 @@ public File getFolder() {
13241318
* Create the data folder if it does not exist already. As a convenience,
13251319
* it also returns the data folder, since it's likely about to be used.
13261320
*/
1327-
public File prepareDataFolder() {
1321+
private File prepareDataFolder() {
13281322
if (!data.getDataFolder().exists()) {
13291323
data.getDataFolder().mkdirs();
13301324
}
@@ -1336,7 +1330,7 @@ public File prepareDataFolder() {
13361330
* Create the code folder if it does not exist already. As a convenience,
13371331
* it also returns the code folder, since it's likely about to be used.
13381332
*/
1339-
public File prepareCodeFolder() {
1333+
private File prepareCodeFolder() {
13401334
if (!data.getCodeFolder().exists()) {
13411335
data.getCodeFolder().mkdirs();
13421336
}
@@ -1369,7 +1363,7 @@ public SketchCode getCurrentCode() {
13691363
}
13701364

13711365

1372-
public void setUntitled(boolean u) {
1366+
private void setUntitled(boolean u) {
13731367
editor.untitled = u;
13741368
}
13751369

@@ -1386,7 +1380,7 @@ public boolean isUntitled() {
13861380
* Convert to sanitized name and alert the user
13871381
* if changes were made.
13881382
*/
1389-
static public String checkName(String origName) {
1383+
private static String checkName(String origName) {
13901384
String newName = BaseNoGui.sanitizeName(origName);
13911385

13921386
if (!newName.equals(origName)) {

0 commit comments

Comments
 (0)