Skip to content

Commit 1d60053

Browse files
authored
Merge pull request #2078 from rubberduck-vba/next
Release 2.0.6
2 parents b54cbb2 + a4b38d0 commit 1d60053

File tree

168 files changed

+8464
-1525
lines changed

Some content is hidden

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

168 files changed

+8464
-1525
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Which basically means it's a reimplementation of Git in C. It also [happens to b
8585

8686
This library makes localizing WPF applications at runtime using resx files a breeze. Thank you [Grant Frisken](http://www.codeproject.com/script/Membership/View.aspx?mid=1079060)!
8787

88-
> Licensed under [The Code Project Open License](http://www.codeproject.com/info/cpol10.aspx).
88+
> Licensed under [The Code Project Open License](http://www.codeproject.com/info/cpol10.aspx) with the [author's permission](http://www.codeproject.com/Messages/5272045/Re-License.aspx) to re-release under the GPLv3.
8989
9090
###[Using Raw Input from C# to handle multiple keyboards](http://www.codeproject.com/Articles/17123/Using-Raw-Input-from-C-to-handle-multiple-keyboard)
9191

RetailCoder.VBE/Common/DeclarationExtensions.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,22 @@ public static IEnumerable<Declaration> FindEventHandlers(this IEnumerable<Declar
262262
&& declaration.IdentifierName.StartsWith(control.IdentifierName + "_"));
263263
}
264264

265+
public static IEnumerable<Declaration> FindUserEventHandlers(this IEnumerable<Declaration> declarations)
266+
{
267+
var declarationList = declarations.ToList();
268+
269+
var userEvents =
270+
declarationList.Where(item => !item.IsBuiltIn && item.DeclarationType == DeclarationType.Event).ToList();
271+
272+
var handlers = new List<Declaration>();
273+
foreach (var @event in userEvents)
274+
{
275+
handlers.AddRange(declarations.FindHandlersForEvent(@event).Select(s => s.Item2));
276+
}
277+
278+
return handlers;
279+
}
280+
265281
public static IEnumerable<Declaration> FindBuiltInEventHandlers(this IEnumerable<Declaration> declarations)
266282
{
267283
var declarationList = declarations.ToList();
@@ -451,6 +467,12 @@ public static IEnumerable<Declaration> FindInterfaceImplementationMembers(this I
451467
.Where(m => m.IdentifierName.EndsWith(interfaceMember));
452468
}
453469

470+
public static IEnumerable<Declaration> FindInterfaceImplementationMembers(this IEnumerable<Declaration> declarations, Declaration interfaceDeclaration)
471+
{
472+
return FindInterfaceImplementationMembers(declarations)
473+
.Where(m => m.IdentifierName == interfaceDeclaration.ComponentName + "_" + interfaceDeclaration.IdentifierName);
474+
}
475+
454476
public static Declaration FindInterfaceMember(this IEnumerable<Declaration> declarations, Declaration implementation)
455477
{
456478
var members = FindInterfaceMembers(declarations);

RetailCoder.VBE/Common/Hotkeys/HotkeyInfo.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Text;
33
using System.Windows.Forms;
4+
using Rubberduck.UI;
45

56
namespace Rubberduck.Common.Hotkeys
67
{
@@ -25,20 +26,21 @@ public override string ToString()
2526
var builder = new StringBuilder();
2627
if (_keys.HasFlag(Keys.Alt))
2728
{
28-
builder.Append(Rubberduck.UI.RubberduckUI.GeneralSettings_HotkeyAlt);
29+
builder.Append(RubberduckUI.GeneralSettings_HotkeyAlt);
2930
builder.Append('+');
3031
}
3132
if (_keys.HasFlag(Keys.Control))
3233
{
33-
builder.Append(Rubberduck.UI.RubberduckUI.GeneralSettings_HotkeyCtrl);
34+
builder.Append(RubberduckUI.GeneralSettings_HotkeyCtrl);
3435
builder.Append('+');
3536
}
3637
if (_keys.HasFlag(Keys.Shift))
3738
{
38-
builder.Append(Rubberduck.UI.RubberduckUI.GeneralSettings_HotkeyShift);
39+
builder.Append(RubberduckUI.GeneralSettings_HotkeyShift);
3940
builder.Append('+');
4041
}
41-
builder.Append(_keys & ~Modifiers);
42+
43+
builder.Append(HotkeyDisplayConverter.Convert(_keys & ~Modifiers));
4244
return builder.ToString();
4345
}
4446
}

RetailCoder.VBE/Common/RubberduckHooks.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,17 @@
55
using System.Linq;
66
using System.Runtime.InteropServices;
77
using System.Windows.Forms;
8-
using System.Windows.Input;
98
using Microsoft.Vbe.Interop;
109
using Rubberduck.Common.Hotkeys;
1110
using Rubberduck.Common.WinAPI;
1211
using Rubberduck.Settings;
1312
using Rubberduck.UI.Command;
14-
using Rubberduck.UI.Command.Refactorings;
1513
using NLog;
1614

1715
namespace Rubberduck.Common
1816
{
1917
public class RubberduckHooks : IRubberduckHooks
2018
{
21-
private readonly VBE _vbe;
2219
private readonly IntPtr _mainWindowHandle;
2320
private readonly IntPtr _oldWndPointer;
2421
private readonly User32.WndProc _oldWndProc;
@@ -33,7 +30,6 @@ public class RubberduckHooks : IRubberduckHooks
3330

3431
public RubberduckHooks(VBE vbe, IGeneralConfigService config, IEnumerable<CommandBase> commands)
3532
{
36-
_vbe = vbe;
3733
_mainWindowHandle = (IntPtr)vbe.MainWindow.HWnd;
3834
_oldWndProc = WindowProc;
3935
_newWndProc = WindowProc;
@@ -174,7 +170,7 @@ public void Detach()
174170
private void hook_MessageReceived(object sender, HookEventArgs e)
175171
{
176172
var hotkey = sender as IHotkey;
177-
if (hotkey != null)
173+
if (hotkey != null && hotkey.Command.CanExecute(null))
178174
{
179175
hotkey.Command.Execute(null);
180176
return;

RetailCoder.VBE/Common/WinAPI/RawInput.cs

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,41 @@ protected override void WndProc(ref Message message)
3939
switch ((WM)message.Msg)
4040
{
4141
case WM.INPUT:
42+
{
43+
if (message.LParam == IntPtr.Zero)
44+
{
45+
break;
46+
}
47+
InputData rawBuffer;
48+
var dwSize = 0;
49+
var res = User32.GetRawInputData(message.LParam, DataCommand.RID_INPUT, IntPtr.Zero, ref dwSize, Marshal.SizeOf(typeof(RawInputHeader)));
50+
if (res != 0)
51+
{
52+
var ex = new Win32Exception(Marshal.GetLastWin32Error());
53+
Logger.Error(ex, "Error sizing the rawinput buffer: {0}", ex.Message);
54+
break;
55+
}
56+
57+
res = User32.GetRawInputData(message.LParam, DataCommand.RID_INPUT, out rawBuffer, ref dwSize, Marshal.SizeOf(typeof(RawInputHeader)));
58+
if (res == -1)
59+
{
60+
var ex = new Win32Exception(Marshal.GetLastWin32Error());
61+
Logger.Error(ex, "Error getting the rawinput buffer: {0}", ex.Message);
62+
break;
63+
}
64+
if (res == dwSize)
4265
{
43-
InputData _rawBuffer;
44-
var dwSize = 0;
45-
User32.GetRawInputData(message.LParam, DataCommand.RID_INPUT, IntPtr.Zero, ref dwSize, Marshal.SizeOf(typeof(RawInputHeader)));
46-
int res = User32.GetRawInputData(message.LParam, DataCommand.RID_INPUT, out _rawBuffer, ref dwSize, Marshal.SizeOf(typeof(RawInputHeader)));
47-
if (dwSize != res)
48-
{
49-
var ex = new Win32Exception(Marshal.GetLastWin32Error());
50-
Logger.Error(ex, "Error getting the rawinput buffer: {0}", ex.Message);
51-
return;
52-
}
5366
foreach (var device in _devices)
5467
{
55-
device.ProcessRawInput(_rawBuffer);
68+
device.ProcessRawInput(rawBuffer);
5669
}
5770
}
58-
break;
71+
else
72+
{
73+
//Something is seriously f'd up with Windows - the number of bytes copied does not match the reported buffer size.
74+
}
75+
}
76+
break;
5977
}
6078
base.WndProc(ref message);
6179
}

RetailCoder.VBE/Inspections/AssignedByValParameterInspectionResult.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ public class AssignedByValParameterInspectionResult : InspectionResultBase
1313
public AssignedByValParameterInspectionResult(IInspection inspection, Declaration target)
1414
: base(inspection, target)
1515
{
16-
_quickFixes = new[]
16+
_quickFixes = new CodeInspectionQuickFix[]
1717
{
1818
new PassParameterByReferenceQuickFix(target.Context, QualifiedSelection),
19+
new IgnoreOnceQuickFix(Context, QualifiedSelection, inspection.AnnotationName)
1920
};
2021
}
2122

RetailCoder.VBE/Inspections/CodeInspectionQuickFix.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Antlr4.Runtime;
1+
using System.Windows.Threading;
2+
using Antlr4.Runtime;
23
using Rubberduck.VBEditor;
34

45
namespace Rubberduck.Inspections
@@ -11,6 +12,9 @@ public abstract class CodeInspectionQuickFix
1112

1213
public CodeInspectionQuickFix(ParserRuleContext context, QualifiedSelection selection, string description)
1314
{
15+
Dispatcher.CurrentDispatcher.Thread.CurrentCulture = UI.Settings.Settings.Culture;
16+
Dispatcher.CurrentDispatcher.Thread.CurrentUICulture = UI.Settings.Settings.Culture;
17+
1418
_context = context;
1519
_selection = selection;
1620
_description = description;

RetailCoder.VBE/Inspections/EmptyStringLiteralInspection.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ public override IEnumerable<InspectionResultBase> GetInspectionResults()
2626
{
2727
return new InspectionResultBase[] { };
2828
}
29-
return ParseTreeResults.EmptyStringLiterals.Select(
30-
context => new EmptyStringLiteralInspectionResult(this,
29+
return ParseTreeResults.EmptyStringLiterals
30+
.Where(s => !IsInspectionDisabled(s.ModuleName.Component, s.Context.Start.Line))
31+
.Select(context => new EmptyStringLiteralInspectionResult(this,
3132
new QualifiedContext<ParserRuleContext>(context.ModuleName, context.Context)));
3233
}
3334

RetailCoder.VBE/Inspections/EmptyStringLiteralInspectionResult.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ public class EmptyStringLiteralInspectionResult : InspectionResultBase
1313
public EmptyStringLiteralInspectionResult(IInspection inspection, QualifiedContext<ParserRuleContext> qualifiedContext)
1414
: base(inspection, qualifiedContext.ModuleName, qualifiedContext.Context)
1515
{
16-
_quickFixes = new[]
16+
_quickFixes = new CodeInspectionQuickFix[]
1717
{
18-
new RepaceEmptyStringLiteralStatementQuickFix(Context, QualifiedSelection),
18+
new RepaceEmptyStringLiteralStatementQuickFix(Context, QualifiedSelection),
19+
new IgnoreOnceQuickFix(Context, QualifiedSelection, Inspection.AnnotationName)
1920
};
2021
}
2122

RetailCoder.VBE/Inspections/EncapsulatePublicFieldInspectionResult.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ public class EncapsulatePublicFieldInspectionResult : InspectionResultBase
1616
public EncapsulatePublicFieldInspectionResult(IInspection inspection, Declaration target, RubberduckParserState state)
1717
: base(inspection, target)
1818
{
19-
_quickFixes = new[]
19+
_quickFixes = new CodeInspectionQuickFix[]
2020
{
2121
new EncapsulateFieldQuickFix(target.Context, target.QualifiedSelection, target, state),
22+
new IgnoreOnceQuickFix(Context, QualifiedSelection, Inspection.AnnotationName)
2223
};
2324
}
2425

0 commit comments

Comments
 (0)