Skip to content

Commit

Permalink
Fix #444 by removing old regex parsing.
Browse files Browse the repository at this point in the history
It looks like there's still some left over regex parsing to check for missing braces from before the new preproc. The new preproc will catch the error and testing makes it look like this old regex check is not triggering anyway outside of comments (which is an issue reported in #444).
  • Loading branch information
sampottinger committed Jun 21, 2022
1 parent fa8eef0 commit 0c179d2
Showing 1 changed file with 0 additions and 51 deletions.
51 changes: 0 additions & 51 deletions java/src/processing/mode/java/ErrorChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,6 @@ private void handleSketchProblems(PreprocSketch ps) {
problems.addAll(curlyQuoteProblems);
}

if (problems.isEmpty()) { // Check for missing braces
List<JavaProblem> missingBraceProblems = checkForMissingBraces(ps);
problems.addAll(missingBraceProblems);
}

if (problems.isEmpty()) {
AtomicReference<ClassPath> searchClassPath =
new AtomicReference<>(null);
Expand Down Expand Up @@ -283,52 +278,6 @@ static private List<JavaProblem> checkForCurlyQuotes(PreprocSketch ps) {
}


static private List<JavaProblem> checkForMissingBraces(PreprocSketch ps) {
List<JavaProblem> problems = new ArrayList<>(0);
for (int tabIndex = 0; tabIndex < ps.tabStartOffsets.length; tabIndex++) {
int tabStartOffset = ps.tabStartOffsets[tabIndex];
int tabEndOffset = (tabIndex < ps.tabStartOffsets.length - 1) ?
ps.tabStartOffsets[tabIndex + 1] : ps.scrubbedPdeCode.length();
int[] braceResult = SourceUtil.checkForMissingBraces(ps.scrubbedPdeCode, tabStartOffset, tabEndOffset);
if (braceResult[0] != 0) {
JavaProblem problem =
new JavaProblem(braceResult[0] < 0
? Language.interpolate("editor.status.missing.left_curly_bracket")
: Language.interpolate("editor.status.missing.right_curly_bracket"),
JavaProblem.ERROR, tabIndex, braceResult[1]);
problem.setPDEOffsets(braceResult[3], braceResult[3] + 1);
problems.add(problem);
}
}

if (problems.isEmpty()) {
return problems;
}

int problemTabIndex = problems.get(0).getTabIndex();

IProblem missingBraceProblem =
Arrays.stream(ps.compilationUnit.getProblems())
.filter(ErrorChecker::isMissingBraceProblem)
// Ignore if it is at the end of file
.filter(p -> p.getSourceEnd() + 1 < ps.javaCode.length())
// Ignore if the tab number does not match our detected tab number
.filter(p -> problemTabIndex == ps.mapJavaToSketch(p).tabIndex)
.findFirst()
.orElse(null);

// Prefer ECJ problem, shows location more accurately
if (missingBraceProblem != null) {
JavaProblem p = convertIProblem(missingBraceProblem, ps);
if (p != null) {
problems.clear();
problems.add(p);
}
}
return problems;
}


static public String[] getImportSuggestions(ClassPath cp, String className) {
className = className.replace("[", "\\[").replace("]", "\\]");
RegExpResourceFilter filter = new RegExpResourceFilter(
Expand Down

0 comments on commit 0c179d2

Please sign in to comment.