public static void doExtendTraits ( final ClassNode cNode , final SourceUnit unit , final CompilationUnit cu ) { if ( cNode . isInterface ( ) ) return ; boolean isItselfTrait = Traits . isTrait ( cNode ) ; SuperCallTraitTransformer superCallTransformer = new SuperCallTraitTransformer ( unit ) ; if ( isItselfTrait ) { checkTraitAllowed ( cNode , unit ) ; return ; } if ( ! cNode . getNameWithoutPackage ( ) . endsWith ( Traits . TRAIT_HELPER ) ) { List < ClassNode > traits = findTraits ( cNode ) ; for ( ClassNode trait : traits ) { TraitHelpersTuple helpers = Traits . findHelpers ( trait ) ; applyTrait ( trait , cNode , helpers ) ; superCallTransformer . visitClass ( cNode ) ; if ( unit != null ) { ASTTransformationCollectorCodeVisitor collector = new ASTTransformationCollectorCodeVisitor ( unit , cu . getTransformLoader ( ) ) ; collector . visitClass ( cNode ) ; } } } }
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 .