protected override ClassDeclarationSyntax InternalExecute(
ClassWithSourceCode childClass,
SemanticModel semantic,
Settings settings = null)
{
// create a field declaration and add it to the child class
// check the following cases:
// 1. if mixin type is a concrete type that has a parameterless constructor
// if injection setting is not set => init field with new instance of type
// 2. if mixin is interface or does not have a parameterless constructor
// do nothing
var positionOfClassInSourceFile = childClass.SourceCode.GetLocation().SourceSpan.Start;
var typeSyntax = ParseTypeName(
_mixin.Class.TypeSymbol.ReduceQualifiedTypeName(semantic,positionOfClassInSourceFile));
var newFieldDeclaration =
FieldDeclaration(
VariableDeclaration(typeSyntax)
.WithVariables(
SingletonSeparatedList(
VariableDeclarator(_mixin.Name))))
.WithModifiers(TokenList(Token(SyntaxKind.PrivateKeyword)));
var newClassDeclaration = childClass.SourceCode.AddMembers(newFieldDeclaration);
return newClassDeclaration;
}
}