Skip to content

Commit 192367b

Browse files
committed
Modify CanExecute to ignore existing Implements statements
1 parent 7cb246b commit 192367b

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

Rubberduck.Refactorings/ExtractInterface/ExtractInterfaceRefactoring.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,8 @@ public bool CanExecute(RubberduckParserState state, QualifiedModuleName qualifie
106106
return false;
107107
}
108108

109-
var parseTree = state.GetParseTree(interfaceClass.QualifiedName.QualifiedModuleName);
110-
var context = ((Antlr4.Runtime.ParserRuleContext)parseTree).GetDescendents<VBAParser.ImplementsStmtContext>();
111-
112109
// true if active code pane is for a class/document/form module
113-
return !context.Any()
114-
&& !state.IsNewOrModified(interfaceClass.QualifiedModuleName)
110+
return !state.IsNewOrModified(interfaceClass.QualifiedModuleName)
115111
&& !state.IsNewOrModified(qualifiedName);
116112
}
117113
}

RubberduckTests/Commands/RefactorCommands/ExtractInterfaceCommandTests.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,22 @@ public void ExtractInterface_CanExecute_PropertySet()
172172
Assert.IsTrue(CanExecute(input));
173173
}
174174

175+
//https://github.com/rubberduck-vba/Rubberduck/issues/5693
176+
[Test]
177+
[Category("Commands")]
178+
[Category("Extract Interface")]
179+
public void ExtractInterface_CanExecute_ExistingImplements()
180+
{
181+
var input =
182+
@"
183+
Implements ITest
184+
185+
Property Set Foo(value)
186+
End Property";
187+
188+
Assert.IsTrue(CanExecute(input));
189+
}
190+
175191
private bool CanExecute(string inputCode, ComponentType componentType = ComponentType.ClassModule)
176192
{
177193
return CanExecute(inputCode, Selection.Home, componentType);

0 commit comments

Comments
 (0)