Skip to content

Commit edf4567

Browse files
committed
back out stream() usage that introduced a regression
1 parent bc923f1 commit edf4567

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

java/src/processing/mode/java/tweak/SketchParser.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import java.util.*;
2424
import java.util.regex.Matcher;
2525
import java.util.regex.Pattern;
26-
import java.util.stream.Collectors;
2726

2827

2928
public class SketchParser {
@@ -118,7 +117,7 @@ private void addAllDecimalNumbers() {
118117

119118
Pattern p = Pattern.compile("[\\[\\{<>(),\\t\\s\\+\\-\\/\\*^%!|&=?:~]\\d+\\.?\\d*");
120119
for (int i = 0; i < codeTabs.length; i++) {
121-
List<Handle> handles = new ArrayList<Handle>();
120+
List<Handle> handles = new ArrayList<>();
122121
allHandles.add(handles);
123122

124123
String c = codeTabs[i];
@@ -328,7 +327,7 @@ private void addAllWebColorNumbers() {
328327

329328

330329
private ArrayList<ColorMode> findAllColorModes() {
331-
ArrayList<ColorMode> modes = new ArrayList<ColorMode>();
330+
ArrayList<ColorMode> modes = new ArrayList<>();
332331

333332
for (int i=0; i<codeTabs.length; i++) {
334333
String tab = codeTabs[i];
@@ -369,14 +368,14 @@ private void createColorBoxes() {
369368
Pattern p = Pattern.compile("color\\(|color\\s\\(|fill[\\(\\s]|stroke[\\(\\s]|background[\\(\\s]|tint[\\(\\s]");
370369

371370
for (int i = 0; i < codeTabs.length; i++) {
372-
List<ColorControlBox> colorBox = new ArrayList<ColorControlBox>();
371+
List<ColorControlBox> colorBox = new ArrayList<>();
373372
colorBoxes.add(colorBox);
374373

375374
String tab = codeTabs[i];
376375
Matcher m = p.matcher(tab);
377376

378377
while (m.find()) {
379-
ArrayList<Handle> colorHandles = new ArrayList<Handle>();
378+
ArrayList<Handle> colorHandles = new ArrayList<>();
380379

381380
// look for the '(' and ')' positions
382381
int openPar = tab.indexOf("(", m.start());
@@ -460,7 +459,7 @@ private void createColorBoxesForLights() {
460459
Matcher m = p.matcher(tab);
461460

462461
while (m.find()) {
463-
ArrayList<Handle> colorHandles = new ArrayList<Handle>();
462+
ArrayList<Handle> colorHandles = new ArrayList<>();
464463

465464
// look for the '(' and ')' positions
466465
int openPar = tab.indexOf("(", m.start());
@@ -559,7 +558,7 @@ private ColorMode getColorModeForContext(String context) {
559558

560559
private void handleMultipleColorModes() {
561560
// count how many color modes per context
562-
Map<String, Integer> modeCount = new HashMap<String, Integer>();
561+
Map<String, Integer> modeCount = new HashMap<>();
563562
for (ColorMode cm : colorModes) {
564563
Integer prev = modeCount.get(cm.drawContext);
565564
if (prev == null) {
@@ -569,7 +568,7 @@ private void handleMultipleColorModes() {
569568
}
570569

571570
// find the contexts that have more than one color mode
572-
ArrayList<String> multipleContexts = new ArrayList<String>();
571+
ArrayList<String> multipleContexts = new ArrayList<>();
573572
Set<String> allContexts = modeCount.keySet();
574573
for (String context : allContexts) {
575574
if (modeCount.get(context) > 1) {
@@ -580,11 +579,13 @@ private void handleMultipleColorModes() {
580579
// keep only hex and web color boxes in color calls
581580
// that belong to 'multipleContexts' contexts
582581
for (int i = 0; i < codeTabs.length; i++) {
583-
List<ColorControlBox> toDelete = new ArrayList<ColorControlBox>();
582+
List<ColorControlBox> toDelete = new ArrayList<>();
584583
for (String context : multipleContexts) {
585-
toDelete = colorBoxes.get(i).stream()
586-
.filter(ccb -> ccb.drawContext.equals(context) && !ccb.isHex)
587-
.collect(Collectors.toList());
584+
for (ColorControlBox ccb : colorBoxes.get(i)) {
585+
if (ccb.drawContext.equals(context) && !ccb.isHex) {
586+
toDelete.add(ccb);
587+
}
588+
}
588589
}
589590
colorBoxes.get(i).removeAll(toDelete);
590591
}
@@ -596,7 +597,7 @@ private List<List<Range>> getAllScientificNotations() {
596597

597598
Pattern p = Pattern.compile("[+\\-]?(?:0|[1-9]\\d*)(?:\\.\\d*)?[eE][+\\-]?\\d+");
598599
for (String code : codeTabs) {
599-
List<Range> notation = new ArrayList<Range>();
600+
List<Range> notation = new ArrayList<>();
600601
Matcher m = p.matcher(code);
601602
while (m.find()) {
602603
notation.add(new Range(m.start(), m.end()));
@@ -766,7 +767,7 @@ private boolean isGlobal(int pos, int codeTabIndex) {
766767

767768

768769
static private List<Range> getCommentBlocks(String code) {
769-
List<Range> commentBlocks = new ArrayList<Range>();
770+
List<Range> commentBlocks = new ArrayList<>();
770771

771772
int lastBlockStart=0;
772773
boolean lookForEnd = false;

0 commit comments

Comments
 (0)