Skip to content

Commit b7d1b4e

Browse files
committed
a bit of cleaning while looking for #610
1 parent 21580b6 commit b7d1b4e

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

app/src/processing/app/Sketch.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import java.awt.event.KeyEvent;
4040
import java.io.*;
4141
import java.util.ArrayList;
42-
import java.util.Date;
4342
import java.util.List;
4443
import java.util.concurrent.atomic.AtomicBoolean;
4544

@@ -79,11 +78,11 @@ public class Sketch {
7978
private int currentIndex;
8079

8180
/**
82-
* Number of SketchCode objects (tabs) in the current sketch. Note that this
83-
* will be the same as code.length, because the getCode() method returns
84-
* just the code[] array, rather than a copy of it, or an array that's been
85-
* resized to just the relevant files themselves.
86-
* https://download.processing.org/bugzilla/940.html
81+
* Number of SketchCode objects (tabs) in the current sketch. Note
82+
* that this will be the same as code.length, because the getCode()
83+
* method returns just the code[] array, rather than a copy of it,
84+
* or an array that's been resized to just the relevant files.
85+
* (<a href="https://download.processing.org/bugzilla/940.html">Bugzilla 940</a>)
8786
*/
8887
private int codeCount;
8988
private SketchCode[] code;
@@ -1692,8 +1691,10 @@ public String getName() {
16921691

16931692
/**
16941693
* Returns the name (without extension) of the main tab.
1695-
* Most uses of getName() prior to 4.0 beta 6 were to get the main class,
1696-
* but this allows the sketch to be decoupled from the main tab name.
1694+
* (This version still has underscores and is a legit class name.)
1695+
* Most getName() calls before 4.0 were to get the main class,
1696+
* so this method addition allows the sketch name to be decoupled
1697+
* from the name of the main tab.
16971698
*/
16981699
public String getMainName() {
16991700
return code[0].getPrettyName();

java/src/processing/mode/java/PreprocService.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import java.io.File;
2424
import java.io.IOException;
2525
import java.io.StringWriter;
26-
import java.nio.charset.StandardCharsets;
2726
import java.nio.file.Files;
2827
import java.nio.file.Path;
2928
import java.util.ArrayList;
@@ -103,7 +102,6 @@ public class PreprocService {
103102

104103
/**
105104
* Create a new preprocessing service to support an editor.
106-
* @param editor The editor supported by this service and receives issues.
107105
*/
108106
public PreprocService(JavaMode javaMode, Sketch sketch) {
109107
this.javaMode = javaMode;
@@ -362,6 +360,7 @@ private PreprocSketch preprocessSketch(PreprocSketch prevResult) {
362360
String newPieceBuilt = getSketchTabContents(sc) + '\n';
363361
numLines += SourceUtil.getCount(newPieceBuilt, "\n");
364362
workBuffer.append(newPieceBuilt);
363+
365364
} else if (sc.isExtension("java")) {
366365
tabStartsList.append(workBuffer.length());
367366
tabLineStarts.add(numLines);
@@ -377,7 +376,7 @@ private PreprocSketch preprocessSketch(PreprocSketch prevResult) {
377376
workBuffer.append(newPieceBuilt);
378377
}
379378
}
380-
result.tabStartOffsets = tabStartsList.array();
379+
result.tabStartOffsets = tabStartsList.toArray();
381380

382381
String pdeStage = result.pdeCode = workBuffer.toString();
383382

@@ -419,8 +418,6 @@ private PreprocSketch preprocessSketch(PreprocSketch prevResult) {
419418
}
420419

421420
if (preprocessorResult.getPreprocessIssues().size() > 0) {
422-
final int endNumLines = numLines;
423-
424421
preprocessorResult.getPreprocessIssues().stream()
425422
.map((x) -> ProblemFactory.build(x, tabLineStarts))
426423
.forEach(result.otherProblems::add);
@@ -694,7 +691,7 @@ private void setupParser(boolean resolveBindings, String className,
694691
private Path createTemporaryFile(String content) {
695692
try {
696693
Path tempFile = Files.createTempFile(null, null);
697-
Files.write(tempFile, content.getBytes(StandardCharsets.UTF_8));
694+
Files.writeString(tempFile, content);
698695
return tempFile;
699696
} catch (IOException e) {
700697
throw new RuntimeException("Cannot write to temporary folder.");

0 commit comments

Comments
 (0)