From d58b27ee89a014aa294b25baffd53c7a96a64be3 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 30 Oct 2016 17:21:10 +0000 Subject: Extract inner type hoisting to separate step --- .../couscous/ast/sugar/TypeDeclarationBody.java | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'src/main/java/org/zwobble/couscous/ast/sugar') 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 instanceInitializers = ImmutableList.builder(); private ConstructorNode constructor = ConstructorNode.DEFAULT; private final ImmutableList.Builder methods = ImmutableList.builder(); + private final ImmutableList.Builder 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 staticConstructor; private final ConstructorNode constructor; private final List methods; + private final List innerTypes; public TypeDeclarationBody( List fields, - List staticConstructor, ConstructorNode constructor, - List methods) + List staticConstructor, + ConstructorNode constructor, + List methods, + List innerTypes + ) { this.fields = fields; this.staticConstructor = staticConstructor; this.constructor = constructor; this.methods = methods; + this.innerTypes = innerTypes; } public List getFields() { @@ -85,4 +97,8 @@ public class TypeDeclarationBody { public List getMethods() { return methods; } + + public List getInnerTypes() { + return innerTypes; + } } -- cgit v1.2.3