Skip to content

Commit eaa0012

Browse files
committed
Merge pull request #1721 from Hosch250/InspectionBugs
Fix built-in event discovery
2 parents 88cb6c2 + ddc772d commit eaa0012

File tree

107 files changed

+62
-452
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+62
-452
lines changed

RetailCoder.VBE/API/DeclarationType.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System;
2-
using System.Runtime.InteropServices;
1+
using System.Runtime.InteropServices;
32

43
namespace Rubberduck.API
54
{

RetailCoder.VBE/App.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
using System.Runtime.InteropServices.ComTypes;
1919
using System.Threading.Tasks;
2020
using System.Windows.Forms;
21-
using Rubberduck.Common.Hotkeys;
2221

2322
namespace Rubberduck
2423
{

RetailCoder.VBE/Common/ClipboardWriter.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
31
using System.IO;
4-
using System.Linq;
5-
using System.Text;
6-
using System.Threading.Tasks;
72
using System.Windows;
83
using System.Windows.Media.Imaging;
94

RetailCoder.VBE/Common/DeclarationExtensions.cs

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -225,35 +225,25 @@ public static IEnumerable<Declaration> FindBuiltInEventHandlers(this IEnumerable
225225
var declarationList = declarations.ToList();
226226

227227
var handlerNames = declarationList.Where(declaration => declaration.IsBuiltIn && declaration.DeclarationType == DeclarationType.Event)
228-
.Select(e => e.ParentDeclaration.IdentifierName + "_" + e.IdentifierName);
228+
.SelectMany(e =>
229+
{
230+
var parentModuleSubtypes = ((ClassModuleDeclaration) e.ParentDeclaration).Subtypes;
231+
return parentModuleSubtypes.Any()
232+
? parentModuleSubtypes.Select(v => v.IdentifierName + "_" + e.IdentifierName)
233+
: new[] { e.ParentDeclaration.IdentifierName + "_" + e.IdentifierName };
234+
});
229235

230236
// class module built-in events
231237
var classModuleHandlers = declarationList.Where(item =>
232238
item.DeclarationType == DeclarationType.Procedure &&
233239
item.ParentDeclaration.DeclarationType == DeclarationType.ClassModule &&
234240
(item.IdentifierName == "Class_Initialize" || item.IdentifierName == "Class_Terminate"));
235241

236-
// user form built-in events
237-
var userFormHandlers = declarationList.Where(item =>
238-
item.DeclarationType == DeclarationType.Procedure &&
239-
item.ParentDeclaration.DeclarationType == DeclarationType.ClassModule &&
240-
item.QualifiedName.QualifiedModuleName.Component.Type == vbext_ComponentType.vbext_ct_MSForm &&
241-
new[]
242-
{
243-
"UserForm_Activate", "UserForm_AddControl", "UserForm_BeforeDragOver", "UserForm_BeforeDropOrPaste",
244-
"UserForm_Click", "UserForm_DblClick", "UserForm_Deactivate", "UserForm_Error",
245-
"UserForm_Initialize", "UserForm_KeyDown", "UserForm_KeyPress", "UserForm_KeyUp", "UserForm_Layout",
246-
"UserForm_MouseDown", "UserForm_MouseMove", "UserForm_MouseUp", "UserForm_QueryClose",
247-
"UserForm_RemoveControl", "UserForm_Resize", "UserForm_Scroll", "UserForm_Terminate",
248-
"UserForm_Zoom"
249-
}.Contains(item.IdentifierName));
250-
251242
var handlers = declarationList.Where(declaration => !declaration.IsBuiltIn
252243
&& declaration.DeclarationType == DeclarationType.Procedure
253244
&& handlerNames.Contains(declaration.IdentifierName)).ToList();
254245

255246
handlers.AddRange(classModuleHandlers);
256-
handlers.AddRange(userFormHandlers);
257247

258248
return handlers;
259249
}

RetailCoder.VBE/Common/ExportFormatter.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.IO;
4-
using System.Linq;
53
using System.Net;
64
using System.Text;
7-
using System.Threading.Tasks;
85
using System.Xml;
96

107
namespace Rubberduck.Common

RetailCoder.VBE/Common/Hotkeys/Hotkey.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Diagnostics;
43
using System.Windows.Forms;
54
using System.Windows.Input;
65
using Rubberduck.Common.WinAPI;

RetailCoder.VBE/Common/RubberduckHooks.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using System.Collections.Generic;
33
using System.ComponentModel;
4-
using System.Diagnostics;
54
using System.Linq;
65
using System.Runtime.InteropServices;
76
using System.Windows.Forms;

RetailCoder.VBE/Common/WinAPI/DeviceInfoHid.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
6-
7-
namespace Rubberduck.Common.WinAPI
1+
namespace Rubberduck.Common.WinAPI
82
{
93
public struct DeviceInfoHid
104
{

RetailCoder.VBE/Common/WinAPI/DeviceInfoMouse.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
6-
7-
namespace Rubberduck.Common.WinAPI
1+
namespace Rubberduck.Common.WinAPI
82
{
93
public struct DeviceInfoMouse
104
{

RetailCoder.VBE/Common/WinAPI/DeviceNotification.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
6-
7-
namespace Rubberduck.Common.WinAPI
1+
namespace Rubberduck.Common.WinAPI
82
{
93
enum DeviceNotification
104
{

0 commit comments

Comments
 (0)