| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -40,7 +40,7 @@ public class SketchParser { | |||
| 40 | 40 | List<List<Range>> scientificNotations; | |
| 41 | 41 | ||
| 42 | 42 | // currently is used to ignore numbers in 'setup' and 'settings' functions | |
| 43 | - List<Range> ignoreFunctions; | ||
| 43 | + List<List<Range>> ignoreFunctions; | ||
| 44 | 44 | ||
| 45 | 45 | List<List<Range>> commentBlocks; | |
| 46 | 46 | List<int[]> curlyScopes; | |
@@ -59,11 +59,15 @@ public SketchParser(String[] codeTabs, boolean requiresComment) { | |||
| 59 | 59 | } | |
| 60 | 60 | ||
| 61 | 61 | // add 'settings' and 'setup' to ignore list (to ignore all numbers there) | |
| 62 | - ignoreFunctions = new ArrayList<Range>(); | ||
| 63 | - ignoreFunctions.add(new Range(getVoidFunctionStart(codeTabs[0], "settings"), | ||
| 64 | - getVoidFunctionEnd(codeTabs[0], "settings"))); | ||
| 65 | - ignoreFunctions.add(new Range(getVoidFunctionStart(codeTabs[0], "setup"), | ||
| 66 | - getVoidFunctionEnd(codeTabs[0], "setup"))); | ||
| 62 | + ignoreFunctions = new ArrayList<>(); | ||
| 63 | + ignoreFunctions.add(Arrays.asList(new Range(getVoidFunctionStart(codeTabs[0], "settings"), | ||
| 64 | + getVoidFunctionEnd(codeTabs[0], "settings")), | ||
| 65 | + new Range(getVoidFunctionStart(codeTabs[0], "setup"), | ||
| 66 | + getVoidFunctionEnd(codeTabs[0], "setup")))); | ||
| 67 | + | ||
| 68 | + //Add empty lists for the other tabs so we do not get an index out of bounds error later | ||
| 69 | + for(int i = 0; i < codeTabs.length-1; i++) | ||
| 70 | + ignoreFunctions.add(Collections.EMPTY_LIST); | ||
| 67 | 71 | ||
| 68 | 72 | // build curly scope for every character in the code | |
| 69 | 73 | curlyScopes = new ArrayList<>(); | |
@@ -102,7 +106,6 @@ private void addAllNumbers() { | |||
| 102 | 106 | } | |
| 103 | 107 | } | |
| 104 | 108 | ||
| 105 | - | ||
| 106 | 109 | /** | |
| 107 | 110 | * Get a list of all the numbers in this sketch | |
| 108 | 111 | * @return | |
@@ -130,7 +133,7 @@ private void addAllDecimalNumbers() { | |||
| 130 | 133 | continue; | |
| 131 | 134 | } | |
| 132 | 135 | ||
| 133 | - if (isInRangeList(start, ignoreFunctions)) { | ||
| 136 | + if (isInRangeList(start, ignoreFunctions.get(i))) { | ||
| 134 | 137 | // ignore numbers in predefined functions | |
| 135 | 138 | continue; | |
| 136 | 139 | } | |
@@ -222,7 +225,7 @@ private void addAllHexNumbers() { | |||
| 222 | 225 | continue; | |
| 223 | 226 | } | |
| 224 | 227 | ||
| 225 | - if (isInRangeList(start, ignoreFunctions)) { | ||
| 228 | + if (isInRangeList(start, ignoreFunctions.get(i))) { | ||
| 226 | 229 | // ignore numbers in predefined functions | |
| 227 | 230 | continue; | |
| 228 | 231 | } | |
@@ -283,7 +286,7 @@ private void addAllWebColorNumbers() { | |||
| 283 | 286 | continue; | |
| 284 | 287 | } | |
| 285 | 288 | ||
| 286 | - if (isInRangeList(start, ignoreFunctions)) { | ||
| 289 | + if (isInRangeList(start, ignoreFunctions.get(i))) { | ||
| 287 | 290 | // ignore numbers in predefined functions | |
| 288 | 291 | continue; | |
| 289 | 292 | } | |
@@ -387,7 +390,7 @@ private void createColorBoxes() { | |||
| 387 | 390 | continue; | |
| 388 | 391 | } | |
| 389 | 392 | ||
| 390 | - if (isInRangeList(m.start(), ignoreFunctions)) { | ||
| 393 | + if (isInRangeList(m.start(), ignoreFunctions.get(i))) { | ||
| 391 | 394 | // ignore numbers in predefined functions | |
| 392 | 395 | continue; | |
| 393 | 396 | } | |
@@ -471,7 +474,7 @@ private void createColorBoxesForLights() { | |||
| 471 | 474 | continue; | |
| 472 | 475 | } | |
| 473 | 476 | ||
| 474 | - if (isInRangeList(m.start(), ignoreFunctions)) { | ||
| 477 | + if (isInRangeList(m.start(), ignoreFunctions.get(i))) { | ||
| 475 | 478 | // ignore numbers in predefined functions | |
| 476 | 479 | continue; | |
| 477 | 480 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments