use of com.google.devtools.j2objc.ast.ExpressionMethodReference in project j2objc by google.
the class TreeConverter method convertExpressionMethodReference.
private static TreeNode convertExpressionMethodReference(org.eclipse.jdt.core.dom.ExpressionMethodReference node) {
IMethodBinding methodBinding = node.resolveMethodBinding();
ExpressionMethodReference newNode = new ExpressionMethodReference();
Expression expression = (Expression) convert(node.getExpression());
boolean consumesFirstParam = !BindingUtil.isStatic(methodBinding) && expression instanceof Name && !ElementUtil.isVariable(((Name) expression).getElement());
convertMethodReference(node, newNode, methodBinding, consumesFirstParam);
return newNode.setName((SimpleName) TreeConverter.convert(node.getName())).setExpression(expression);
}
use of com.google.devtools.j2objc.ast.ExpressionMethodReference in project j2objc by google.
the class TreeConverter method convertMemberReference.
private TreeNode convertMemberReference(JCTree.JCMemberReference node) {
Element element = node.sym;
SourcePosition pos = getPosition(node);
if (ElementUtil.isConstructor(element)) {
CreationReference newNode = new CreationReference();
convertMethodReference(node, newNode);
return newNode.setType(Type.newType(nameType(node.expr)));
}
if (node.hasKind(JCTree.JCMemberReference.ReferenceKind.SUPER)) {
SuperMethodReference newNode = new SuperMethodReference();
convertMethodReference(node, newNode);
if (node.getQualifierExpression().getKind() == Kind.IDENTIFIER) {
// super::foo
return newNode;
} else {
// Qualifier expression is <name>."super", so it's always a JCFieldAccess.
JCTree.JCFieldAccess expr = (JCTree.JCFieldAccess) node.getQualifierExpression();
return newNode.setQualifier(convertSimpleName(nameSymbol(expr.selected), expr.type, getPosition(expr.selected)));
}
}
if (node.hasKind(JCTree.JCMemberReference.ReferenceKind.UNBOUND) || node.hasKind(JCTree.JCMemberReference.ReferenceKind.STATIC)) {
TypeMethodReference newNode = new TypeMethodReference();
convertMethodReference(node, newNode);
return newNode.setName(convertSimpleName(node.sym, node.type, pos)).setType(convertType(node.type, pos, false));
}
ExpressionMethodReference newNode = new ExpressionMethodReference();
convertMethodReference(node, newNode);
return newNode.setName(convertSimpleName(node.sym, node.type, pos)).setExpression((Expression) convert(node.getQualifierExpression()));
}
Aggregations