Depending on how the Problem is made, the error may be given relative to
start of line or start of tab. Flag indicates to users of Problems which
one they are working with.
This commit is contained in:
Sam Pottinger
2023-05-10 16:13:37 -07:00
parent 80a5b124f1
commit 490fc2bfee
6 changed files with 35 additions and 9 deletions

View File

@@ -82,7 +82,7 @@ public class JavaProblem implements Problem {
}
public void setPDEOffsets(int startOffset, int stopOffset){
public void setPDEOffsets(int startOffset, int stopOffset) {
this.startOffset = startOffset;
this.stopOffset = stopOffset;
}
@@ -139,6 +139,9 @@ public class JavaProblem implements Problem {
importSuggestions = a;
}
public boolean isLineOffset() {
return false;
}
@Override
public String toString() {

View File

@@ -53,7 +53,8 @@ public class ProblemFactory {
localLine,
message,
lineStart,
lineStop
lineStop,
false
);
}
@@ -83,8 +84,9 @@ public class ProblemFactory {
tab,
localLine,
message,
localLine,
localLine + col
0,
col,
true
);
}

View File

@@ -10,6 +10,7 @@ public class SyntaxProblem extends JavaProblem {
private final String message;
private final int startOffset;
private final int stopOffset;
private final boolean lineFlag;
/**
* Create a new syntax problem.
@@ -18,12 +19,14 @@ public class SyntaxProblem extends JavaProblem {
* @param newLineNumber The line number within the tab at which the offending code can be found.
* @param newMessage Human readable message describing the issue.
* @param newStartOffset The character index at which the issue starts. This is relative to start
* of tab / file not relative to start of line.
* of tab / file not relative to start of line if newIsLineOffset is true else it is line
* offset.
* @param newStopOffset The character index at which the issue ends. This is relative to start
* * of tab / file not relative to start of line.
* of tab / file not relative to start of line if newIsLineOffset is true else it is line
* offset.
*/
public SyntaxProblem(int newTabIndex, int newLineNumber, String newMessage, int newStartOffset,
int newStopOffset) {
int newStopOffset, boolean newIsLineOffset) {
super(newMessage, JavaProblem.ERROR, newLineNumber, newLineNumber);
@@ -32,6 +35,7 @@ public class SyntaxProblem extends JavaProblem {
message = newMessage;
startOffset = newStartOffset;
stopOffset = newStopOffset;
lineFlag = newIsLineOffset;
}
@Override
@@ -69,4 +73,8 @@ public class SyntaxProblem extends JavaProblem {
return stopOffset;
}
public boolean isLineOffset() {
return lineFlag;
}
}