use of com.google.devtools.j2objc.ast.Type in project j2objc by google.
the class TreeConverter method convertCastExpression.
private static TreeNode convertCastExpression(org.eclipse.jdt.core.dom.CastExpression node) {
CastExpression newNode = new CastExpression();
convertExpression(node, newNode);
return newNode.setType((Type) convert(node.getType())).setExpression((Expression) convert(node.getExpression()));
}
use of com.google.devtools.j2objc.ast.Type in project j2objc by google.
the class TreeConverter method convertVariableExpression.
private VariableDeclarationExpression convertVariableExpression(JCTree.JCVariableDecl node) {
VarSymbol var = node.sym;
boolean isVarargs = (node.sym.flags() & Flags.VARARGS) > 0;
Type newType = convertType(var.asType(), getPosition(node), isVarargs);
VariableDeclarationFragment fragment = new VariableDeclarationFragment();
fragment.setVariableElement(var).setInitializer((Expression) convert(node.getInitializer()));
return new VariableDeclarationExpression().setType(newType).addFragment(fragment);
}
use of com.google.devtools.j2objc.ast.Type in project j2objc by google.
the class TreeConverter method convertSingleVariable.
private TreeNode convertSingleVariable(JCTree.JCVariableDecl node) {
VarSymbol var = node.sym;
SourcePosition pos = getPosition(node);
boolean isVarargs = (node.sym.flags() & Flags.VARARGS) > 0;
Type newType = convertType(var.asType(), pos, isVarargs);
return new SingleVariableDeclaration().setType(newType).setIsVarargs(isVarargs).setAnnotations(convertAnnotations(node.getModifiers())).setVariableElement(var).setInitializer((Expression) convert(node.getInitializer()));
}
use of com.google.devtools.j2objc.ast.Type in project j2objc by google.
the class TreeConverter method convertArrayType.
private TreeNode convertArrayType(JCTree.JCArrayTypeTree node) {
ArrayType newNode = new ArrayType();
Type componentType = (Type) Type.newType(node.getType().type);
return newNode.setComponentType(componentType).setTypeMirror(node.type);
}
use of com.google.devtools.j2objc.ast.Type in project j2objc by google.
the class OuterReferenceResolver method endVisit.
@Override
public void endVisit(CreationReference node) {
Type typeNode = node.getType();
TypeMirror creationType = typeNode.getTypeMirror();
if (TypeUtil.isArray(creationType)) {
// Nothing to capture for array creations.
return;
}
TypeElement lambdaType = node.getTypeElement();
pushType(lambdaType);
// This is kind of messy, but we use the Type child node as the key for capture scope to be
// transferred to the inner ClassInstanceCreation. The capture scope of the CreationReference
// node will be transferred to the ClassInstanceCreation that creates the lambda instance.
TypeElement creationElement = TypeUtil.asTypeElement(creationType);
whenNeedsOuterParam(creationElement, () -> {
TypeElement enclosingTypeElement = ElementUtil.getDeclaringClass(creationElement);
node.setCreationOuterArg(getOuterPathInherited(enclosingTypeElement));
});
if (ElementUtil.isLocal(creationElement)) {
onExitScope(creationElement, () -> {
addCaptureArgs(creationElement, node.getCreationCaptureArgs());
});
}
popType();
endVisitFunctionalExpression(node);
}
Aggregations