Examples of EmptyExpression


Examples of org.codehaus.groovy.ast.expr.EmptyExpression

                    final MethodCallExpression sendErrorMethodCall = new MethodCallExpression(responsePropertyExpression, "sendError", new ConstantExpression(HttpServletResponse.SC_METHOD_NOT_ALLOWED));
                    final ReturnStatement returnStatement = new ReturnStatement(new ConstantExpression(null));
                    final BlockStatement blockToSendError = new BlockStatement();
                    blockToSendError.addStatement(new ExpressionStatement(sendErrorMethodCall));
                    blockToSendError.addStatement(returnStatement);
                    final IfStatement ifIsValidRequestMethodStatement = new IfStatement(isValidRequestMethod, new ExpressionStatement(new EmptyExpression()), blockToSendError);
                 
                    checkAllowedMethodsBlock.addStatement(ifIsValidRequestMethodStatement);
                }
            }
        }
View Full Code Here

Examples of org.codehaus.groovy.ast.expr.EmptyExpression

    protected void initializeAndValidateCommandObjectParameter(final BlockStatement wrapper,
            final ClassNode controllerNode, final ClassNode commandObjectNode,
            final ASTNode actionNode, final String actionName, final String paramName,
            final SourceUnit source, final GeneratorContext context) {
        final DeclarationExpression declareCoExpression = new DeclarationExpression(
                new VariableExpression(paramName, commandObjectNode), Token.newSymbol(Types.EQUALS, 0, 0), new EmptyExpression());
        wrapper.addStatement(new ExpressionStatement(declareCoExpression));

        if(commandObjectNode.isInterface() || Modifier.isAbstract(commandObjectNode.getModifiers())) {
            final String warningMessage = "The [" + actionName + "] action in [" +
                    controllerNode.getName() + "] accepts a parameter of type [" +
                    commandObjectNode.getName() +
                    "].  Interface types and abstract class types are not supported as command objects.  This parameter will be ignored.";
            GrailsASTUtils.warning(source, actionNode, warningMessage);
        } else {
            initializeCommandObjectParameter(wrapper, commandObjectNode, paramName, source);

            @SuppressWarnings("unchecked")
            boolean argumentIsValidateable = GrailsASTUtils.hasAnyAnnotations(
                    commandObjectNode,
                    grails.validation.Validateable.class,
                    grails.persistence.Entity.class,
                    javax.persistence.Entity.class);

            if (!argumentIsValidateable) {
                final ModuleNode commandObjectModule = commandObjectNode.getModule();
                if (commandObjectModule != null) {
                    if (commandObjectModule == controllerNode.getModule() ||
                            doesModulePathIncludeSubstring(commandObjectModule,
                                    "grails-app" + File.separator + "controllers" + File.separator)) {
                        final ASTValidateableHelper h = new DefaultASTValidateableHelper();
                        h.injectValidateableCode(commandObjectNode, false);
                        argumentIsValidateable = true;
                    } else if (doesModulePathIncludeSubstring(commandObjectModule,
                            "grails-app" + File.separator + "domain" + File.separator)) {
                        argumentIsValidateable = true;
                    }
                }
            }
           
            if (argumentIsValidateable) {
                final MethodCallExpression validateMethodCallExpression =
                        new MethodCallExpression(new VariableExpression(paramName), "validate", EMPTY_TUPLE);
                final MethodNode validateMethod =
                        commandObjectNode.getMethod("validate", new Parameter[0]);
                if (validateMethod != null) {
                    validateMethodCallExpression.setMethodTarget(validateMethod);
                }
                final Statement ifCommandObjectIsNotNullThenValidate = new IfStatement(new BooleanExpression(new VariableExpression(paramName)), new ExpressionStatement(validateMethodCallExpression), new ExpressionStatement(new EmptyExpression()));
                wrapper.addStatement(ifCommandObjectIsNotNullThenValidate);
            } else {
                // try to dynamically invoke the .validate() method if it is available at runtime...
                final Expression respondsToValidateMethodCallExpression = new MethodCallExpression(
                        new VariableExpression(paramName), "respondsTo", new ArgumentListExpression(
                                new ConstantExpression("validate")));
                final Expression validateMethodCallExpression = new MethodCallExpression(
                        new VariableExpression(paramName), "validate", new ArgumentListExpression());
                final Statement ifRespondsToValidateThenValidateStatement = new IfStatement(
                        new BooleanExpression(respondsToValidateMethodCallExpression),
                        new ExpressionStatement(validateMethodCallExpression),
                        new ExpressionStatement(new EmptyExpression()));
                final Statement ifCommandObjectIsNotNullThenValidate = new IfStatement(new BooleanExpression(new VariableExpression(paramName)), ifRespondsToValidateThenValidateStatement, new ExpressionStatement(new EmptyExpression()));
                wrapper.addStatement(ifCommandObjectIsNotNullThenValidate);
               
                final String warningMessage = "The [" + actionName + "] action accepts a parameter of type [" +
                        commandObjectNode.getName() +
                        "] which has not been marked with @Validateable.  Data binding will still be applied " +
View Full Code Here

Examples of org.codehaus.groovy.ast.expr.EmptyExpression

        final Token equalsToken = Token.newSymbol(Types.EQUALS, 0, 0);
        final VariableExpression convertedValueExpression = new VariableExpression(
                "___converted_" + methodParamName, new ClassNode(Object.class));
        final DeclarationExpression declareConvertedValueExpression = new DeclarationExpression(
                convertedValueExpression, equalsToken, new EmptyExpression());

        Statement declareVariableStatement = new ExpressionStatement(declareConvertedValueExpression);
        wrapper.addStatement(declareVariableStatement);

        final VariableExpression methodParamExpression = new VariableExpression(
                methodParamName, paramTypeClassNode);
        final DeclarationExpression declareParameterVariableStatement = new DeclarationExpression(
                methodParamExpression, equalsToken, new EmptyExpression());
        declareVariableStatement = new ExpressionStatement(declareParameterVariableStatement);
        wrapper.addStatement(declareVariableStatement);

        final Expression assignmentExpression = new BinaryExpression(
                convertedValueExpression, equalsToken,
                new TernaryExpression(containsKeyExpression, retrieveConvertedValueExpression, defaultValueExpression));
        wrapper.addStatement(new ExpressionStatement(assignmentExpression));
        Expression rejectValueMethodCallExpression = getRejectValueExpression(classNode, methodParamName);

        BlockStatement ifConvertedValueIsNullBlockStatement = new BlockStatement();
        ifConvertedValueIsNullBlockStatement.addStatement(
                new ExpressionStatement(rejectValueMethodCallExpression));
        ifConvertedValueIsNullBlockStatement.addStatement(
                new ExpressionStatement(new BinaryExpression(
                        methodParamExpression, equalsToken, defaultValueExpression)));

        final BooleanExpression isConvertedValueNullExpression = new BooleanExpression(new BinaryExpression(
                convertedValueExpression, Token.newSymbol(Types.COMPARE_EQUAL, 0, 0),
                new ConstantExpression(null)));
        final ExpressionStatement assignConvertedValueToParamStatement = new ExpressionStatement(
                new BinaryExpression(methodParamExpression, equalsToken, convertedValueExpression));
        final Statement ifStatement = new IfStatement(isConvertedValueNullExpression,
                ifConvertedValueIsNullBlockStatement,
                assignConvertedValueToParamStatement);

        wrapper.addStatement(new IfStatement(new BooleanExpression(containsKeyExpression),
                ifStatement, new ExpressionStatement(new EmptyExpression())));
    }
View Full Code Here

Examples of org.codehaus.groovy.ast.expr.EmptyExpression

                            new ConstructorCallExpression(new ClassNode(
                                    ValidationErrors.class),
                                    beanPropertyBindingResultConstructorArgs)));
            final Statement initErrorsIfNullStatement = new IfStatement(
                    new BooleanExpression(errorsIsNullExpression), newEvaluatorExpression,
                    new ExpressionStatement(new EmptyExpression()));
            initErrorsMethodCode.addStatement(initErrorsIfNullStatement);
            paramTypeClassNode.addMethod(new MethodNode(INIT_ERRORS_METHOD_NAME,
                    Modifier.PRIVATE, ClassHelper.VOID_TYPE,
                    GrailsArtefactClassInjector.ZERO_PARAMETERS, GrailsArtefactClassInjector.EMPTY_CLASS_ARRAY, initErrorsMethodCode));
        }
View Full Code Here

Examples of org.codehaus.groovy.ast.expr.EmptyExpression

    @Test
    public void testVisit_Contract() {
        try {
            ASTNode[] badInput = new ASTNode[]{
                    new ConstantExpression("sample"),
                    new EmptyExpression()
            };
            new SingletonASTTransformation().visit(badInput, null);
            Assert.fail("Contract Failure");
        } catch (Error e) {
            Assert.assertTrue("Bad error msg: " + e.getMessage(), e.getMessage().contains("ConstantExpression"));
View Full Code Here

Examples of org.codehaus.groovy.ast.expr.EmptyExpression

                // modelTypes = {
                //  List<String> items
                //  ...
                // }
                Map<String,ClassNode> modelTypes = extractModelTypesFromClosureExpression((ClosureExpression)right);
                Expression result = new EmptyExpression();
                result.setSourcePosition(bin);
                classNode.putNodeMetaData(MarkupTemplateEngine.MODELTYPES_ASTKEY, modelTypes);
                return result;
            }
        }
        return super.transform(bin);
View Full Code Here

Examples of org.exist.xquery.modules.ngram.query.EmptyExpression

        List<String> queryTokens = tokenizeQuery(query);

        LOG.trace("Tokenized query: " + queryTokens);

        if (queryTokens.isEmpty())
            return new EmptyExpression();

        List<WildcardedExpression> expressions = new ArrayList<WildcardedExpression>();

        if (queryTokens.get(0).equals("^")) {
            expressions.add(new StartAnchor());
            queryTokens.remove(0);
        }

        if (queryTokens.isEmpty())
            return new EmptyExpression();

        boolean endAnchorPresent = false;
        if (queryTokens.get(queryTokens.size() - 1).equals("$")) {
            endAnchorPresent = true;
            queryTokens.remove(queryTokens.size() - 1);
        }

        if (queryTokens.isEmpty())
            return new EmptyExpression();

        for (String token : queryTokens) {
            if (token.startsWith(".")) {
                Wildcard wildcard = null;
                if (token.length() == 1) {
View Full Code Here

Examples of org.mozilla.javascript.ast.EmptyExpression

    return new EmptyStatement();
  }

  @Override
  public AstNode emptyExpression() {
    return new EmptyExpression();
  }
View Full Code Here

Examples of org.mozilla.javascript.ast.EmptyExpression

  @Override
  public AstNode binary(BinaryOperator operator, Iterable<AstNode> operands) {
    // this is to deal with the COMMA operator who can have less than two operands
    if (Iterables.isEmpty(operands)) {
      return new EmptyExpression();
    }
    if (Iterables.size(operands) == 1) {
      return operands.iterator().next();
    }
    InfixExpression list = new InfixExpression();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.