doExtendTraits(org.codehaus.groovy.ast.ClassNode, org.codehaus.groovy.control.SourceUnit, org.codehaus.groovy.control.CompilationUnit)
aimed at generating code for a classnode implementing a trait.
| Modifier and Type | Field and Description |
|---|---|
| public static final ClassNode |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private static void | applyTrait(final ClassNode trait, final ClassNode cNode, final TraitHelpersTuple helpers, SourceUnit unit)
|
| private static void | |
| private static ClassNode[] | |
| private static Statement | |
| private static SyntaxException | createException(ClassNode trait, ClassNode targetNode, MethodNode forwarder, MethodNode existingMethod)
|
| private static void | createForwarderMethod(ClassNode trait, ClassNode targetNode, MethodNode helperMethod, MethodNode originalMethod, ClassNode helperClassNode, Map<String, ClassNode> genericsSpec, Parameter[] helperMethodParams, Parameter[] traitMethodParams, Parameter[] forwarderParams, ArgumentListExpression helperMethodArgList, SourceUnit unit)
|
| private static Statement | |
| private static void | createSuperForwarder(ClassNode targetNode, MethodNode
a forwarder method forwarder, final Map<String, ClassNode> genericsSpec)Creates, if necessary, a super forwarder method, for stackable traits. |
| private static void | doCreateSuperForwarder(final ClassNode targetNode, final MethodNode forwarderMethod, final ClassNode[] interfacesToGenerateForwarderFor, final Map<String, ClassNode> genericsSpec)
Creates a method to dispatch to "super traits" in a "stackable" fashion. |
| public static void | doExtendTraits(final ClassNode
a class node cNode, final SourceUnit the source unit unit, final CompilationUnit cu)Given a class node, if this class node implements a trait, then generate all the appropriate code which delegates calls to the trait. |
| private static MethodNode | |
| private static MethodNode | |
| private static boolean | |
| private static GenericsType[] | |
| private static boolean |
| COMPILESTATIC_CLASSNODE | back to summary |
|---|---|
| public static final ClassNode COMPILESTATIC_CLASSNODE | |
| TraitComposer | back to summary |
|---|---|
| public TraitComposer() | |
| applyTrait | back to summary |
|---|---|
| private static void applyTrait(final ClassNode trait, final ClassNode cNode, final TraitHelpersTuple helpers, SourceUnit unit) | |
| checkTraitAllowed | back to summary |
|---|---|
| private static void checkTraitAllowed(final ClassNode bottomTrait, final SourceUnit unit) | |
| copyExceptions | back to summary |
|---|---|
| private static ClassNode[] copyExceptions(final ClassNode[] sourceExceptions) | |
| createDelegatingForwarder | back to summary |
|---|---|
| private static Statement createDelegatingForwarder(final MethodNode forwarderMethod, final ClassNode next) | |
| createException | back to summary |
|---|---|
| private static SyntaxException createException(ClassNode trait, ClassNode targetNode, MethodNode forwarder, MethodNode existingMethod) | |
| createForwarderMethod | back to summary |
|---|---|
| private static void createForwarderMethod(ClassNode trait, ClassNode targetNode, MethodNode helperMethod, MethodNode originalMethod, ClassNode helperClassNode, Map<String, ClassNode> genericsSpec, Parameter[] helperMethodParams, Parameter[] traitMethodParams, Parameter[] forwarderParams, ArgumentListExpression helperMethodArgList, SourceUnit unit) | |
| createSuperFallback | back to summary |
|---|---|
| private static Statement createSuperFallback(final MethodNode forwarderMethod, final ClassNode returnType) | |
| createSuperForwarder | back to summary |
|---|---|
| private static void createSuperForwarder(ClassNode targetNode, MethodNode forwarder, final Map<String, ClassNode> genericsSpec) Creates, if necessary, a super forwarder method, for stackable traits.
| |
| doCreateSuperForwarder | back to summary |
|---|---|
| private static void doCreateSuperForwarder(final ClassNode targetNode, final MethodNode forwarderMethod, final ClassNode[] interfacesToGenerateForwarderFor, final Map<String, ClassNode> genericsSpec) Creates a method to dispatch to "super traits" in a "stackable" fashion. The generated method looks like this: ReturnType trait$super$method(Class clazz, Arg1 arg1, Arg2 arg2, ...) {
if (SomeTrait.is(A) return SomeOtherTrait$Trait$Helper.method(this, arg1, arg2)
super.method(arg1,arg2)
}
| |
| doExtendTraits | back to summary |
|---|---|
| public static void doExtendTraits(final ClassNode cNode, final SourceUnit unit, final CompilationUnit cu) Given a class node, if this class node implements a trait, then generate all the appropriate code which delegates calls to the trait. It is safe to call this method on a class node which does not implement a trait.
| |
| findExistingMethod | back to summary |
|---|---|
| private static MethodNode findExistingMethod(final ClassNode cNode, final MethodNode forwarder) | |
| findExistingMethod | back to summary |
|---|---|
| private static MethodNode findExistingMethod(final ClassNode cNode, final String name, final Parameter[] params) | |
| isExistingProperty | back to summary |
|---|---|
| private static boolean isExistingProperty(final String methodName, final ClassNode cNode, final Parameter[] params) | |
| removeNonPlaceHolders | back to summary |
|---|---|
| private static GenericsType[] removeNonPlaceHolders(GenericsType[] oldTypes) | |
| shouldSkipMethod | back to summary |
|---|---|
| private static boolean shouldSkipMethod(final ClassNode cNode, final String name, final Parameter[] params) | |