Skip to content

Commit 1dc08f6

Browse files
committed
Remove problem priority since we're going to do it manually in PDEX.ErrorChecker
1 parent 9efa410 commit 1dc08f6

3 files changed

Lines changed: 6 additions & 91 deletions

File tree

java/src/processing/mode/java/JavaEditor.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2285,26 +2285,6 @@ public void statusHalted() {
22852285
}
22862286

22872287

2288-
/**
2289-
* @return the Problem for the most relevant error or warning on 'line',
2290-
* defaulting to the first.
2291-
*/
2292-
@Override
2293-
protected Problem findProblem(int line) {
2294-
List<Problem> l = findProblems(line);
2295-
if (l.size() == 0) return null;
2296-
Problem worst = l.get(0);
2297-
2298-
for (Problem p : l) {
2299-
if (p instanceof JavaProblem && ((!(worst instanceof JavaProblem)) ||
2300-
((JavaProblem)p).getPriority() > ((JavaProblem)worst).getPriority())) {
2301-
worst = p;
2302-
}
2303-
}
2304-
return worst;
2305-
}
2306-
2307-
23082288
/**
23092289
* Updates the error table in the Error Window.
23102290
* Overridden to handle the fugly import suggestions text.

java/src/processing/mode/java/pdex/JavaProblem.java

Lines changed: 3 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@
2020

2121
package processing.mode.java.pdex;
2222

23-
import java.util.Arrays;
24-
2523
import org.eclipse.jdt.core.compiler.IProblem;
26-
import static org.eclipse.jdt.core.compiler.IProblem.*;
2724

2825
import processing.app.Problem;
2926

@@ -56,65 +53,18 @@ public class JavaProblem implements Problem {
5653
*/
5754
private int type;
5855

59-
/**
60-
* Priority: bigger = higher. Currently 7 to 10 for errors,
61-
* 4 for warning.
62-
* <p>
63-
* The logic of the numbers in the priorityN arrays is that if ECJ wants a
64-
* token got rid of entirely it's most likely the root of the problem. If it
65-
* wants more tokens, that might have been caused by an unterminated string
66-
* or something but it's also likely to be the “real” error. Only if the
67-
* syntax is good are mismatched argument lists and so on of any real
68-
* significance. These rankings are entirely made up so can be changed to
69-
* support any other plausible scenario.
70-
*/
71-
private int priority;
72-
73-
static private final int[] priority10 = {
74-
ParsingError,
75-
ParsingErrorDeleteToken,
76-
ParsingErrorDeleteTokens,
77-
ParsingErrorInvalidToken,
78-
ParsingErrorMergeTokens,
79-
ParsingErrorMisplacedConstruct,
80-
ParsingErrorNoSuggestion,
81-
ParsingErrorNoSuggestionForTokens,
82-
ParsingErrorOnKeyword,
83-
ParsingErrorOnKeywordNoSuggestion,
84-
ParsingErrorReplaceTokens,
85-
ParsingErrorUnexpectedEOF
86-
};
87-
static private final int[] priority9 = {
88-
InvalidCharacterConstant,
89-
UnterminatedString
90-
};
91-
static private final int[] priority8 = {
92-
ParsingErrorInsertToComplete,
93-
ParsingErrorInsertToCompletePhrase,
94-
ParsingErrorInsertToCompleteScope,
95-
ParsingErrorInsertTokenAfter,
96-
ParsingErrorInsertTokenBefore,
97-
};
98-
// Sorted so I can do a one-line binary search later.
99-
static {
100-
Arrays.sort(priority10);
101-
Arrays.sort(priority9);
102-
Arrays.sort(priority8);
103-
}
104-
10556
/**
10657
* If the error is a 'cannot find type' contains the list of suggested imports
10758
*/
10859
private String[] importSuggestions;
10960

11061
public static final int ERROR = 1, WARNING = 2;
11162

112-
public JavaProblem(String message, int type, int tabIndex, int lineNumber, int priority) {
63+
public JavaProblem(String message, int type, int tabIndex, int lineNumber) {
11364
this.message = message;
11465
this.type = type;
11566
this.tabIndex = tabIndex;
11667
this.lineNumber = lineNumber;
117-
this.priority = priority;
11868
}
11969

12070
/**
@@ -127,24 +77,13 @@ public JavaProblem(String message, int type, int tabIndex, int lineNumber, int p
12777
public static JavaProblem fromIProblem(IProblem iProblem,
12878
int tabIndex, int lineNumber, String badCode) {
12979
int type = 0;
130-
int priority = 0;
131-
if (iProblem.isError()) {
80+
if(iProblem.isError()) {
13281
type = ERROR;
133-
if (Arrays.binarySearch(priority10, iProblem.getID()) >= 0) {
134-
priority = 10;
135-
} else if (Arrays.binarySearch(priority9, iProblem.getID()) >= 0) {
136-
priority = 9;
137-
} else if (Arrays.binarySearch(priority8, iProblem.getID()) >= 0) {
138-
priority = 8;
139-
} else {
140-
priority = 7;
141-
}
14282
} else if (iProblem.isWarning()) {
14383
type = WARNING;
144-
priority = 4;
14584
}
14685
String message = ErrorMessageSimplifier.getSimplifiedErrorMessage(iProblem, badCode);
147-
return new JavaProblem(message, type, tabIndex, lineNumber, priority);
86+
return new JavaProblem(message, type, tabIndex, lineNumber);
14887
}
14988

15089
public void setPDEOffsets(int startOffset, int stopOffset){
@@ -195,10 +134,6 @@ public void setImportSuggestions(String[] a) {
195134
importSuggestions = a;
196135
}
197136

198-
public int getPriority() {
199-
return priority;
200-
}
201-
202137
@Override
203138
public String toString() {
204139
return "TAB " + tabIndex + ",LN " + lineNumber + "LN START OFF: "

java/src/processing/mode/java/pdex/PDEX.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,7 +1193,7 @@ static private List<JavaProblem> checkForCurlyQuotes(PreprocessedSketch ps) {
11931193
int tabLine = ps.tabOffsetToTabLine(tabIndex, tabOffset);
11941194

11951195
String message = Language.interpolate("editor.status.bad_curly_quote", q);
1196-
JavaProblem problem = new JavaProblem(message, JavaProblem.ERROR, tabIndex, tabLine, 10);
1196+
JavaProblem problem = new JavaProblem(message, JavaProblem.ERROR, tabIndex, tabLine);
11971197
problem.setPDEOffsets(tabOffset, tabOffset+1);
11981198

11991199
problems.add(problem);
@@ -1229,7 +1229,7 @@ static private List<JavaProblem> checkForCurlyQuotes(PreprocessedSketch ps) {
12291229
} else {
12301230
message = Language.interpolate("editor.status.bad_curly_quote", q);
12311231
}
1232-
JavaProblem p = new JavaProblem(message, JavaProblem.ERROR, in.tabIndex, line, 10);
1232+
JavaProblem p = new JavaProblem(message, JavaProblem.ERROR, in.tabIndex, line);
12331233
p.setPDEOffsets(tabStart, tabStop);
12341234
problems2.add(p);
12351235
}
@@ -1255,7 +1255,7 @@ static private List<JavaProblem> checkForMissingBraces(PreprocessedSketch ps) {
12551255
new JavaProblem(braceResult[0] < 0
12561256
? Language.interpolate("editor.status.missing.left_curly_bracket")
12571257
: Language.interpolate("editor.status.missing.right_curly_bracket"),
1258-
JavaProblem.ERROR, tabIndex, braceResult[1], 8);
1258+
JavaProblem.ERROR, tabIndex, braceResult[1]);
12591259
problem.setPDEOffsets(braceResult[3], braceResult[3] + 1);
12601260
problems.add(problem);
12611261
}

0 commit comments

Comments
 (0)