diff --git a/src/main/java/noppes/npcs/client/gui/util/script/interpreter/DocumentError.java b/src/main/java/noppes/npcs/client/gui/util/script/interpreter/DocumentError.java new file mode 100644 index 000000000..865e560b2 --- /dev/null +++ b/src/main/java/noppes/npcs/client/gui/util/script/interpreter/DocumentError.java @@ -0,0 +1,72 @@ +package noppes.npcs.client.gui.util.script.interpreter; + +import noppes.npcs.client.gui.util.script.interpreter.token.Token; + +/** + * Centralized error representation for the script document. + * Captures all validation errors (method calls, assignments, method declarations, type declarations) + * into a single list for generic processing. + * + *

Each error tracks: + *

+ */ +public class DocumentError { + + private final Token token; + private final int startPos; + private final int endPos; + private final String message; + + /** + * Create a new document error. + * + * @param token The associated token, or null if this error is span-based + * @param startPos Global start offset of the error span + * @param endPos Global end offset of the error span + * @param message Human-readable error description + */ + public DocumentError(Token token, int startPos, int endPos, String message) { + this.token = token; + this.startPos = startPos; + this.endPos = endPos; + this.message = message; + } + + public DocumentError(int startPos, int endPos, String message) { + this.token = null; + this.startPos = startPos; + this.endPos = endPos; + this.message = message; + } + + public Token getToken() { + return token; + } + + public int getStartPos() { + return startPos; + } + + public int getEndPos() { + return endPos; + } + + public String getMessage() { + return message; + } + + @Override + public String toString() { + return "DocumentError{" + + "startPos=" + startPos + + ", endPos=" + endPos + + ", message='" + message + '\'' + + ", token=" + (token != null ? token.getText() : "null") + + '}'; + } +}