use of org.mvel2.ast.LiteralDeepPropertyNode in project mvel by mvel.
the class AbstractParser method createPropertyToken.
/**
* Generate a property token
*
* @param st the start offset
* @param end the end offset
* @return an ast node
*/
private ASTNode createPropertyToken(int st, int end) {
String tmp;
if (isPropertyOnly(expr, st, end)) {
if (pCtx != null && pCtx.hasImports()) {
int find;
if ((find = findFirst('.', st, end - st, expr)) != -1) {
String iStr = new String(expr, st, find - st);
if (pCtx.hasImport(iStr)) {
lastWasIdentifier = true;
return lastNode = new LiteralDeepPropertyNode(expr, find + 1, end - find - 1, fields, pCtx.getImport(iStr), pCtx);
}
} else {
if (pCtx.hasImport(tmp = new String(expr, st, cursor - st))) {
lastWasIdentifier = true;
return lastNode = new LiteralNode(pCtx.getStaticOrClassImport(tmp), pCtx);
}
}
}
if (LITERALS.containsKey(tmp = new String(expr, st, end - st))) {
lastWasIdentifier = true;
return lastNode = new LiteralNode(LITERALS.get(tmp), pCtx);
} else if (OPERATORS.containsKey(tmp)) {
lastWasIdentifier = false;
return lastNode = new OperatorNode(OPERATORS.get(tmp), expr, st, pCtx);
} else if (lastWasIdentifier) {
return procTypedNode(true);
}
}
if (pCtx != null && isArrayType(expr, st, end)) {
if (pCtx.hasImport(new String(expr, st, cursor - st - 2))) {
lastWasIdentifier = true;
TypeDescriptor typeDescriptor = new TypeDescriptor(expr, st, cursor - st, fields);
try {
return lastNode = new LiteralNode(typeDescriptor.getClassReference(pCtx), pCtx);
} catch (ClassNotFoundException e) {
throw new CompileException("could not resolve class: " + typeDescriptor.getClassName(), expr, st);
}
}
}
lastWasIdentifier = true;
return lastNode = new ASTNode(expr, trimRight(st), trimLeft(end) - st, fields, pCtx);
}
Aggregations