aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/zwobble/couscous/ast/sugar
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-10-30 17:21:10 +0000
committerMichael Williamson <mike@zwobble.org>2016-10-30 17:21:10 +0000
commitd58b27ee89a014aa294b25baffd53c7a96a64be3 (patch)
tree6dcd100dd36c54b481dd49d07fab76bd747dc851 /src/main/java/org/zwobble/couscous/ast/sugar
parentbefd7c344ba8a7c3402d4c678f1b81017fd65947 (diff)
Extract inner type hoisting to separate step
Diffstat (limited to 'src/main/java/org/zwobble/couscous/ast/sugar')
-rw-r--r--src/main/java/org/zwobble/couscous/ast/sugar/TypeDeclarationBody.java22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/main/java/org/zwobble/couscous/ast/sugar/TypeDeclarationBody.java b/src/main/java/org/zwobble/couscous/ast/sugar/TypeDeclarationBody.java
index 381c521..99b7c06 100644
--- a/src/main/java/org/zwobble/couscous/ast/sugar/TypeDeclarationBody.java
+++ b/src/main/java/org/zwobble/couscous/ast/sugar/TypeDeclarationBody.java
@@ -19,6 +19,7 @@ public class TypeDeclarationBody {
private final ImmutableList.Builder<StatementNode> instanceInitializers = ImmutableList.builder();
private ConstructorNode constructor = ConstructorNode.DEFAULT;
private final ImmutableList.Builder<MethodNode> methods = ImmutableList.builder();
+ private final ImmutableList.Builder<TypeNode> innerTypes = ImmutableList.builder();
private Builder() {
}
@@ -43,6 +44,10 @@ public class TypeDeclarationBody {
this.methods.add(method);
}
+ public void addInnerType(TypeNode typeDeclaration) {
+ this.innerTypes.add(typeDeclaration);
+ }
+
public TypeDeclarationBody build() {
return new TypeDeclarationBody(
fields.build(),
@@ -50,7 +55,9 @@ public class TypeDeclarationBody {
ConstructorNode.constructor(
constructor.getArguments(),
ExtraLists.concat(instanceInitializers.build(), constructor.getBody())),
- methods.build());
+ methods.build(),
+ innerTypes.build()
+ );
}
}
@@ -58,16 +65,21 @@ public class TypeDeclarationBody {
private final List<StatementNode> staticConstructor;
private final ConstructorNode constructor;
private final List<MethodNode> methods;
+ private final List<TypeNode> innerTypes;
public TypeDeclarationBody(
List<FieldDeclarationNode> fields,
- List<StatementNode> staticConstructor, ConstructorNode constructor,
- List<MethodNode> methods)
+ List<StatementNode> staticConstructor,
+ ConstructorNode constructor,
+ List<MethodNode> methods,
+ List<TypeNode> innerTypes
+ )
{
this.fields = fields;
this.staticConstructor = staticConstructor;
this.constructor = constructor;
this.methods = methods;
+ this.innerTypes = innerTypes;
}
public List<FieldDeclarationNode> getFields() {
@@ -85,4 +97,8 @@ public class TypeDeclarationBody {
public List<MethodNode> getMethods() {
return methods;
}
+
+ public List<TypeNode> getInnerTypes() {
+ return innerTypes;
+ }
}