Skip to content

Commit

Permalink
Adds lifecycle support to traits
Browse files Browse the repository at this point in the history
  • Loading branch information
gregghz committed Nov 27, 2017
1 parent 2c441cc commit 1c39fa8
Showing 1 changed file with 15 additions and 1 deletion.
Expand Up @@ -37,8 +37,22 @@ class LifecycleMacro(val c: Context) {
}
""" :: maybeCompanion

case q"""
$mods trait $tpname[..$tparams] extends { ..$earlydefns } with ..$parents { $self =>
..$members
}
""" :: maybeCompanion =>
val ActionValidationResult(membersWithExpandedActions, actions) = validateActions(members, parameters)
val ModifyLifecycleMethodsResult(finalMembers) = modifyLifecycleMethods(membersWithExpandedActions, actions)

q"""
$mods trait $tpname[..$tparams] extends { ..$earlydefns } with ..$parents { $self =>
..$finalMembers
}
""" :: maybeCompanion

case unchanged =>
c.error(c.enclosingPosition, "@LifecycleManaged must be used on a class")
c.error(c.enclosingPosition, "@LifecycleManaged must be used on a class or trait")
unchanged
}

Expand Down

0 comments on commit 1c39fa8

Please sign in to comment.