diff --git a/languages/golang/src/main/java/de/jplag/golang/JPlagGoListener.java b/languages/golang/src/main/java/de/jplag/golang/JPlagGoListener.java index 8774fb81d..e2251353d 100644 --- a/languages/golang/src/main/java/de/jplag/golang/JPlagGoListener.java +++ b/languages/golang/src/main/java/de/jplag/golang/JPlagGoListener.java @@ -542,8 +542,16 @@ public void visitTerminal(TerminalNode node) { expectAndLeave(GoBlockContext.IF_BLOCK); enterContext(GoBlockContext.ELSE_BLOCK); } - case "{" -> transformToken(getCurrentContext().getBegin(), token); - case "}" -> transformToken(getCurrentContext().getEnd(), token); + case "{" -> { + if (getCurrentContext() != null) { + transformToken(getCurrentContext().getBegin(), token); + } + } + case "}" -> { + if (getCurrentContext() != null) { + transformToken(getCurrentContext().getEnd(), token); + } + } default -> { // do nothing. }