From 747ee29d9566c27a10e2b4b10d71c74196e02717 Mon Sep 17 00:00:00 2001 From: Josh Tynjala Date: Wed, 26 Jun 2024 09:42:24 -0700 Subject: [PATCH] GroovyLanguageServerUtils: return null from syntaxExceptionToRange() if exception start or end line is -1 (closes #90) --- .../groovyls/util/GroovyLanguageServerUtils.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/prominic/groovyls/util/GroovyLanguageServerUtils.java b/src/main/java/net/prominic/groovyls/util/GroovyLanguageServerUtils.java index a0e2aed..3b2c572 100644 --- a/src/main/java/net/prominic/groovyls/util/GroovyLanguageServerUtils.java +++ b/src/main/java/net/prominic/groovyls/util/GroovyLanguageServerUtils.java @@ -60,8 +60,15 @@ public static Position createGroovyPosition(int groovyLine, int groovyColumn) { } public static Range syntaxExceptionToRange(SyntaxException exception) { - return new Range(createGroovyPosition(exception.getStartLine(), exception.getStartColumn()), - createGroovyPosition(exception.getEndLine(), exception.getEndColumn())); + Position start = createGroovyPosition(exception.getStartLine(), exception.getStartColumn()); + if (start == null) { + return null; + } + Position end = createGroovyPosition(exception.getEndLine(), exception.getEndColumn()) + if (end == null) { + return null; + } + return new Range(start, end); } /**