Skip to content

Commit

Permalink
Remove residual references to ReplaceReferencesRefactoringAction comp…
Browse files Browse the repository at this point in the history
…onents
  • Loading branch information
BZngr committed Oct 13, 2021
1 parent fb3abc8 commit e5198b1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ public class EncapsulateFieldUseBackingFieldRefactoringAction : CodeOnlyRefactor
private readonly ICodeOnlyRefactoringAction<ReplaceDeclarationIdentifierModel> _replaceDeclarationIdentifiers;
private readonly ICodeOnlyRefactoringAction<EncapsulateFieldInsertNewCodeModel> _encapsulateFieldInsertNewCodeRefactoringAction;
private readonly ICodeOnlyRefactoringAction<DeleteDeclarationsModel> _deleteDeclarationsRefactoringAction;
private readonly IReplacePrivateUDTMemberReferencesModelFactory _replaceUDTMemberReferencesModelFactory;
//private readonly INewContentAggregatorFactory _newContentAggregatorFactory;
private readonly INewContentAggregatorFactory _newContentAggregatorFactory;
private readonly IEncapsulateFieldReferenceReplacerFactory _encapsulateFieldReferenceReplacerFactory;

public EncapsulateFieldUseBackingFieldRefactoringAction(
Expand All @@ -32,7 +31,6 @@ public class EncapsulateFieldUseBackingFieldRefactoringAction : CodeOnlyRefactor
_replaceDeclarationIdentifiers = refactoringActionsProvider.ReplaceDeclarationIdentifiers;
_encapsulateFieldInsertNewCodeRefactoringAction = refactoringActionsProvider.EncapsulateFieldInsertNewCode;
_deleteDeclarationsRefactoringAction = refactoringActionsProvider.DeleteDeclarations;
//_replaceUDTMemberReferencesModelFactory = replaceUDTMemberReferencesModelFactory;
_newContentAggregatorFactory = newContentAggregatorFactory;
_encapsulateFieldReferenceReplacerFactory = encapsulateFieldReferenceReplacerFactory;
}
Expand Down Expand Up @@ -60,7 +58,9 @@ var publicFieldsDeclaredInListsToReDeclareAsPrivateBackingFields

private void ModifyFields(EncapsulateFieldUseBackingFieldModel model, List<IEncapsulateFieldCandidate> publicFieldsToRemove, IRewriteSession rewriteSession)
{
_deleteDeclarationsRefactoringAction.Refactor(new DeleteDeclarationsModel(publicFieldsToRemove.Select(f => f.Declaration)), rewriteSession);
var deletionsModel = new DeleteDeclarationsModel(publicFieldsToRemove.Select(f => f.Declaration));

_deleteDeclarationsRefactoringAction.Refactor(deletionsModel, rewriteSession);

var retainedFieldDeclarations = model.SelectedFieldCandidates
.Except(publicFieldsToRemove)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Rubberduck.Parsing.Rewriter;
using Rubberduck.Parsing.Symbols;
using Rubberduck.Refactorings.Common;
using System.Linq;
using Rubberduck.Refactorings.EncapsulateField;
using Rubberduck.Refactorings.EncapsulateFieldInsertNewCode;
Expand All @@ -12,8 +10,6 @@ namespace Rubberduck.Refactorings.EncapsulateFieldUseBackingUDTMember
public class EncapsulateFieldUseBackingUDTMemberRefactoringAction : CodeOnlyRefactoringActionBase<EncapsulateFieldUseBackingUDTMemberModel>
{
private readonly ICodeOnlyRefactoringAction<ModifyUserDefinedTypeModel> _modifyUDTRefactoringAction;
private readonly ICodeOnlyRefactoringAction<ReplacePrivateUDTMemberReferencesModel> _replacePrivateUDTMemberReferencesRefactoringAction;
private readonly ICodeOnlyRefactoringAction<ReplaceReferencesModel> _replaceReferencesRefactoringAction;
private readonly ICodeOnlyRefactoringAction<EncapsulateFieldInsertNewCodeModel> _encapsulateFieldInsertNewCodeRefactoringAction;
private readonly ICodeOnlyRefactoringAction<DeleteDeclarationsModel> _deleteDeclarationsRefactoringAction;
private readonly INewContentAggregatorFactory _newContentAggregatorFactory;
Expand All @@ -29,7 +25,6 @@ public class EncapsulateFieldUseBackingUDTMemberRefactoringAction : CodeOnlyRefa
_modifyUDTRefactoringAction = refactoringActionsProvider.ModifyUserDefinedType;
_encapsulateFieldInsertNewCodeRefactoringAction = refactoringActionsProvider.EncapsulateFieldInsertNewCode;
_deleteDeclarationsRefactoringAction = refactoringActionsProvider.DeleteDeclarations;
_replaceUDTMemberReferencesModelFactory = replaceUDTMemberReferencesModelFactory;
_encapsulateFieldReferenceReplacerFactory = encapsulateFieldReferenceReplacerFactory;
_newContentAggregatorFactory = newContentAggregatorFactory;
}
Expand All @@ -51,10 +46,9 @@ public override void Refactor(EncapsulateFieldUseBackingUDTMemberModel model, IR

private void ModifyFields(EncapsulateFieldUseBackingUDTMemberModel encapsulateFieldModel, IRewriteSession rewriteSession)
{
var rewriter = rewriteSession.CheckOutModuleRewriter(encapsulateFieldModel.QualifiedModuleName);
var deletionsModel = new DeleteDeclarationsModel(encapsulateFieldModel.SelectedFieldCandidates.Select(f => f.Declaration));

rewriter.RemoveVariables(encapsulateFieldModel.SelectedFieldCandidates.Select(f => f.Declaration)
.Cast<VariableDeclaration>());
_deleteDeclarationsRefactoringAction.Refactor(deletionsModel, rewriteSession);

if (encapsulateFieldModel.ObjectStateUDTField.IsExistingDeclaration)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,8 @@ private static void RegisterSingletonObjects(IWindsorContainer container)
container.Kernel.Register(Component.For<EncapsulateFieldRefactoringAction>());
container.Kernel.Register(Component.For<EncapsulateFieldUseBackingUDTMemberRefactoringAction>());
container.Kernel.Register(Component.For<EncapsulateFieldUseBackingFieldRefactoringAction>());
container.Kernel.Register(Component.For<ReplacePrivateUDTMemberReferencesRefactoringAction>());
container.Kernel.Register(Component.For<EncapsulateFieldInsertNewCodeRefactoringAction>());
container.Kernel.Register(Component.For<ModifyUserDefinedTypeRefactoringAction>());
container.Kernel.Register(Component.For<ReplaceReferencesRefactoringAction>());
container.Kernel.Register(Component.For<ReplaceDeclarationIdentifierRefactoringAction>());
container.Kernel.Register(Component.For<DeleteDeclarationsRefactoringAction>());
container.Kernel.Register(Component.For<DeleteModuleElementsRefactoringAction>());
Expand Down Expand Up @@ -150,11 +148,9 @@ private static void RegisterInterfaceToImplementationPairsSingleton(IWindsorCont
container.Register(Component.For<IEncapsulateFieldRefactoringActionsProvider>()
.ImplementedBy<EncapsulateFieldRefactoringActionsProvider>());

// container.Kernel.Register(Component.For<IReplacePrivateUDTMemberReferencesModelFactory>()
// .ImplementedBy<ReplacePrivateUDTMemberReferencesModelFactory>());
//
// container.Kernel.Register(Component.For<IDeclarationDeletionTargetFactory>()
// .ImplementedBy<DeclarationDeletionTargetFactory>());
container.Kernel.Register(Component.For<IDeclarationDeletionTargetFactory>()
.ImplementedBy<DeclarationDeletionTargetFactory>());

container.Register(Component.For<IEncapsulateFieldReferenceReplacerFactory>()
.ImplementedBy<EncapsulateFieldReferenceReplacerFactory>());
}
Expand Down

0 comments on commit e5198b1

Please sign in to comment.