Java Code Examples for org.codehaus.groovy.ast.stmt.BlockStatement#isEmpty()
The following examples show how to use
org.codehaus.groovy.ast.stmt.BlockStatement#isEmpty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OptimizingStatementWriter.java From groovy with Apache License 2.0 | 6 votes |
@Override public void visitBlockStatement(final BlockStatement statement) { opt.push(); boolean optAll = true; for (Statement stmt : statement.getStatements()) { opt.push(); stmt.visit(this); optAll = optAll && opt.canOptimize(); opt.pop(true); } if (statement.isEmpty()) { opt.chainCanOptimize(true); opt.pop(true); } else { opt.chainShouldOptimize(optAll); if (optAll) { addMeta(statement, opt); } opt.pop(optAll); } }
Example 2
Source File: StatementWriter.java From groovy with Apache License 2.0 | 5 votes |
private boolean isMethodOrConstructorNonEmptyBlock(final BlockStatement block) { MethodNode methodNode = controller.getMethodNode(); if (methodNode == null) { methodNode = controller.getConstructorNode(); } return (methodNode != null && methodNode.getCode() == block && !block.isEmpty()); }