Skip to content

Commit c393c9f

Browse files
committed
final implementation of this version. Haven't implemented line lable moves
1 parent 27d5997 commit c393c9f

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

RetailCoder.VBE/UI/Command/Refactorings/RefactorExtractMethodCommand.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,20 @@ public override bool CanExecute(object parameter)
4343

4444
var code = Vbe.ActiveCodePane.CodeModule.Lines[selection.StartLine, selection.LineCount];
4545

46-
var parentProcedure = _state.AllDeclarations.FindSelectedDeclaration(qualifiedSelection.Value, DeclarationExtensions.ProcedureTypes, d => ((ParserRuleContext)d.Context.Parent).GetSelection());
46+
var allDeclarations = _state.AllDeclarations;
47+
var extractMethodValidation = new ExtractMethodSelectionValidation(allDeclarations);
48+
//var parentProcedure = _state.AllDeclarations.FindSelectedDeclaration(qualifiedSelection.Value, DeclarationExtensions.ProcedureTypes, d => ((ParserRuleContext)d.Context.Parent).GetSelection());
49+
var canExecute = extractMethodValidation.withinSingleProcedure(qualifiedSelection.Value);
50+
51+
52+
/*
4753
var canExecute = parentProcedure != null
4854
&& selection.StartColumn != selection.EndColumn
4955
&& selection.LineCount > 0
5056
&& !string.IsNullOrWhiteSpace(code);
57+
*/
5158

52-
Debug.WriteLine("{0}.CanExecute evaluates to {1}", GetType().Name, canExecute);
59+
Debug.Print("{0}.CanExecute evaluates to {1}", GetType().Name, canExecute);
5360
return canExecute;
5461
}
5562

RubberduckTests/Refactoring/ExtractMethod/ExtractedMethodRefactoringTests.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,12 @@ public void shouldCallTheExtraction()
104104
* - When the return value is a reference - the return assignment is Set initially implement with return values returned as ByRef */
105105

106106

107-
[TestClass]
108107
//[TestClass]
109108
public class when_local_variable_is_only_used_before_the_selection : ExtractMethodModelTests
110109
{
111110
/* When a local variable/constant is only used before the selection,
112111
* its declaration remains where it was */
113-
[TestMethod]
114-
112+
//[TestMethod]
115113
public void should_leave_declaration_in_source_method()
116114
{
117115
}
@@ -121,7 +119,7 @@ public class when_local_variable_is_only_used_after_the_selection : ExtractMetho
121119
{
122120
/* When a local variable/constant is only used after the selection,
123121
* its declaration remains where it was */
124-
[TestMethod]
122+
//[TestMethod]
125123
public void should_leave_declaration_in_source_method()
126124
{
127125

@@ -133,7 +131,7 @@ public class when_local_variable_is_used_before_and_within_the_selection : Extra
133131
{
134132
/* When a local variable is used before and within the selction,
135133
* it's considered an input */
136-
[TestMethod]
134+
//[TestMethod]
137135
public void should_be_passed_as_a_byref_parameter()
138136
{
139137
}
@@ -143,7 +141,7 @@ public class when_local_variable_is_used_after_and_within_the_selection : Extrac
143141
{
144142
/* When a local variable is used after and within the selection,
145143
* it's considered an output */
146-
[TestMethod]
144+
//[TestMethod]
147145
public void should_be_passed_as_a_byref_parameter()
148146
{
149147
}
@@ -154,6 +152,7 @@ public void should_be_passed_as_a_byref_parameter()
154152
//[TestClass]
155153
public class when_multiple_values_are_updated_within_selection : ExtractMethodModelTests
156154
{
155+
157156
public void should_add_byref_param_for_each()
158157
{
159158
}

0 commit comments

Comments
 (0)