1- using System . Linq ;
2- using System . Runtime . InteropServices ;
31using Rubberduck . Parsing . VBA ;
42using Rubberduck . Refactorings . ExtractMethod ;
5- using Rubberduck . Refactorings ;
6- using Rubberduck . Settings ;
7- using Rubberduck . VBEditor . SafeComWrappers . Abstract ;
83using Rubberduck . UI . Command . Refactorings . Notifiers ;
94using Rubberduck . VBEditor . Utility ;
10- using Rubberduck . Parsing . Symbols ;
115
126namespace Rubberduck . UI . Command . Refactorings
137{
148 public class RefactorExtractMethodCommand : RefactorCodePaneCommandBase
159 {
1610 private readonly RubberduckParserState _state ;
17- private readonly IRefactoringFactory < ExtractMethodRefactoring > _refactoringFactory ;
18- private readonly IVBE _vbe ;
1911 private readonly ISelectedDeclarationProvider _selectedDeclarationProvider ;
2012 private readonly ISelectionProvider _selectionProvider ;
2113
@@ -36,7 +28,7 @@ public RefactorExtractMethodCommand(
3628 private bool SpecializedEvaluateCanExecute ( object parameter )
3729 {
3830 var member = _selectedDeclarationProvider . SelectedDeclaration ( ) ;
39- var moduleContext = _selectedDeclarationProvider . SelectedModule ( ) . Context ;
31+ // var moduleContext = _selectedDeclarationProvider.SelectedModule().Context;
4032 var moduleName = _selectedDeclarationProvider . SelectedModule ( ) . QualifiedModuleName ;
4133
4234 if ( member == null || _state . IsNewOrModified ( member . QualifiedModuleName ) || ! _selectionProvider . Selection ( moduleName ) . HasValue )
@@ -55,118 +47,5 @@ private bool SpecializedEvaluateCanExecute(object parameter)
5547 // ? parameters.Count > 2
5648 // : parameters.Count > 1;
5749 }
58-
59- //protected bool EvaluateCanExecute(object parameter)
60- //{
61- // if (_vbe.ActiveCodePane == null || _state.Status != ParserState.Ready)
62- // {
63- // return false;
64- // }
65-
66- // var pane = _vbe.ActiveCodePane;
67- // var module = pane.CodeModule;
68- // {
69- // var qualifiedSelection = pane.GetQualifiedSelection();
70- // if (!qualifiedSelection.HasValue || module.IsWrappingNullReference)
71- // {
72- // return false;
73- // }
74-
75- // var validator = new ExtractMethodSelectionValidation(_state.AllDeclarations, module);
76- // var canExecute = validator.ValidateSelection(qualifiedSelection.Value);
77-
78- // return canExecute;
79- // }
80- //}
81-
82- //protected override void OnExecute(object parameter)
83- //{
84- // var qualifiedSelection = _vbe.ActiveCodePane.GetQualifiedSelection();
85-
86- // if (qualifiedSelection == null)
87- // {
88- // return;
89- // }
90-
91- // var pane = _vbe.ActiveCodePane;
92- // if (pane == null)
93- // {
94- // return;
95- // }
96-
97- // var module = pane.CodeModule;
98- // var selection = module.GetQualifiedSelection();
99-
100- // if (selection == null)
101- // {
102- // return;
103- // }
104-
105- // var validator = new ExtractMethodSelectionValidation(_state.AllDeclarations, module);
106- // var canExecute = validator.ValidateSelection(qualifiedSelection.Value);
107-
108- // if (!canExecute)
109- // {
110- // return;
111- // }
112-
113- // /* TODO: Refactor the section to make command ignorant of data
114- // * This section needs to be refactored. The way it is, the command knows too much
115- // * about the validator and the refactoring. Getting data from validator should
116- // * be refactoring's responsibility, which implies the validation is refactoring's
117- // * responsiblity. Note where indicated.
118- // */
119-
120-
121- // var refactoring = _refactoringFactory.Create();
122- // refactoring.Validator = validator; //TODO: Refactor
123- // refactoring.Refactor(selection.Value);
124- // _refactoringFactory.Release(refactoring);
125-
126- // /*
127- // using (var view = new ExtractMethodDialog(new ExtractMethodViewModel()))
128- // {
129- // var factory = new ExtractMethodPresenterFactory(Vbe, view, _indenter, _state, qualifiedSelection.Value);
130- // var refactoring = new ExtractMethodRefactoring(Vbe, module, factory);
131- // refactoring.Refactor(qualifiedSelection.Value);
132- // }
133- // */
134-
135- // /*
136- // {
137- // Func<QualifiedSelection?, string, IExtractMethodModel> createMethodModel = (qs, code) =>
138- // {
139- // if (qs == null)
140- // {
141- // return null;
142- // }
143- // //TODO: Pull these even further back;
144- // // and implement with IProvider<IExtractMethodRule>
145- // var rules = new List<IExtractMethodRule>
146- // {
147- // new ExtractMethodRuleInSelection(),
148- // new ExtractMethodRuleIsAssignedInSelection(),
149- // new ExtractMethodRuleUsedAfter(),
150- // new ExtractMethodRuleUsedBefore()
151- // };
152-
153- // var paramClassify = new ExtractMethodParameterClassification(rules);
154-
155- // var extractedMethod = new ExtractedMethod();
156- // var extractedMethodModel = new ExtractMethodModel(extractedMethod, paramClassify);
157- // extractedMethodModel.extract(declarations, qs.Value, code);
158- // return extractedMethodModel;
159- // };
160-
161- // var extraction = new ExtractMethodExtraction();
162- // // bug: access to disposed closure - todo: make ExtractMethodRefactoring request reparse like everyone else.
163- // Action<object> parseRequest = obj => _state.OnParseRequested(obj);
164-
165- // var refactoring = new ExtractMethodRefactoring(module, parseRequest, createMethodModel, extraction);
166- // refactoring.InvalidSelection += HandleInvalidSelection;
167- // refactoring.Refactor();
168- // }
169- // */
170- //}
17150 }
17251}
0 commit comments