private void InitializeModel(ReplacePrivateUDTMemberReferencesModel model, IEncapsulateFieldCandidate udtfield) { foreach (var udtMember in model.UDTMembers) { var udtExpressions = new PrivateUDTMemberReferenceReplacementExpressions($"{udtfield.IdentifierName}.{udtMember.IdentifierName}") { LocalReferenceExpression = udtMember.IdentifierName, }; model.AssignUDTMemberReferenceExpressions(udtfield.Declaration as VariableDeclaration, udtMember, udtExpressions); } }
private ReplacePrivateUDTMemberReferencesModel TestModel(RubberduckParserState state, bool moduleQualify = true, params PrivateUDTExpressions[] fieldConversions) { var fields = state.DeclarationFinder.UserDeclarations(DeclarationType.Variable) .Where(d => d.AsTypeDeclaration?.DeclarationType.HasFlag(DeclarationType.UserDefinedType) ?? false) .Select(v => v as VariableDeclaration); var factory = new ReplacePrivateUDTMemberReferencesModelFactory(state); var model = factory.Create(fields); foreach (var fieldConversion in fieldConversions) { var fieldDeclaration = fields.Single(f => f.IdentifierName == fieldConversion.FieldID); var udtMember = model.UDTMembers .Single(udtm => udtm.ParentDeclaration == fieldDeclaration.AsTypeDeclaration && udtm.IdentifierName == fieldConversion.UDTMemberID); var expressions = new PrivateUDTMemberReferenceReplacementExpressions(fieldConversion.InternalName); model.AssignUDTMemberReferenceExpressions(fieldDeclaration as VariableDeclaration, udtMember, expressions); } return(model); }