use of com.sun.source.util.TreePath in project j2objc by google.
the class TreeConverter method convertAssignment.
private TreeNode convertAssignment(AssignmentTree node, TreePath parent) {
TreePath path = getTreePath(parent, node);
Assignment newNode = new Assignment();
return newNode.setOperator(Assignment.Operator.ASSIGN).setLeftHandSide((Expression) convert(node.getVariable(), path)).setRightHandSide((Expression) convert(node.getExpression(), path));
}
use of com.sun.source.util.TreePath in project j2objc by google.
the class TreeConverter method convertArrayType.
private TreeNode convertArrayType(ArrayTypeTree node, TreePath parent) {
TreePath path = getTreePath(parent, node);
ArrayType newNode = new ArrayType();
Type componentType = Type.newType(getTypeMirror(getTreePath(path, node.getType())));
return newNode.setComponentType(componentType).setTypeMirror(getTypeMirror(path));
}
use of com.sun.source.util.TreePath in project j2objc by google.
the class TreeConverter method convertAnnotationTypeDeclaration.
private TreeNode convertAnnotationTypeDeclaration(ClassTree node, TreePath parent) {
AnnotationTypeDeclaration newNode = new AnnotationTypeDeclaration();
TreePath path = getTreePath(parent, node);
Element element = getElement(path);
convertBodyDeclaration(node, path, node.getModifiers(), newNode);
for (Tree bodyDecl : node.getMembers()) {
if (bodyDecl.getKind() == Kind.METHOD) {
MethodTree methodTree = (MethodTree) bodyDecl;
TreePath methodPath = getTreePath(path, methodTree);
ExecutableElement methodElement = (ExecutableElement) getElement(methodPath);
Tree defaultValue = methodTree.getDefaultValue();
ModifiersTree modifiers = methodTree.getModifiers();
AnnotationTypeMemberDeclaration newMember = new AnnotationTypeMemberDeclaration().setDefault((Expression) convert(defaultValue, methodPath)).setExecutableElement(methodElement);
newMember.setModifiers((int) ((JCModifiers) modifiers).flags).setAnnotations(convertAnnotations(modifiers, getTreePath(methodPath, modifiers))).setJavadoc((Javadoc) getAssociatedJavaDoc(methodTree, methodPath));
newNode.addBodyDeclaration(newMember);
} else {
newNode.addBodyDeclaration((BodyDeclaration) convert(bodyDecl, path));
}
}
return newNode.setName(convertSimpleName(element, getTypeMirror(path), getNamePosition(node))).setTypeElement((TypeElement) element);
}
use of com.sun.source.util.TreePath in project j2objc by google.
the class TreeConverter method convertClassDeclarationHelper.
private TypeDeclaration convertClassDeclarationHelper(ClassTree node, TreePath parent) {
TreePath path = getTreePath(parent, node);
TypeDeclaration newNode = new TypeDeclaration();
TypeElement element = (TypeElement) getElement(path);
convertBodyDeclaration(node, parent, node.getModifiers(), newNode);
List<BodyDeclaration> bodyDeclarations = newNode.getBodyDeclarations();
for (Tree bodyDecl : node.getMembers()) {
Object member = convert(bodyDecl, path);
if (member instanceof BodyDeclaration) {
// Not true for enum constants.
bodyDeclarations.add((BodyDeclaration) member);
} else if (member instanceof Block) {
BlockTree javacBlock = (BlockTree) bodyDecl;
Block block = (Block) member;
bodyDeclarations.add(new Initializer(block, javacBlock.isStatic()));
}
}
newNode.setName(convertSimpleName(element, getTypeMirror(path), getNamePosition(node)));
newNode.setTypeElement(element);
return newNode;
}
use of com.sun.source.util.TreePath in project j2objc by google.
the class TreeConverter method convertNewClass.
private TreeNode convertNewClass(NewClassTree node, TreePath parent) {
TreePath path = getTreePath(parent, node);
ClassInstanceCreation newNode = new ClassInstanceCreation();
Expression enclosingExpression = (Expression) convert(node.getEnclosingExpression(), path);
ExecutableElement executable = (ExecutableElement) getElement(path);
TypeMirror vargarsType = ((JCNewClass) node).varargsElement;
// map to zero arguments.
if (executable.getParameters().size() - node.getArguments().size() == 1 && vargarsType == null) {
newNode.addArgument(enclosingExpression);
enclosingExpression = null;
}
for (ExpressionTree arg : node.getArguments()) {
newNode.addArgument((Expression) convert(arg, path));
}
return newNode.setExecutablePair(new ExecutablePair(executable)).setVarargsType(vargarsType).setExpression(enclosingExpression).setType(convertType(getTypeMirror(getTreePath(path, node.getIdentifier())))).setAnonymousClassDeclaration((TypeDeclaration) convert(node.getClassBody(), path));
}
Aggregations