Java Code Examples for org.codehaus.groovy.ast.stmt.BlockStatement#setNodeMetaData()
The following examples show how to use
org.codehaus.groovy.ast.stmt.BlockStatement#setNodeMetaData() .
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: RuleVisitor.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
@Override public void visitClosureExpression(ClosureExpression expression) { if (inputs == null) { inputs = ImmutableListMultimap.builder(); try { accessVariable = new VariableExpression(ACCESS_HOLDER_FIELD, ACCESS_API_TYPE); super.visitClosureExpression(expression); BlockStatement code = (BlockStatement) expression.getCode(); code.setNodeMetaData(AST_NODE_METADATA_INPUTS_KEY, inputs.build()); accessVariable.setClosureSharedVariable(true); StaticMethodCallExpression getAccessCall = new StaticMethodCallExpression(CONTEXTUAL_INPUT_TYPE, GET_ACCESS, ArgumentListExpression.EMPTY_ARGUMENTS); DeclarationExpression variableDeclaration = new DeclarationExpression(accessVariable, new Token(Types.ASSIGN, "=", -1, -1), getAccessCall); code.getStatements().add(0, new ExpressionStatement(variableDeclaration)); code.getVariableScope().putDeclaredVariable(accessVariable); } finally { inputs = null; } } else { expression.getVariableScope().putReferencedLocalVariable(accessVariable); super.visitClosureExpression(expression); } }
Example 2
Source File: RuleVisitor.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
@Override public void visitClosureExpression(ClosureExpression expression) { if (inputs == null) { inputs = ImmutableListMultimap.builder(); try { accessVariable = new VariableExpression(ACCESS_HOLDER_FIELD, ACCESS_API_TYPE); super.visitClosureExpression(expression); BlockStatement code = (BlockStatement) expression.getCode(); code.setNodeMetaData(AST_NODE_METADATA_INPUTS_KEY, inputs.build()); accessVariable.setClosureSharedVariable(true); StaticMethodCallExpression getAccessCall = new StaticMethodCallExpression(CONTEXTUAL_INPUT_TYPE, GET_ACCESS, ArgumentListExpression.EMPTY_ARGUMENTS); DeclarationExpression variableDeclaration = new DeclarationExpression(accessVariable, new Token(Types.ASSIGN, "=", -1, -1), getAccessCall); code.getStatements().add(0, new ExpressionStatement(variableDeclaration)); code.getVariableScope().putDeclaredVariable(accessVariable); } finally { inputs = null; } } else { expression.getVariableScope().putReferencedLocalVariable(accessVariable); super.visitClosureExpression(expression); } }
Example 3
Source File: RulesVisitor.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void visitBlockStatement(BlockStatement block) { block.setNodeMetaData(AST_NODE_METADATA_KEY, true); for (Statement statement : block.getStatements()) { statement.visit(this); } }
Example 4
Source File: RulesVisitor.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void visitBlockStatement(BlockStatement block) { block.setNodeMetaData(AST_NODE_METADATA_KEY, true); for (Statement statement : block.getStatements()) { statement.visit(this); } }