2323import java .io .File ;
2424import java .io .IOException ;
2525import java .io .StringWriter ;
26- import java .nio .charset .StandardCharsets ;
2726import java .nio .file .Files ;
2827import java .nio .file .Path ;
2928import 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