Package org.gradle.groovy.scripts.internal

Examples of org.gradle.groovy.scripts.internal.ScriptBlock


        ModelRegistryDslHelperStatementGenerator statementGenerator = new ModelRegistryDslHelperStatementGenerator();
        BlockStatement rootStatementBlock = source.getAST().getStatementBlock();
        ListIterator<Statement> statementsIterator = rootStatementBlock.getStatements().listIterator();
        while (statementsIterator.hasNext()) {
            Statement statement = statementsIterator.next();
            ScriptBlock scriptBlock = AstUtils.detectScriptBlock(statement, SCRIPT_BLOCK_NAMES);
            if (scriptBlock != null) {
                statementsIterator.remove();
                ScopeVisitor scopeVisitor = new ScopeVisitor(source, statementGenerator);
                scriptBlock.getClosureExpression().getCode().visit(scopeVisitor);
            }
        }
        rootStatementBlock.addStatements(statementGenerator.getGeneratedStatements());
    }
View Full Code Here


            return;
        }

        List<Statement> statements = source.getAST().getStatementBlock().getStatements();
        for (Statement statement : statements) {
            ScriptBlock scriptBlock = AstUtils.detectScriptBlock(statement, SCRIPT_BLOCK_NAMES);
            if (scriptBlock == null) {
                // Look for model(«») (i.e. call to model with anything other than non literal closure)
                MethodCallExpression methodCall = AstUtils.extractBareMethodCall(statement);
                if (methodCall == null) {
                    continue;
                }

                String methodName = AstUtils.extractConstantMethodName(methodCall);
                if (methodName == null) {
                    continue;
                }

                if (methodName.equals(MODEL)) {
                    source.getErrorCollector().addError(
                            new SyntaxException(NON_LITERAL_CLOSURE_TO_TOP_LEVEL_MODEL_MESSAGE, statement.getLineNumber(), statement.getColumnNumber()),
                            source
                    );
                }
            } else {
                RuleVisitor ruleVisitor = new RuleVisitor(source);
                RulesVisitor rulesVisitor = new RulesVisitor(source, ruleVisitor);
                scriptBlock.getClosureExpression().getCode().visit(rulesVisitor);
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.gradle.groovy.scripts.internal.ScriptBlock

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.