Skip to content

Commit

Permalink
Adds missing accept calls into children of new JSL8 nodes. Plus some …
Browse files Browse the repository at this point in the history
…formatting nits.

	Change on 2015/06/02 by kstanger <kstanger@google.com>
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=95002976
  • Loading branch information
kstanger authored and tomball committed Jun 9, 2015
1 parent 7ed44c0 commit b147deb
Show file tree
Hide file tree
Showing 11 changed files with 115 additions and 82 deletions.
10 changes: 10 additions & 0 deletions translator/Makefile
Expand Up @@ -54,6 +54,7 @@ JAVA_SOURCES = \
J2ObjC.java \
Options.java \
ast/AbstractTypeDeclaration.java \
ast/AnnotatableType.java \
ast/Annotation.java \
ast/AnnotationTypeDeclaration.java \
ast/AnnotationTypeMemberDeclaration.java \
Expand Down Expand Up @@ -82,13 +83,16 @@ JAVA_SOURCES = \
ast/ConditionalExpression.java \
ast/ConstructorInvocation.java \
ast/ContinueStatement.java \
ast/CreationReference.java \
ast/DebugASTPrinter.java \
ast/Dimension.java \
ast/DoStatement.java \
ast/EmptyStatement.java \
ast/EnhancedForStatement.java \
ast/EnumConstantDeclaration.java \
ast/EnumDeclaration.java \
ast/Expression.java \
ast/ExpressionMethodReference.java \
ast/ExpressionStatement.java \
ast/FieldAccess.java \
ast/FieldDeclaration.java \
Expand All @@ -99,14 +103,18 @@ JAVA_SOURCES = \
ast/InfixExpression.java \
ast/Initializer.java \
ast/InstanceofExpression.java \
ast/IntersectionType.java \
ast/Javadoc.java \
ast/LabeledStatement.java \
ast/LambdaExpression.java \
ast/LineComment.java \
ast/MarkerAnnotation.java \
ast/MemberValuePair.java \
ast/MethodDeclaration.java \
ast/MethodInvocation.java \
ast/MethodReference.java \
ast/Name.java \
ast/NameQualifiedType.java \
ast/NativeDeclaration.java \
ast/NativeExpression.java \
ast/NativeStatement.java \
Expand All @@ -131,6 +139,7 @@ JAVA_SOURCES = \
ast/SuperConstructorInvocation.java \
ast/SuperFieldAccess.java \
ast/SuperMethodInvocation.java \
ast/SuperMethodReference.java \
ast/SwitchCase.java \
ast/SwitchStatement.java \
ast/SynchronizedStatement.java \
Expand All @@ -147,6 +156,7 @@ JAVA_SOURCES = \
ast/TypeDeclaration.java \
ast/TypeDeclarationStatement.java \
ast/TypeLiteral.java \
ast/TypeMethodReference.java \
ast/UnionType.java \
ast/VariableDeclaration.java \
ast/VariableDeclarationExpression.java \
Expand Down
Expand Up @@ -24,12 +24,13 @@
// TODO(kirbs): Migrate Simple, Primitive, Qualified, and Wildcard Types to extend this
// type, as changed in JLS8.
public abstract class AnnotatableType extends Type {

protected ChildList<Annotation> annotations = ChildList.create(Annotation.class, this);

public AnnotatableType(org.eclipse.jdt.core.dom.AnnotatableType jdtNode) {
super(jdtNode);
typeBinding = jdtNode.resolveBinding();
for(Object x : jdtNode.annotations()){
for (Object x : jdtNode.annotations()){
annotations.add((Annotation) TreeConverter.convert(x));
}
}
Expand All @@ -51,4 +52,7 @@ public List<Annotation> annotations() {
public boolean isAnnotatable() {
return true;
}
}

@Override
public abstract AnnotatableType copy();
}
Expand Up @@ -17,6 +17,7 @@
* Creation reference expression AST node type (added in JLS8, section 15.13).
*/
public class CreationReference extends MethodReference {

private ChildLink<Type> type = ChildLink.create(Type.class, this);

public CreationReference(org.eclipse.jdt.core.dom.CreationReference jdtNode) {
Expand All @@ -29,23 +30,26 @@ public CreationReference(CreationReference other) {
type.set(other.getType());
}

public Type getType() {
return type.get();
}

@Override
public CreationReference copy() {
return new CreationReference(this);
}

@Override
public Kind getKind() {
return Kind.CREATION_REFERENCE;
}

public Type getType() {
return type.get();
}

@Override
protected void acceptInner(TreeVisitor visitor) {
visitor.visit(this);
if (visitor.visit(this)) {
type.accept(visitor);
typeArguments.accept(visitor);
}
visitor.endVisit(this);
}

@Override
public CreationReference copy() {
return new CreationReference(this);
}
}
Expand Up @@ -21,6 +21,7 @@
*/
// TODO(kirbs): Clean up ad-hoc dimension support that we had to implement previously.
public class Dimension extends TreeNode {

protected ChildList<Annotation> annotations = ChildList.create(Annotation.class, this);

public Dimension(org.eclipse.jdt.core.dom.Dimension jdtNode) {
Expand All @@ -37,18 +38,20 @@ public Dimension(Dimension other) {
annotations.copyFrom(other.annotations());
}

public List<Annotation> annotations() {
return annotations;
}

@Override
public Kind getKind() {
return Kind.DIMENSION;
}

public List<Annotation> annotations() {
return annotations;
}

@Override
protected void acceptInner(TreeVisitor visitor) {
visitor.visit(this);
if (visitor.visit(this)) {
annotations.accept(visitor);
}
visitor.endVisit(this);
}

Expand Down
Expand Up @@ -13,40 +13,31 @@
*/
package com.google.devtools.j2objc.ast;

import org.eclipse.jdt.core.dom.ITypeBinding;

/**
* Expression method reference node type (added in JLS8, section 15.13).
*/
public class ExpressionMethodReference extends MethodReference {
private final ITypeBinding typeBinding;

private ChildLink<Expression> expression = ChildLink.create(Expression.class, this);
private ChildLink<SimpleName> name = ChildLink.create(SimpleName.class, this);

public ExpressionMethodReference(org.eclipse.jdt.core.dom.ExpressionMethodReference jdtNode) {
super(jdtNode);
expression.set((Expression) TreeConverter.convert(jdtNode.getExpression()));
name.set((SimpleName) TreeConverter.convert(jdtNode.getName()));
typeBinding = jdtNode.resolveTypeBinding();
}

public ExpressionMethodReference(ExpressionMethodReference other) {
super(other);
expression.copyFrom(other.getExpression());
name.copyFrom(other.getName());
typeBinding = other.getTypeBinding();
}

@Override
public Kind getKind() {
return Kind.EXPRESSION_METHOD_REFERENCE;
}

@Override
public ITypeBinding getTypeBinding() {
return typeBinding;
}

public Expression getExpression() {
return expression.get();
}
Expand All @@ -67,6 +58,8 @@ public void setName(SimpleName newName) {
protected void acceptInner(TreeVisitor visitor) {
if (visitor.visit(this)) {
expression.accept(visitor);
typeArguments.accept(visitor);
name.accept(visitor);
}
visitor.endVisit(this);
}
Expand Down
Expand Up @@ -21,6 +21,7 @@
* Type node for an intersection type in a cast expression (added in JLS8, section 4.9).
*/
public class IntersectionType extends Type {

private ChildList<Type> types = ChildList.create(Type.class, this);

public IntersectionType(org.eclipse.jdt.core.dom.IntersectionType jdtNode) {
Expand All @@ -37,6 +38,11 @@ public IntersectionType(IntersectionType other) {
types.copyFrom(other.types);
}

@Override
public Kind getKind() {
return Kind.INTERSECTION_TYPE;
}

public List<Type> types() {
return types;
}
Expand All @@ -45,6 +51,15 @@ public boolean isIntersectionType() {
return true;
}

@Override
protected void acceptInner(TreeVisitor visitor) {
if (visitor.visit(this)) {
types.accept(visitor);
}
visitor.endVisit(this);
}

@Override
public IntersectionType copy() {
return new IntersectionType(this);
}
Expand All @@ -54,15 +69,4 @@ public void validateInner() {
super.validateInner();
Preconditions.checkNotNull(typeBinding);
}

@Override
public Kind getKind() {
return Kind.INTERSECTION_TYPE;
}

@Override
protected void acceptInner(TreeVisitor visitor) {
visitor.visit(this);
visitor.endVisit(this);
}
}
Expand Up @@ -18,10 +18,11 @@

import java.util.List;

/*
/**
* Lambda expression AST node type (added in JLS8, section 15.27).
*/
public class LambdaExpression extends Expression {

private final ITypeBinding typeBinding;
private final IMethodBinding methodBinding;
private ChildList<VariableDeclarationFragment> parameters = ChildList.create(
Expand Down Expand Up @@ -72,6 +73,7 @@ public TreeNode getBody() {
@Override
protected void acceptInner(TreeVisitor visitor) {
if (visitor.visit(this)) {
parameters.accept(visitor);
body.accept(visitor);
}
visitor.endVisit(this);
Expand Down
Expand Up @@ -30,6 +30,7 @@
* </pre>
*/
public abstract class MethodReference extends Expression {

protected ITypeBinding typeBinding;
protected ChildList<Type> typeArguments = ChildList.create(Type.class, this);

Expand All @@ -55,4 +56,7 @@ public ITypeBinding getTypeBinding() {
public List<Type> typeArguments() {
return typeArguments;
}

@Override
public abstract MethodReference copy();
}
Expand Up @@ -17,6 +17,7 @@
* Node for a name-qualified type (added in JLS8, section 6.5.5.2).
*/
public class NameQualifiedType extends AnnotatableType {

private ChildLink<SimpleName> name = ChildLink.create(SimpleName.class, this);
private ChildLink<Name> qualifier = ChildLink.create(Name.class, this);

Expand All @@ -32,6 +33,11 @@ public NameQualifiedType(NameQualifiedType other) {
qualifier.copyFrom(other.getQualifier());
}

@Override
public Kind getKind() {
return Kind.NAME_QUALIFIED_TYPE;
}

public SimpleName getName() {
return name.get();
}
Expand All @@ -41,18 +47,17 @@ public Name getQualifier() {
}

@Override
public Type copy() {
return new NameQualifiedType(this);
}

@Override
public Kind getKind() {
return Kind.NAME_QUALIFIED_TYPE;
protected void acceptInner(TreeVisitor visitor) {
if (visitor.visit(this)) {
name.accept(visitor);
annotations.accept(visitor);
qualifier.accept(visitor);
}
visitor.endVisit(this);
}

@Override
protected void acceptInner(TreeVisitor visitor) {
visitor.visit(this);
visitor.endVisit(this);
public NameQualifiedType copy() {
return new NameQualifiedType(this);
}
}
}

0 comments on commit b147deb

Please sign in to comment.