Fixed NPE in ScriptError if INode is empty (#1985)

Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
Christoph Weitkamp 2020-12-22 20:34:49 +01:00 committed by GitHub
parent bf14e1077f
commit 7ce96ac06a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -62,10 +62,16 @@ public final class ScriptError {
public ScriptError(final String message, final EObject atEObject) {
this.message = message;
INode node = NodeModelUtils.getNode(atEObject);
LineAndColumn lac = NodeModelUtils.getLineAndColumn(node, node.getOffset());
this.line = lac.getLine();
this.column = lac.getColumn();
this.length = node.getEndOffset() - node.getOffset();
if (node == null) {
this.line = 0;
this.column = 0;
this.length = -1;
} else {
LineAndColumn lac = NodeModelUtils.getLineAndColumn(node, node.getOffset());
this.line = lac.getLine();
this.column = lac.getColumn();
this.length = node.getEndOffset() - node.getOffset();
}
}
/**