use of com.github.javaparser.ast.expr.MethodCallExpr in project vue-gwt by Axellience.
the class TemplateParser method checkMethodNames.
/**
* Check the expression for component method calls.
* This will check that the methods used in the template exist in the Component.
* It throws an exception if we use a method that is not declared in our Component.
* This will not check for the type or number of parameters, we leave that to the Java Compiler.
* @param expression The expression to check
*/
private void checkMethodNames(Expression expression) {
if (expression instanceof MethodCallExpr) {
MethodCallExpr methodCall = ((MethodCallExpr) expression);
if (!methodCall.getScope().isPresent()) {
String methodName = methodCall.getName().getIdentifier();
if (!context.hasMethod(methodName) && !context.hasStaticMethod(methodName)) {
logger.error("Couldn't find the method \"" + methodName + "\". " + "Make sure it is not private.");
}
}
}
for (com.github.javaparser.ast.Node node : expression.getChildNodes()) {
if (!(node instanceof Expression))
continue;
Expression childExpr = (Expression) node;
checkMethodNames(childExpr);
}
}
use of com.github.javaparser.ast.expr.MethodCallExpr in project vue-gwt by Axellience.
the class TemplateParser method resolveStaticMethodsUsingImports.
/**
* Resolve static method calls using static imports
* @param expression The expression to resolve
*/
private void resolveStaticMethodsUsingImports(Expression expression) {
if (expression instanceof MethodCallExpr) {
MethodCallExpr methodCall = ((MethodCallExpr) expression);
String methodName = methodCall.getName().getIdentifier();
if (!methodCall.getScope().isPresent() && context.hasStaticMethod(methodName)) {
methodCall.setName(context.getFullyQualifiedNameForMethodName(methodName));
}
}
// Recurse downward in the expression
expression.getChildNodes().stream().filter(Expression.class::isInstance).map(Expression.class::cast).forEach(this::resolveStaticMethodsUsingImports);
}
Aggregations