Mutates expression
such that, if it contains a NameExpr for any of the <code>names</code>,
it is replaced with a FieldAccessExpr having <code>newScope</code> as the scope.
8519
public static void rescopeNamesToNewScope(Expression newScope, List<String> names, Expression e) {

        if (e instanceof NodeWithArguments) {
            NodeWithArguments<?> arguments = (NodeWithArguments) e;
            for (Expression argument : arguments.getArguments()) {
                rescopeNamesToNewScope(newScope, names, argument);
            }
        }

        if (e instanceof AssignExpr) {
            AssignExpr assignExpr = (AssignExpr) e;
            rescopeNamesToNewScope(newScope, names, assignExpr.getTarget());
            rescopeNamesToNewScope(newScope, names, assignExpr.getValue());
        } else if (e instanceof BinaryExpr) {
            rescopeNamesToNewScope(newScope, names, (( BinaryExpr ) e).getLeft());
            rescopeNamesToNewScope(newScope, names, (( BinaryExpr ) e).getRight());
        } else if (e instanceof UnaryExpr) {
            rescopeNamesToNewScope(newScope, names, (( UnaryExpr ) e).getExpression());
        } else if (e instanceof EnclosedExpr) {
            rescopeNamesToNewScope(newScope, names, (( EnclosedExpr ) e).getInner());
        } else {
            Optional<Expression> rootNode = DrlxParseUtil.findRootNodeViaScope(e);
            if (rootNode.isPresent() && rootNode.get() instanceof NameExpr) {
                NameExpr nameExpr = (NameExpr) rootNode.get();
                if (names.contains(nameExpr.getNameAsString())) {
                    Expression prepend = new FieldAccessExpr(newScope, nameExpr.getNameAsString());
                    if (e instanceof NameExpr) {
                        e.getParentNode().get().replace(nameExpr, prepend); // actually `e` was not composite, it was already the NameExpr node I was looking to replace.
                    } else {
                        e.replace(nameExpr, prepend);
                    }
                }
            }
        }
    }
430446
private void evaluateExpressions() throws JspException {
        /* 
         * Note: we don't check for type mismatches here; we assume
         * the expression evaluator will return the expected type
         * (by virtue of knowledge we give it about what that type is).
         * A ClassCastException here is truly unexpected, so we let it
         * propagate up.
         */

        url = (String) ExpressionUtil.evalNotNull(
                "import", "url", url_, String.class, this, pageContext);
        if (url == null || url.equals("")) {
            throw new NullAttributeException("import", "url");
        }

        context = (String) ExpressionUtil.evalNotNull(
                "import", "context", context_, String.class, this, pageContext);
        charEncoding = (String) ExpressionUtil.evalNotNull(
                "import", "charEncoding", charEncoding_, String.class, this,
                pageContext);
    }
442351
@Override
	public T visitAnonExpr(AnonExprContext ctx) {
//		on(ctx);
		appendAst(ctx, tok(ANONYMOUS_EXPRESSION));
		return super.visitAnonExpr(ctx);
	}
1056613
public boolean mutateAttachments(CollectionUtils.Functor<Map<String, Object>,
            Map<String, Object>> functor) {
        {
            Map<String, Object> properties = getProperties();
            Map<String, Object> editedProperties = null;
            Map<String, Object> attachments = (Map<String, Object>) properties.get("_attachments");
            Map<String, Object> editedAttachments = null;
            if (attachments != null) {
                for (String name : attachments.keySet()) {

                    Map<String, Object> attachment = new HashMap<String, Object>(
                            (Map<String, Object>) attachments.get(name));
                    attachment.put("name", name);
                    Map<String, Object> editedAttachment = functor.invoke(attachment);
                    if (editedAttachment == null) {
                        return false;  // block canceled
                    }
                    if (editedAttachment != attachment) {
                        if (editedProperties == null) {
                            // Make the document properties and _attachments dictionary mutable:
                            editedProperties = new HashMap<String, Object>(properties);
                            editedAttachments = new HashMap<String, Object>(attachments);
                            editedProperties.put("_attachments", editedAttachments);
                        }
                        editedAttachment.remove("name");
                        editedAttachments.put(name, editedAttachment);
                    }
                }
            }
            if (editedProperties != null) {
                setProperties(editedProperties);
                return true;
            }
            return false;
        }
    }
1042412
private Expression transformInlineConstants(Expression exp) {
        if (exp instanceof PropertyExpression) {
            PropertyExpression pe = (PropertyExpression) exp;
            if (pe.getObjectExpression() instanceof ClassExpression) {
                ClassExpression ce = (ClassExpression) pe.getObjectExpression();
                ClassNode type = ce.getType();
                if (type.isEnum())
                    return exp;

                FieldNode fn = type.getField(pe.getPropertyAsString());
                if (fn != null && !fn.isEnum() && fn.isStatic() && fn.isFinal()) {
                    if (fn.getInitialValueExpression() instanceof ConstantExpression) {
                        return fn.getInitialValueExpression();
                    }
                }
            }
        } else if (exp instanceof ListExpression) {
            ListExpression le = (ListExpression) exp;
            ListExpression result = new ListExpression();
            for (Expression e : le.getExpressions()) {
                result.addExpression(transformInlineConstants(e));
            }
            return result;
        } else if (exp instanceof AnnotationConstantExpression) {
            ConstantExpression ce = (ConstantExpression) exp;
            if (ce.getValue() instanceof AnnotationNode) {
                // replicate a little bit of AnnotationVisitor here
                // because we can't wait until later to do this
                AnnotationNode an = (AnnotationNode) ce.getValue();
                for (Map.Entry<String, Expression> member : an.getMembers().entrySet()) {
                    member.setValue(transformInlineConstants(member.getValue()));
                }

            }
        }
        return exp;
    }
888750
private static Matcher<CompoundAssignmentTree> variableFromCompoundAssignmentTree(
      final Matcher<ExpressionTree> exprMatcher) {
    return new Matcher<CompoundAssignmentTree>() {
      @Override
      public boolean matches(CompoundAssignmentTree tree, VisitorState state) {
        return exprMatcher.matches(tree.getVariable(), state);
      }
    };
  }
1001723
public String expand() throws VariableExpansionException
    {
        String template = getTemplate();
        for (Expression expression : expressions)
        {
            final String replacement = expressionReplacementString(expression, false);
            template = template.replaceAll(expression.getReplacementPattern(), replacement);
        }
        return template;
    }
639218
function scopeExpression(expression) {
	return expression.replace(expressionRE, (match, name) =>
		(
			name === undefined ||
			name[0] === "$" ||
			globals.indexOf(name) !== -1
		) ?
			match :
			"data." + name
	);
}
43006
@Generated("com.github.javaparser.generator.core.node.PropertyGenerator")
    public NullSafeFieldAccessExpr setTypeArguments(final NodeList<Type> typeArguments) {
        if (typeArguments == this.typeArguments) {
            return (NullSafeFieldAccessExpr) this;
        }
        notifyPropertyChange(ObservableProperty.TYPE_ARGUMENTS, this.typeArguments, typeArguments);
        if (this.typeArguments != null) {
            this.typeArguments.setParentNode(null);
        }
        this.typeArguments = typeArguments;
        setAsParentNodeOf(typeArguments);
        return this;
    }
1128696
final public ThenExpressionBuilder<T> ifExp() {
    return new ThenExpressionBuilder<T>(new ExpressionHandler<ThenBuilder<T>>() {
      public ThenBuilder<T> handleExpression(final Expression e) {
        return new ThenBuilder<T>(e, new IfStatementHandler<T>() {
          public T handleStatement(IfStatement ifStatement) {
            return statementHandler().handleStatement(ifStatement);
          }
        }, builder);
      }
    });
  }
934524
private PatternElement parseNamedElement(Node el, Map<String, Scope> scopes) {
        PatternElement namedElement;
        if (
                nodeAttribute(el, TAG_VAR_ATTR_PARSE, DEFAULT_PARSE_VALUE)
                        && !nodeHasAttribute(el, TAG_VAR_ATTR_REGEX)
                        && !nodeHasAttribute(el, TAG_VAR_ATTR_ACTION)
                ) {
            namedElement = parseText(el, scopes);
        } else {
            namedElement = parseVariable(el);
        }
        return namedElement;
    }
215352
private void evaluateExpressions() throws JspException {
        if (valueEL != null) {
            value = (Date) ExpressionEvaluatorManager.evaluate(
                    "value", valueEL, Date.class, this, pageContext);
        }

        if (typeEL != null) {
            type = (String) ExpressionEvaluatorManager.evaluate(
                    "type", typeEL, String.class, this, pageContext);
        }
    }
290419
private Text parseText(Node el, Map<String, Scope> scopes) {
        Text text;
        if (nodeAttribute(el, TAG_VAR_ATTR_INHERIT, DEFAULT_INHERIT_VALUE)) {
            text = new Text(
                    nodeAttribute(el, TAG_VAR_ATTR_NAME, Variable.DEFAULT_NAME),
                    null,
                    nodeAttribute(el, TAG_VAR_ATTR_TRANSPARENT, false)
            );
        } else {
            String scopeName = nodeAttribute(el, TAG_SCOPE, Scope.ROOT);
            Scope scope = scopes.get(scopeName);
            if (scope == null) {
                throw new TextProcessorFactoryException(
                        MessageFormat.format("Scope \"{0}\" not found.", scopeName)
                );
            }

            text = new Text(
                    nodeAttribute(el, TAG_VAR_ATTR_NAME, Variable.DEFAULT_NAME),
                    scope,
                    nodeAttribute(el, TAG_VAR_ATTR_TRANSPARENT, false)
            );
        }
        return text;
    }
838402
public static Matcher<EnhancedForLoopTree> enhancedForLoop(
      final Matcher<VariableTree> variableMatcher,
      final Matcher<ExpressionTree> expressionMatcher,
      final Matcher<StatementTree> statementMatcher) {
    return new Matcher<EnhancedForLoopTree>() {
      @Override
      public boolean matches(EnhancedForLoopTree t, VisitorState state) {
        return variableMatcher.matches(t.getVariable(), state)
            && expressionMatcher.matches(t.getExpression(), state)
            && statementMatcher.matches(t.getStatement(), state);
      }
    };
  }
1288870
@CheckReturnValue
  public Expression build(CodeChunk.Generator codeGenerator) {
    ImmutableList<IfThenPair<Expression>> pairs = conditions.build();
    Expression ternary = tryCreateTernary(pairs);
    if (ternary != null) {
      return ternary;
    }
    // Otherwise we need to introduce a temporary and assign to it in each branch
    VariableDeclaration decl = codeGenerator.declarationBuilder().build();
    Expression var = decl.ref();
    ConditionalBuilder builder = null;
    for (IfThenPair<Expression> oldCondition : pairs) {
      Expression newConsequent = var.assign(oldCondition.consequent);
      if (builder == null) {
        builder = ifStatement(oldCondition.predicate, newConsequent.asStatement());
      } else {
        builder.addElseIf(oldCondition.predicate, newConsequent.asStatement());
      }
    }
    if (trailingElse != null) {
      builder.setElse(var.assign(trailingElse).asStatement());
    }
    return var.withInitialStatements(ImmutableList.of(decl, builder.build()));
  }
618426
@SuppressWarnings("TreeToString") // Indented to ignore whitespace, comments, and source position.
  private static boolean isSameExpression(ExpressionTree leftTree, ExpressionTree rightTree) {
    // The left tree and right tree must have the same symbol resolution.
    // This ensures the symbol kind on field, parameter or local var.
    if (ASTHelpers.getSymbol(leftTree) != ASTHelpers.getSymbol(rightTree)) {
      return false;
    }

    String leftTreeTextRepr = stripPrefixIfPresent(leftTree.toString(), "this.");
    String rightTreeTextRepr = stripPrefixIfPresent(rightTree.toString(), "this.");
    return leftTreeTextRepr.contentEquals(rightTreeTextRepr);
  }
388154
public static XNodeSet executeFilterExpr(int context, XPathContext xctxt, 
  												PrefixResolver prefixResolver,
  												boolean isTopLevel,
  												int stackFrame,
  												Expression expr )
    throws org.apache.xml.utils.WrappedRuntimeException
  {
    PrefixResolver savedResolver = xctxt.getNamespaceContext();
    XNodeSet result = null;

    try
    {
      xctxt.pushCurrentNode(context);
      xctxt.setNamespaceContext(prefixResolver);

      // The setRoot operation can take place with a reset operation, 
      // and so we may not be in the context of LocPathIterator#nextNode, 
      // so we have to set up the variable context, execute the expression, 
      // and then restore the variable context.

      if (isTopLevel)
      {
        // System.out.println("calling m_expr.execute(getXPathContext())");
        VariableStack vars = xctxt.getVarStack();

        // These three statements need to be combined into one operation.
        int savedStart = vars.getStackFrame();
        vars.setStackFrame(stackFrame);

        result = (org.apache.xpath.objects.XNodeSet) expr.execute(xctxt);
        result.setShouldCacheNodes(true);

        // These two statements need to be combined into one operation.
        vars.setStackFrame(savedStart);
      }
      else
          result = (org.apache.xpath.objects.XNodeSet) expr.execute(xctxt);

    }
    catch (javax.xml.transform.TransformerException se)
    {

      // TODO: Fix...
      throw new org.apache.xml.utils.WrappedRuntimeException(se);
    }
    finally
    {
      xctxt.popCurrentNode();
      xctxt.setNamespaceContext(savedResolver);
    }
    return result;
  }