Visit a ExpressionDef. This method will be called for
every node in the tree that is a ExpressionDef.

@param elm     the ELM tree
@param context the context passed to the visitor
@return the visitor result
161260
public T visitExpressionDef(ExpressionDef elm, C context) {
        visitElement(elm.getExpression(), context);
        return null;
    }
899201
public String getToViewId(FacesContext context) {

        if (toViewIdExpr == null) {
            ExpressionFactory factory =
                  context.getApplication().getExpressionFactory();
            toViewIdExpr = factory.createValueExpression(context.getELContext(),
                                                         toViewId,
                                                         String.class);
        }
        String result = (String) toViewIdExpr.getValue(context.getELContext());
        if (result.charAt(0) != '/') {
            result = '/' + result;
        }

        return result;

    }
361708
public Object eval(Node node, Context ctx) {
        Object evalResult = null;
        if(node instanceof AstRoot){
            Object ret = null;
            Iterator<Node> it = node.iterator();
            while(it.hasNext()){
                Node n = it.next();
                ret = eval(n, ctx);
            }
            evalResult = ret;
        }else if(node instanceof Block){
            //{...}
            Context ctx1 = ctx.createChild();
            Iterator<Node> it = node.iterator();
            while(it.hasNext()){
                Node n = it.next();
                eval(n,ctx1);
            }
        }else if(node instanceof DoLoop){
            //do while(...) ...;
            Context ctx1 = ctx.createChild();
            do{
                try{
                    eval(((DoLoop) node).getBody(), ctx);
                }catch (LoopContinueException e){

                }catch (LoopBreakException e){
                    break;
                }
            }while (condition(((DoLoop) node).getCondition(),ctx1));
        }else if(node instanceof WhileLoop){
            //while(...){...}
            Context ctx1 = ctx.createChild();
            while(condition(((WhileLoop) node).getCondition(),ctx1)){
                try{
                    eval(((WhileLoop) node).getBody(), ctx1);
                }catch (LoopContinueException e){

                }catch (LoopBreakException e){
                    break;
                }
            }
        }else if(node instanceof ForInLoop){
            //for(x in y){...}
            Context ctx1 = ctx.createChild();
            Object o = get(((ForInLoop) node).getIteratedObject(),ctx);
            if(o instanceof Map){
                for(String s:((Map<String,Object>) o).keySet()){
                    AstNode it = ((ForInLoop) node).getIterator();
                    if(it instanceof VariableDeclaration){
                        String name = ((Name)((VariableDeclaration) it).getVariables().get(0).getTarget()).getIdentifier();
                        ctx1.getVariables().put(name, s);
                    }
                    try{
                        eval(((ForInLoop) node).getBody(),ctx1);
                    }catch (LoopContinueException e){

                    }catch (LoopBreakException e){
                        break;
                    }
                }
            }else if(o instanceof List){
                for(double i=0.0D;i<((List<Object>) o).size();i++){
                    AstNode it = ((ForInLoop) node).getIterator();
                    if(it instanceof VariableDeclaration){
                        String name = ((Name)((VariableDeclaration) it).getVariables().get(0).getTarget()).getIdentifier();
                        ctx1.getVariables().put(name,i);
                    }
                    try{
                        eval(((ForInLoop) node).getBody(),ctx1);
                    }catch (LoopContinueException e){

                    }catch (LoopBreakException e){
                        break;
                    }
                }
            }
        }else if(node instanceof ForLoop){
            //for(...;...;...){...}
            Context ctx1 = ctx.createChild();
            for(eval(((ForLoop) node).getInitializer(),ctx1);
                condition(((ForLoop) node).getCondition(),ctx1);
                eval(((ForLoop) node).getIncrement(),ctx1)){
                try{
                    eval(((ForLoop) node).getBody(), ctx1);
                }catch (LoopContinueException e){

                }catch (LoopBreakException e){
                    break;
                }
            }
        }else if(node instanceof NewExpression){
            //new ...;

        }else if(node instanceof IfStatement){
            //if(...){...}
            boolean c = condition(((IfStatement) node).getCondition(),ctx);
            if(c){
                eval(((IfStatement) node).getThenPart(), ctx.createChild());
            }else{
                if(((IfStatement) node).getElsePart()!=null){
                    eval(((IfStatement) node).getElsePart(),ctx.createChild());
                }
            }
        }else if(node instanceof SwitchStatement){
            //switch(...)
            Object o = get(((SwitchStatement) node).getExpression(), ctx);
            for(SwitchCase sc:((SwitchStatement) node).getCases()){
                boolean b = false;
                if(sc.isDefault()){
                    b = true;
                }else{
                    Object o2 = get(sc.getExpression(),ctx);
                    if(Objects.equals(o,o2)){
                        b = true;
                    }
                }
                if(b){
                    try{
                        for(AstNode s: sc.getStatements()){
                            eval(s, ctx);
                        }
                    }catch (LoopContinueException e){
                    }catch (LoopBreakException e){
                        break;
                    }
                }
            }
        }else if(node instanceof WithStatement){
            //with(...){...}

        }else if(node instanceof VariableDeclaration){
            //var ...
            for(VariableInitializer vi:((VariableDeclaration) node).getVariables()){
                String name = ((Name)vi.getTarget()).getIdentifier();
                ctx.getVariables().put(name,get(vi.getInitializer(), ctx));
            }
        }else if(node instanceof TryStatement){
            //try{...}catch(..){...}finally{...}
            try{
                Context ctx1 = ctx.createChild();
                eval(((TryStatement) node).getTryBlock(),ctx1);
            }catch (ScriptException e){
                for(CatchClause cc:((TryStatement) node).getCatchClauses()){
                    Context ctx1 = ctx.createChild();
                    ctx1.getVariables().put(cc.getVarName().getIdentifier(),e.getData());
                    if(cc.getCatchCondition()==null || condition(cc.getCatchCondition(), ctx1)){
                        eval(cc.getBody(),ctx1);
                    }
                }
            }finally {
                eval(((TryStatement) node).getFinallyBlock(),ctx);
            }
        }else if(node instanceof ThrowStatement){
            //throw ...;
            throw new ScriptException(get(((ThrowStatement) node).getExpression(),ctx));
        }else if(node instanceof ReturnStatement){
            //return ...;
            throw new FunctionReturnException(get(((ReturnStatement) node).getReturnValue(),ctx));
        }else if(node instanceof BreakStatement){
            //break;
            throw new LoopBreakException();
        }else if(node instanceof ContinueStatement){
            //continue;
            throw new LoopContinueException();
        }else if(node instanceof Scope && !(node instanceof FunctionNode)){
            //{...}
            Context ctx1 = ctx.createChild();
            for(AstNode n:((Scope) node).getStatements()){
                eval(n,ctx1);
            }
        }else{
            evalResult = get((AstNode)node,ctx);
        }
        return evalResult;
    }
686949
@Override
    public void visit(NodeVisitor v) {
        if (v.visit(this)) {
            expression.visit(v);
            statement.visit(v);
        }
    }
114629
public T visitTupleElementDefinition(TupleElementDefinition elm, C context) {
        visitElement(elm.getType(), context);
        return null;
    }
643341
public Object evaluateExpression(String expression, EvaluationContext context) throws EvaluationError {
        return evaluateExpression(expression, context, EvaluationStrategy.COMPLETE);
    }
121897
@Nullable
    protected <T> T resolveExpression(String context, String expression, Class<T> type) {
        if (environment.containsProperty(expression)) {
            return environment.getProperty(expression, type)
                    .orElseThrow(() ->
                            new ConfigurationException("Could not resolve expression: [" + expression + "] in placeholder ${" + context + "}"));
        }
        if (NameUtils.isEnvironmentName(expression)) {
            String envVar = System.getenv(expression);
            if (StringUtils.isNotEmpty(envVar)) {
                return conversionService.convert(envVar, type)
                        .orElseThrow(() ->
                                new ConfigurationException("Could not resolve expression: [" + expression + "] in placeholder ${" + context + "}"));
            }
        }
        return null;
    }
650094
public T visitTuple(Tuple elm, C context) {
        for (TupleElement element : elm.getElement()) {
            visitTupleElement(element, context);
        }
        return null;
    }
1086405
public T visitOperandDef(OperandDef elm, C context) {
        if (elm.getOperandTypeSpecifier() != null) {
            visitElement(elm.getOperandTypeSpecifier(), context);
        }
        return null;
    }
1349370
public T visitUnaryExpression(UnaryExpression elm, C context) {
        if (elm instanceof Abs) return visitAbs((Abs)elm, context);
        else if (elm instanceof As) return visitAs((As)elm, context);
        else if (elm instanceof Ceiling) return visitCeiling((Ceiling)elm, context);
        else if (elm instanceof Convert) return visitConvert((Convert)elm, context);
        else if (elm instanceof DateFrom) return visitDateFrom((DateFrom)elm, context);
        else if (elm instanceof DateTimeComponentFrom) return visitDateTimeComponentFrom((DateTimeComponentFrom)elm, context);
        else if (elm instanceof Distinct) return visitDistinct((Distinct)elm, context);
        else if (elm instanceof End) return visitEnd((End)elm, context);
        else if (elm instanceof Exists) return visitExists((Exists)elm, context);
        else if (elm instanceof Exp) return visitExp((Exp)elm, context);
        else if (elm instanceof Flatten) return visitFlatten((Flatten)elm, context);
        else if (elm instanceof Floor) return visitFloor((Floor)elm, context);
        else if (elm instanceof Is) return visitIs((Is)elm, context);
        else if (elm instanceof IsFalse) return visitIsFalse((IsFalse)elm, context);
        else if (elm instanceof IsNull) return visitIsNull((IsNull)elm, context);
        else if (elm instanceof IsTrue) return visitIsTrue((IsTrue)elm, context);
        else if (elm instanceof Length) return visitLength((Length)elm, context);
        else if (elm instanceof Ln) return visitLn((Ln)elm, context);
        else if (elm instanceof Lower) return visitLower((Lower)elm, context);
        else if (elm instanceof Negate) return visitNegate((Negate)elm, context);
        else if (elm instanceof Not) return visitNot((Not)elm, context);
        else if (elm instanceof Predecessor) return visitPredecessor((Predecessor)elm, context);
        else if (elm instanceof SingletonFrom) return visitSingletonFrom((SingletonFrom)elm, context);
        else if (elm instanceof Start) return visitStart((Start)elm, context);
        else if (elm instanceof Successor) return visitSuccessor((Successor)elm, context);
        else if (elm instanceof TimeFrom) return visitTimeFrom((TimeFrom)elm, context);
        else if (elm instanceof TimezoneFrom) return visitTimezoneFrom((TimezoneFrom)elm, context);
        else if (elm instanceof ToBoolean) return visitToBoolean((ToBoolean)elm, context);
        else if (elm instanceof ToConcept) return visitToConcept((ToConcept)elm, context);
        else if (elm instanceof ToDateTime) return visitToDateTime((ToDateTime)elm, context);
        else if (elm instanceof ToDecimal) return visitToDecimal((ToDecimal)elm, context);
        else if (elm instanceof ToInteger) return visitToInteger((ToInteger)elm, context);
        else if (elm instanceof ToQuantity) return visitToQuantity((ToQuantity)elm, context);
        else if (elm instanceof ToString) return visitToString((ToString)elm, context);
        else if (elm instanceof ToTime) return visitToTime((ToTime)elm, context);
        else if (elm instanceof Truncate) return visitTruncate((Truncate)elm, context);
        else if (elm instanceof Upper) return visitUpper((Upper)elm, context);
        else if (elm instanceof Width) return visitWidth((Width)elm, context);
        else return null;
    }
553275
function create(context) {
    return {
        CallExpression(node) {
            if (isAmdDefine(node)) {
                context.report(node, message);
            }
        }
    };
}
919622
@Override
	public Element execute(Context context) {
		Element result = Undef.VALUE;
		for (Operation op : ops) {
			try {
				result = op.execute(context);
			} catch (EvaluationException ee) {
				throw ee.addExceptionInfo(sourceRange, context);
			}
		}
		return result;
	}
125497
@Override
    public Expression visitCreator(CreatorContext ctx) {
        ClassNode classNode = this.visitCreatedName(ctx.createdName());

        if (asBoolean(ctx.arguments())) { // create instance of class
            Expression arguments = this.visitArguments(ctx.arguments());
            Expression enclosingInstanceExpression = ctx.getNodeMetaData(ENCLOSING_INSTANCE_EXPRESSION);

            if (null != enclosingInstanceExpression) {
                if (arguments instanceof ArgumentListExpression) {
                    ((ArgumentListExpression) arguments).getExpressions().add(0, enclosingInstanceExpression);
                } else if (arguments instanceof TupleExpression) {
                    throw createParsingFailedException("Creating instance of non-static class does not support named parameters", arguments);
                } else if (arguments instanceof NamedArgumentListExpression) {
                    throw createParsingFailedException("Unexpected arguments", arguments);
                } else {
                    throw createParsingFailedException("Unsupported arguments", arguments); // should never reach here
                }
            }

            if (asBoolean(ctx.anonymousInnerClassDeclaration())) {
                ctx.anonymousInnerClassDeclaration().putNodeMetaData(ANONYMOUS_INNER_CLASS_SUPER_CLASS, classNode);
                InnerClassNode anonymousInnerClassNode = this.visitAnonymousInnerClassDeclaration(ctx.anonymousInnerClassDeclaration());

                List<InnerClassNode> anonymousInnerClassList = anonymousInnerClassesDefinedInMethodStack.peek();
                if (null != anonymousInnerClassList) { // if the anonymous class is created in a script, no anonymousInnerClassList is available.
                    anonymousInnerClassList.add(anonymousInnerClassNode);
                }

                ConstructorCallExpression constructorCallExpression = new ConstructorCallExpression(anonymousInnerClassNode, arguments);
                constructorCallExpression.setUsingAnonymousInnerClass(true);

                return configureAST(constructorCallExpression, ctx);
            }

            return configureAST(
                    new ConstructorCallExpression(classNode, arguments),
                    ctx);
        }

        if (asBoolean(ctx.LBRACK()) || asBoolean(ctx.dims())) { // create array
            ArrayExpression arrayExpression;
            List<List<AnnotationNode>> allDimList;

            if (asBoolean(ctx.arrayInitializer())) {
                ClassNode elementType = classNode;
                allDimList = this.visitDims(ctx.dims());

                for (int i = 0, n = allDimList.size() - 1; i < n; i++) {
                    elementType = elementType.makeArray();
                }

                arrayExpression =
                        new ArrayExpression(
                            elementType,
                            this.visitArrayInitializer(ctx.arrayInitializer()));

            } else {
                Expression[] empties;
                List<List<AnnotationNode>> emptyDimList = this.visitDimsOpt(ctx.dimsOpt());

                if (asBoolean(emptyDimList)) {
                    empties = new Expression[emptyDimList.size()];
                    Arrays.fill(empties, ConstantExpression.EMPTY_EXPRESSION);
                } else {
                    empties = Expression.EMPTY_ARRAY;
                }

                arrayExpression =
                        new ArrayExpression(
                                classNode,
                                null,
                                Stream.concat(
                                        ctx.expression().stream()
                                                .map(e -> (Expression) this.visit(e)),
                                        Arrays.stream(empties)
                                ).collect(Collectors.toList()));


                List<List<AnnotationNode>> exprDimList = ctx.annotationsOpt().stream().map(this::visitAnnotationsOpt).collect(Collectors.toList());
                allDimList = new ArrayList<>(exprDimList);
                Collections.reverse(emptyDimList);
                allDimList.addAll(emptyDimList);
                Collections.reverse(allDimList);
            }

            arrayExpression.setType(createArrayType(classNode, allDimList));

            return configureAST(arrayExpression, ctx);
        }

        throw createParsingFailedException("Unsupported creator: " + ctx.getText(), ctx);
    }
542375
public static List<?> evaluateAsList(final XPathExpression expression, final Node node, final Method method, final InvocationContext invocationContext) throws XPathExpressionException {
        //assert targetComponentType != null;
        final Class<?> targetComponentType = invocationContext.getTargetComponentType();
        final NodeList nodes = (NodeList) expression.evaluate(node, XPathConstants.NODESET);
        final List<Object> linkedList = new LinkedList<Object>();

        final TypeConverter typeConverter = invocationContext.getProjector().config().getTypeConverter();
        if (typeConverter.isConvertable(targetComponentType)) {
            for (int i = 0; i < nodes.getLength(); ++i) {
                linkedList.add(typeConverter.convertTo(targetComponentType, nodes.item(i).getTextContent(), invocationContext.getExpressionFormatPattern()));
            }
            return linkedList;
        }
        if (Node.class.equals(targetComponentType)) {
            for (int i = 0; i < nodes.getLength(); ++i) {
                linkedList.add(nodes.item(i));
            }
            return linkedList;
        }
        if (targetComponentType.isInterface()) {
            for (int i = 0; i < nodes.getLength(); ++i) {
                Object subprojection = invocationContext.getProjector().projectDOMNode(nodes.item(i), targetComponentType);
                linkedList.add(subprojection);
            }
            return linkedList;
        }
        throw new IllegalArgumentException("Return type " + targetComponentType + " is not valid for list or array component type returning from method " + method + " using the current type converter:" + invocationContext.getProjector().config().getTypeConverter()
                + ". Please change the return type to a sub projection or add a conversion to the type converter.");
    }
434241
@Override
    public Object visitContextReference(ExcellentParser.ContextReferenceContext ctx) {
        String identifier = ctx.NAME().getText();
        return m_evalContext.resolveVariable(identifier);
    }
345798
private static Object computeFragment(final ITemplateContext context, final String input) {

        final IStandardExpressionParser expressionParser = StandardExpressions.getExpressionParser(context.getConfiguration());

        final String trimmedInput = input.trim();

        if (shouldBeWrappedAsFragmentExpression(trimmedInput)) {
            // We do not know for sure that this is a complete standard expression, so we will consider it the
            // content of a FragmentExpression for legacy compatibility reasons.
            // We will only reach this point if the expression does not contain any Fragment Expressions expressed
            // as ~{...} (excluding parameters), nor the "::" fragment selector separator.
            // NOTE we are using the generic parseExpression() and not directly calling a parse method in the
            // FragmentExpression class because we want to take advantage of the expression cache.
            final FragmentExpression fragmentExpression =
                    (FragmentExpression) expressionParser.parseExpression(context, "~{" + trimmedInput + "}");

            final FragmentExpression.ExecutedFragmentExpression executedFragmentExpression =
                    FragmentExpression.createExecutedFragmentExpression(context, fragmentExpression);

            if (executedFragmentExpression.getFragmentSelectorExpressionResult() == null && executedFragmentExpression.getFragmentParameters() == null) {
                // We might be in the scenario that what we thought was a template name in fact was instead an expression
                // returning a Fragment itself, so we should simply return it
                final Object templateNameExpressionResult = executedFragmentExpression.getTemplateNameExpressionResult();
                if (templateNameExpressionResult != null) {
                    if (templateNameExpressionResult instanceof Fragment) {
                        return templateNameExpressionResult;
                    }
                    if (templateNameExpressionResult == NoOpToken.VALUE) {
                        return NoOpToken.VALUE;
                    }
                }
            }

            // Given this is a simple (originally unwrapped) fragment expression, we will consider the non-existence
            // of the fragment a failure. The reason we do this here instead of just waiting and seeing if we receive
            // a null and then failing is that, in order to receive such "null", the underlying resolution system would
            // have to execute a (potentially costly) resource.exists() call on the resolved resource.
            return FragmentExpression.resolveExecutedFragmentExpression(context, executedFragmentExpression, true);

        }

        // If we reached this point, we know for sure this is a complete fragment expression, so we just parse it
        // as such and execute it

        final IStandardExpression fragmentExpression = expressionParser.parseExpression(context, trimmedInput);

        final Object fragmentExpressionResult;

        if (fragmentExpression != null && fragmentExpression instanceof FragmentExpression) {
            // This is not a complex expression but merely a FragmentExpression, so we can apply a shortcut
            // so that we don't require a "null" result for this expression if the template does not exist. That will
            // save a call to resource.exists() which might be costly.

            final FragmentExpression.ExecutedFragmentExpression executedFragmentExpression =
                    FragmentExpression.createExecutedFragmentExpression(context, (FragmentExpression) fragmentExpression);

            fragmentExpressionResult =
                    FragmentExpression.resolveExecutedFragmentExpression(context, executedFragmentExpression, true);

        } else {

            fragmentExpressionResult = fragmentExpression.execute(context);

        }

        if (fragmentExpressionResult == null || fragmentExpressionResult == NoOpToken.VALUE) {
            return fragmentExpressionResult;
        }

        if (!(fragmentExpressionResult instanceof Fragment)) {
            throw new TemplateProcessingException(
                    "Invalid fragment specification: \"" + input + "\": " +
                    "expression does not return a Fragment object");
        }

        return fragmentExpressionResult;

    }
1188853
public T visitNaryExpression(NaryExpression elm, C context) {
        if (elm instanceof Coalesce) return visitCoalesce((Coalesce)elm, context);
        else if (elm instanceof Concatenate) return visitConcatenate((Concatenate)elm, context);
        else if (elm instanceof Except) return visitExcept((Except)elm, context);
        else if (elm instanceof Intersect) return visitIntersect((Intersect)elm, context);
        else if (elm instanceof Union) return visitUnion((Union)elm, context);
        else return null;
    }