MCPcopy Create free account
hub / github.com/apache/tomcat / visit

Method visit

java/org/apache/el/lang/ExpressionBuilder.java:181–221  ·  view source on GitHub ↗
(Node node)

Source from the content-addressed store, hash-verified

179 }
180
181 @Override
182 public void visit(Node node) throws ELException {
183 if (node instanceof AstFunction funcNode) {
184
185 Method m = null;
186
187 if (this.fnMapper != null) {
188 m = fnMapper.resolveFunction(funcNode.getPrefix(), funcNode.getLocalName());
189 }
190
191 // References to variables that refer to lambda expressions will be
192 // parsed as functions. This is handled at runtime but at this point
193 // need to treat it as a variable rather than a function.
194 if (m == null && this.varMapper != null && funcNode.getPrefix().isEmpty()) {
195 this.varMapper.resolveVariable(funcNode.getLocalName());
196 return;
197 }
198
199 if (this.fnMapper == null) {
200 throw new ELException(MessageFactory.get("error.fnMapper.null"));
201 }
202
203 if (m == null) {
204 throw new ELException(MessageFactory.get("error.fnMapper.method", funcNode.getOutputName()));
205 }
206
207 int methodParameterCount = m.getParameterTypes().length;
208 // AstFunction->MethodParameters->Parameters()
209 int inputParameterCount = node.jjtGetChild(0).jjtGetNumChildren();
210 if (m.isVarArgs() && inputParameterCount < methodParameterCount - 1 ||
211 !m.isVarArgs() && inputParameterCount != methodParameterCount) {
212 throw new ELException(MessageFactory.get("error.fnMapper.paramcount", funcNode.getOutputName(),
213 "" + methodParameterCount, "" + node.jjtGetChild(0).jjtGetNumChildren()));
214 }
215 } else if (node instanceof AstIdentifier && this.varMapper != null) {
216 String variable = node.getImage();
217
218 // simply capture it
219 this.varMapper.resolveVariable(variable);
220 }
221 }
222
223 /**
224 * Creates a ValueExpression from the parsed expression.

Callers

nothing calls this directly

Calls 12

getMethod · 0.95
getOutputNameMethod · 0.80
getLocalNameMethod · 0.65
jjtGetNumChildrenMethod · 0.65
jjtGetChildMethod · 0.65
getImageMethod · 0.65
resolveFunctionMethod · 0.45
getPrefixMethod · 0.45
isEmptyMethod · 0.45
resolveVariableMethod · 0.45
getParameterTypesMethod · 0.45
isVarArgsMethod · 0.45

Tested by

no test coverage detected