Skip to content

Commit 4288c28

Browse files
authored
Merge pull request #217 from rubberduck-vba/next
sync with main repo
2 parents b74e62b + 0f5f5e1 commit 4288c28

File tree

167 files changed

+3693
-2356
lines changed

Some content is hidden

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

167 files changed

+3693
-2356
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ LibGit2Sharp is the library that has allowed us to integrate Git right into the
8181
8282
Which basically means it's a reimplementation of Git in C. It also [happens to be the technology Microsoft uses for their own Git integration with Visual Studio](http://www.hanselman.com/blog/GitSupportForVisualStudioGitTFSAndVSPutIntoContext.aspx).
8383

84+
###[AvalonEdit](http://avalonedit.net)
85+
86+
Source code looks a lot better with syntax highlighting, and AvalonEdit excels at it.
87+
88+
> AvalonEdit is a WPF-based text editor component. It was written by [Daniel Grunwald](https://github.com/dgrunwald) for the [SharpDevelop](http://www.icsharpcode.net/OpenSource/SD/) IDE. Starting with version 5.0, AvalonEdit is released under the [MIT license](http://opensource.org/licenses/MIT).
89+
90+
We're currently only using a tiny bit of this code editor's functionality (more to come!).
91+
8492
###[WPF Localization Using RESX Files](http://www.codeproject.com/Articles/35159/WPF-Localization-Using-RESX-Files)
8593

8694
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)!

RetailCoder.VBE/App.cs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
using System.Globalization;
1414
using System.Linq;
1515
using System.Windows.Forms;
16+
using Rubberduck.UI.Command;
1617
using Rubberduck.UI.Command.MenuItems.CommandBars;
1718
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
19+
using Rubberduck.VersionCheck;
1820

1921
namespace Rubberduck
2022
{
@@ -28,6 +30,8 @@ public sealed class App : IDisposable
2830
private readonly IAppMenu _appMenus;
2931
private readonly RubberduckCommandBar _stateBar;
3032
private readonly IRubberduckHooks _hooks;
33+
private readonly IVersionCheck _version;
34+
private readonly CommandBase _checkVersionCommand;
3135

3236
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
3337

@@ -39,7 +43,9 @@ public App(IVBE vbe,
3943
IGeneralConfigService configService,
4044
IAppMenu appMenus,
4145
RubberduckCommandBar stateBar,
42-
IRubberduckHooks hooks)
46+
IRubberduckHooks hooks,
47+
IVersionCheck version,
48+
CommandBase checkVersionCommand)
4349
{
4450
_vbe = vbe;
4551
_messageBox = messageBox;
@@ -49,6 +55,8 @@ public App(IVBE vbe,
4955
_appMenus = appMenus;
5056
_stateBar = stateBar;
5157
_hooks = hooks;
58+
_version = version;
59+
_checkVersionCommand = checkVersionCommand;
5260

5361
_hooks.MessageReceived += _hooks_MessageReceived;
5462
_configService.SettingsChanged += _configService_SettingsChanged;
@@ -158,6 +166,11 @@ public void Startup()
158166
_stateBar.SetStatusLabelCaption(ParserState.Pending);
159167
_stateBar.EvaluateCanExecute(_parser.State);
160168
UpdateLoggingLevel();
169+
170+
if (_config.UserSettings.GeneralSettings.CheckVersion)
171+
{
172+
_checkVersionCommand.Execute(null);
173+
}
161174
}
162175

163176
public void Shutdown()
@@ -229,8 +242,8 @@ private void CheckForLegacyIndenterSettings()
229242

230243
private void LogRubberduckSart()
231244
{
232-
var version = GetType().Assembly.GetName().Version.ToString();
233-
GlobalDiagnosticsContext.Set("RubberduckVersion", version);
245+
var version = _version.CurrentVersion;
246+
GlobalDiagnosticsContext.Set("RubberduckVersion", version.ToString());
234247
var headers = new List<string>
235248
{
236249
string.Format("Rubberduck version {0} loading:", version),

RetailCoder.VBE/Common/StringExtensions.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,13 @@ public static string Captialize(this string input)
1515
tokens[0] = CultureInfo.CurrentUICulture.TextInfo.ToTitleCase(tokens[0]);
1616
return string.Join(" ", tokens);
1717
}
18+
public static string CapitalizeFirstLetter(this string input)
19+
{
20+
if (input.Length == 0)
21+
{
22+
return string.Empty;
23+
}
24+
return input.Captialize().Substring(0, 1) + input.Substring(1);
25+
}
1826
}
1927
}

RetailCoder.VBE/Common/WinAPI/RawInput.cs

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33
using System.Collections.Generic;
44
using System.ComponentModel;
55
using System.Runtime.InteropServices;
6-
using System.Windows.Forms;
6+
using Rubberduck.UI;
77

88
namespace Rubberduck.Common.WinAPI
99
{
10-
public class RawInput : NativeWindow
10+
public class RawInput : SubclassingWindow
1111
{
1212
static readonly Guid DeviceInterfaceHid = new Guid("4D1E55B2-F16F-11CF-88CB-001111000030");
1313
private readonly List<IRawDevice> _devices;
1414
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
15+
private static int _currentId;
1516

16-
public RawInput(IntPtr parentHandle)
17+
public RawInput(IntPtr parentHandle) : base (new IntPtr((int)parentHandle + (_currentId++)), parentHandle)
1718
{
18-
AssignHandle(parentHandle);
1919
_devices = new List<IRawDevice>();
2020
}
2121

@@ -26,56 +26,56 @@ public void AddDevice(IRawDevice device)
2626

2727
public IRawDevice CreateKeyboard()
2828
{
29-
return new RawKeyboard(Handle, true);
29+
return new RawKeyboard(Hwnd, true);
3030
}
3131

3232
public IRawDevice CreateMouse()
3333
{
34-
return new RawMouse(Handle, true);
35-
}
34+
return new RawMouse(Hwnd, true);
35+
}
3636

37-
protected override void WndProc(ref Message message)
37+
public override int SubClassProc(IntPtr hWnd, IntPtr msg, IntPtr wParam, IntPtr lParam, IntPtr uIdSubclass, IntPtr dwRefData)
3838
{
39-
switch ((WM)message.Msg)
39+
switch ((WM)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)
5142
{
52-
var ex = new Win32Exception(Marshal.GetLastWin32Error());
53-
Logger.Error(ex, "Error sizing the rawinput buffer: {0}", ex.Message);
54-
break;
55-
}
43+
if (lParam == IntPtr.Zero)
44+
{
45+
break;
46+
}
47+
InputData rawBuffer;
48+
var dwSize = 0;
49+
var res = User32.GetRawInputData(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+
}
5656

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)
65-
{
66-
foreach (var device in _devices)
57+
res = User32.GetRawInputData(lParam, DataCommand.RID_INPUT, out rawBuffer, ref dwSize, Marshal.SizeOf(typeof(RawInputHeader)));
58+
if (res == -1)
6759
{
68-
device.ProcessRawInput(rawBuffer);
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)
65+
{
66+
foreach (var device in _devices)
67+
{
68+
device.ProcessRawInput(rawBuffer);
69+
}
70+
}
71+
else
72+
{
73+
//Something is seriously f'd up with Windows - the number of bytes copied does not match the reported buffer size.
6974
}
7075
}
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;
76+
break;
7777
}
78-
base.WndProc(ref message);
78+
return base.SubClassProc(hWnd, msg, wParam, lParam, uIdSubclass, dwRefData);
7979
}
8080
}
8181
}

RetailCoder.VBE/Extension.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ private void InitializeAddIn()
172172
{
173173
splash = new Splash
174174
{
175+
// note: IVersionCheck.CurrentVersion could return this string.
175176
Version = string.Format("version {0}", Assembly.GetExecutingAssembly().GetName().Version)
176177
};
177178
splash.Show();

RetailCoder.VBE/Inspections/ObjectVariableNotSetInspection.cs

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using Rubberduck.Inspections.Abstract;
44
using Rubberduck.Inspections.Resources;
55
using Rubberduck.Inspections.Results;
6+
using Rubberduck.Parsing;
67
using Rubberduck.Parsing.Grammar;
78
using Rubberduck.Parsing.Symbols;
89
using Rubberduck.Parsing.VBA;
@@ -20,29 +21,13 @@ public ObjectVariableNotSetInspection(RubberduckParserState state)
2021
public override string Description { get { return InspectionsUI.ObjectVariableNotSetInspectionName; } }
2122
public override CodeInspectionType InspectionType { get { return CodeInspectionType.CodeQualityIssues; } }
2223

23-
private static readonly IReadOnlyList<string> ValueTypes = new[]
24-
{
25-
Tokens.Boolean,
26-
Tokens.Byte,
27-
Tokens.Currency,
28-
Tokens.Date,
29-
Tokens.Decimal,
30-
Tokens.Double,
31-
Tokens.Integer,
32-
Tokens.Long,
33-
Tokens.LongLong,
34-
Tokens.Single,
35-
Tokens.String,
36-
Tokens.Variant
37-
};
38-
3924
public override IEnumerable<InspectionResultBase> GetInspectionResults()
4025
{
4126
var interestingDeclarations =
4227
State.AllUserDeclarations.Where(item =>
4328
!item.IsSelfAssigned &&
4429
!item.IsArray &&
45-
!ValueTypes.Contains(item.AsTypeName) &&
30+
!SymbolList.ValueTypes.Contains(item.AsTypeName) &&
4631
(item.AsTypeDeclaration == null || (!ClassModuleDeclaration.HasDefaultMember(item.AsTypeDeclaration) &&
4732
item.AsTypeDeclaration.DeclarationType != DeclarationType.Enumeration &&
4833
item.AsTypeDeclaration.DeclarationType != DeclarationType.UserDefinedType)) &&
@@ -54,7 +39,7 @@ public override IEnumerable<InspectionResultBase> GetInspectionResults()
5439
(item.DeclarationType == DeclarationType.Function || item.DeclarationType == DeclarationType.PropertyGet)
5540
&& !item.IsArray
5641
&& item.IsTypeSpecified
57-
&& !ValueTypes.Contains(item.AsTypeName)
42+
&& !SymbolList.ValueTypes.Contains(item.AsTypeName)
5843
&& (item.AsTypeDeclaration == null // null if unresolved (e.g. in unit tests)
5944
|| (item.AsTypeDeclaration.DeclarationType != DeclarationType.Enumeration && item.AsTypeDeclaration.DeclarationType != DeclarationType.UserDefinedType
6045
&& item.AsTypeDeclaration != null

0 commit comments

Comments
 (0)