boolean (@NotNull GroovyPsiElement statement) { final Ref<Boolean> hasSideEffect = new Ref<>(false); statement.accept(new GroovyRecursiveElementVisitor() { @Override public void visitMethodCallExpression(@NotNull GrMethodCallExpression methodCallExpression) { hasSideEffect.set(true); } @Override public void visitCallExpression(@NotNull GrCallExpression callExpression) { hasSideEffect.set(true); } @Override public void visitApplicationStatement(@NotNull GrApplicationStatement applicationStatement) { hasSideEffect.set(true); } @Override public void visitClosure(@NotNull GrClosableBlock closure) { hasSideEffect.set(true); } @Override public void visitUnaryExpression(@NotNull GrUnaryExpression expression) { hasSideEffect.set(true); } @Override public void visitElement(@NotNull GroovyPsiElement element) { if (hasSideEffect.get()) return; super.visitElement(element); } }); return hasSideEffect.get(); }