minor cleaning and warnings

This commit is contained in:
Ben Fry
2023-01-15 19:56:50 -05:00
parent 7572501d29
commit 21580b60f1
+29 -24
View File
@@ -30,35 +30,30 @@ import processing.app.Problem;
* according to its tab, including the original IProblem object
*/
public class JavaProblem implements Problem {
/**
* The tab number to which the error belongs to
*/
private int tabIndex;
/**
* Line number(pde code) of the error
*/
private int lineNumber;
/** Error Message. Processed form of IProblem.getMessage() */
private final String message;
/** The type of error - WARNING or ERROR. */
private final int type;
/** The tab number the error belongs to. */
private final int tabIndex;
/** Line number (pde code) of the error */
private final int lineNumber;
private int startOffset;
private int stopOffset;
/**
* Error Message. Processed form of IProblem.getMessage()
*/
private String message;
/**
* The type of error - WARNING or ERROR.
*/
private int type;
/**
* If the error is a 'cannot find type' contains the list of suggested imports
*/
private String[] importSuggestions;
public static final int ERROR = 1, WARNING = 2;
static final int ERROR = 1;
static final int WARNING = 2;
public JavaProblem(String message, int type, int tabIndex, int lineNumber) {
this.message = message;
@@ -67,17 +62,17 @@ public class JavaProblem implements Problem {
this.lineNumber = lineNumber;
}
/**
*
* @param iProblem - The IProblem which is being wrapped
* @param tabIndex - The tab number to which the error belongs to
* @param lineNumber - Line number(pde code) of the error
* @param badCode - The code iProblem refers to.
*/
public static JavaProblem fromIProblem(IProblem iProblem,
int tabIndex, int lineNumber, String badCode) {
static public JavaProblem fromIProblem(IProblem iProblem, int tabIndex,
int lineNumber, String badCode) {
int type = 0;
if(iProblem.isError()) {
if (iProblem.isError()) {
type = ERROR;
} else if (iProblem.isWarning()) {
type = WARNING;
@@ -86,59 +81,69 @@ public class JavaProblem implements Problem {
return new JavaProblem(message, type, tabIndex, lineNumber);
}
public void setPDEOffsets(int startOffset, int stopOffset){
this.startOffset = startOffset;
this.stopOffset = stopOffset;
}
@Override
public int getStartOffset() {
return startOffset;
}
@Override
public int getStopOffset() {
return stopOffset;
}
@Override
public boolean isError() {
return type == ERROR;
}
@Override
public boolean isWarning() {
return type == WARNING;
}
@Override
public String getMessage() {
return message;
}
@Override
public int getTabIndex() {
return tabIndex;
}
@Override
public int getLineNumber() {
return lineNumber;
}
public String[] getImportSuggestions() {
return importSuggestions;
}
public void setImportSuggestions(String[] a) {
importSuggestions = a;
}
@Override
public String toString() {
return "TAB " + tabIndex + ",LN " + lineNumber + "LN START OFF: "
+ startOffset + ",LN STOP OFF: " + stopOffset + ",PROB: "
+ message;
}
}