Skip to content

Commit 352334c

Browse files
committed
Find interface with selection over the space in "Implements IXyz". Show error message on failure.
1 parent a800618 commit 352334c

File tree

4 files changed

+32
-3
lines changed

4 files changed

+32
-3
lines changed

RetailCoder.VBE/Common/DeclarationExtensions.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,10 +510,13 @@ public static Declaration FindInterface(this IEnumerable<Declaration> declaratio
510510

511511
if (implementsStmt == null) { continue; }
512512

513+
var completeSelection = new Selection(implementsStmt.GetSelection().StartLine,
514+
implementsStmt.GetSelection().StartColumn, reference.Selection.EndLine,
515+
reference.Selection.EndColumn);
516+
513517
if (reference.QualifiedModuleName.ComponentName == selection.QualifiedName.ComponentName &&
514518
reference.QualifiedModuleName.Project == selection.QualifiedName.Project &&
515-
(implementsStmt.GetSelection().Contains(selection.Selection) ||
516-
reference.Selection.Contains(selection.Selection)))
519+
completeSelection.Contains(selection.Selection))
517520
{
518521
return declaration;
519522
}

RetailCoder.VBE/Refactorings/ImplementInterface/ImplementInterfaceRefactoring.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public void Refactor()
3333

3434
if (!selection.HasValue)
3535
{
36-
_messageBox.Show("Invalid selection.", "Rubberduck - Implement Interface",
36+
_messageBox.Show(RubberduckUI.ImplementInterface_InvalidSelectionMessage, RubberduckUI.ImplementInterface_Caption,
3737
System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
3838
return;
3939
}
@@ -52,6 +52,8 @@ public void Refactor(QualifiedSelection selection)
5252

5353
if (_targetClass == null || _targetInterface == null)
5454
{
55+
_messageBox.Show(RubberduckUI.ImplementInterface_InvalidSelectionMessage, RubberduckUI.ImplementInterface_Caption,
56+
System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
5557
return;
5658
}
5759

RetailCoder.VBE/UI/RubberduckUI.Designer.cs

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

RetailCoder.VBE/UI/RubberduckUI.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,4 +1291,10 @@ Are you sure you want to proceed with this rename?</value>
12911291
<data name="RefactorMenu_ImplementInterface" xml:space="preserve">
12921292
<value>Implement Interface</value>
12931293
</data>
1294+
<data name="ImplementInterface_Caption" xml:space="preserve">
1295+
<value>Rubberduck - Implement Interface</value>
1296+
</data>
1297+
<data name="ImplementInterface_InvalidSelectionMessage" xml:space="preserve">
1298+
<value>The current selection is not valid.</value>
1299+
</data>
12941300
</root>

0 commit comments

Comments
 (0)