Skip to content

Commit debaf1e

Browse files
committed
Merge with conflicts
2 parents e554a95 + 5d49b4e commit debaf1e

File tree

90 files changed

+3078
-2536
lines changed

Some content is hidden

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

90 files changed

+3078
-2536
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
![Rubberduck](http://i.stack.imgur.com/vmqXM.png)
1+
<img src="http://i.stack.imgur.com/vmqXM.png" width="320" />
22

3-
| Branch | Build Status |
4-
|------------|--------------|
5-
| **master** | ![master branch build status][masterBuildStatus] |
6-
| **next** | ![next branch build status][nextBuildStatus] |
3+
Branch | Description | Build Status |
4+
|------------|---|--------------|
5+
| **master** | The last released build | ![master branch build status][masterBuildStatus] |
6+
| **next** | The current build (dev) | ![next branch build status][nextBuildStatus] |
77

88
[nextBuildStatus]:https://ci.appveyor.com/api/projects/status/we3pdnkeebo4nlck/branch/next?svg=true
99
[masterBuildStatus]:https://ci.appveyor.com/api/projects/status/we3pdnkeebo4nlck/branch/master?svg=true

RetailCoder.VBE/App.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,8 @@ private void LoadConfig()
488488
{
489489
_config = _configService.LoadConfiguration();
490490

491+
_autoSave.ConfigServiceSettingsChanged(this, EventArgs.Empty);
492+
491493
var currentCulture = RubberduckUI.Culture;
492494
try
493495
{

RetailCoder.VBE/AutoSave/AutoSave.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@ public AutoSave(VBE vbe, IGeneralConfigService configService)
2222

2323
_configService.SettingsChanged += ConfigServiceSettingsChanged;
2424
_timer.Elapsed += _timer_Elapsed;
25-
26-
ConfigServiceSettingsChanged(null, EventArgs.Empty);
25+
_timer.Enabled = false;
2726
}
2827

29-
private void ConfigServiceSettingsChanged(object sender, EventArgs e)
28+
public void ConfigServiceSettingsChanged(object sender, EventArgs e)
3029
{
3130
var config = _configService.LoadConfiguration();
3231

RetailCoder.VBE/Common/Hotkeys/Hotkey.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ namespace Rubberduck.Common.Hotkeys
1212
public class Hotkey : IHotkey
1313
{
1414
private readonly string _key;
15-
private readonly ICommand _command;
15+
private readonly CommandBase _command;
1616
private readonly IntPtr _hWndVbe;
1717
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
1818

19-
public Hotkey(IntPtr hWndVbe, string key, ICommand command, Keys secondKey = Keys.None)
19+
public Hotkey(IntPtr hWndVbe, string key, CommandBase command, Keys secondKey = Keys.None)
2020
{
2121
_hWndVbe = hWndVbe;
2222

@@ -27,7 +27,7 @@ public Hotkey(IntPtr hWndVbe, string key, ICommand command, Keys secondKey = Key
2727
SecondKey = secondKey;
2828
}
2929

30-
public ICommand Command { get { return _command; } }
30+
public CommandBase Command { get { return _command; } }
3131
public string Key { get { return _key; } }
3232
public HotkeyInfo HotkeyInfo { get; private set; }
3333
public Keys Combo { get; private set; }

RetailCoder.VBE/Common/Hotkeys/IHotkey.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
using System.Windows.Forms;
22
using System.Windows.Input;
3+
using Rubberduck.UI.Command;
34

45
namespace Rubberduck.Common.Hotkeys
56
{
67
public interface IHotkey : IAttachable
78
{
89
string Key { get; }
9-
ICommand Command { get; }
10+
CommandBase Command { get; }
1011
HotkeyInfo HotkeyInfo { get; }
1112
Keys Combo { get; }
1213
Keys SecondKey { get; }

RetailCoder.VBE/Common/RubberduckHooks.cs

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.ComponentModel;
4+
using System.Diagnostics;
45
using System.Linq;
56
using System.Runtime.InteropServices;
67
using System.Windows.Forms;
@@ -26,12 +27,11 @@ public class RubberduckHooks : IRubberduckHooks
2627
private IRawDevice _kb;
2728
private IRawDevice _mouse;
2829
private readonly IGeneralConfigService _config;
29-
private readonly IEnumerable<ICommand> _commands;
30+
private readonly IEnumerable<CommandBase> _commands;
3031
private readonly IList<IAttachable> _hooks = new List<IAttachable>();
31-
private readonly IDictionary<RubberduckHotkey, ICommand> _mappings;
3232
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
3333

34-
public RubberduckHooks(VBE vbe, IGeneralConfigService config, IEnumerable<ICommand> commands)
34+
public RubberduckHooks(VBE vbe, IGeneralConfigService config, IEnumerable<CommandBase> commands)
3535
{
3636
_vbe = vbe;
3737
_mainWindowHandle = (IntPtr)vbe.MainWindow.HWnd;
@@ -42,29 +42,11 @@ public RubberduckHooks(VBE vbe, IGeneralConfigService config, IEnumerable<IComma
4242

4343
_commands = commands;
4444
_config = config;
45-
_mappings = GetCommandMappings();
4645
}
4746

48-
private ICommand Command<TCommand>() where TCommand : ICommand
47+
private CommandBase Command(RubberduckHotkey hotkey)
4948
{
50-
return _commands.OfType<TCommand>().SingleOrDefault();
51-
}
52-
53-
private IDictionary<RubberduckHotkey, ICommand> GetCommandMappings()
54-
{
55-
return new Dictionary<RubberduckHotkey, ICommand>
56-
{
57-
{ RubberduckHotkey.ParseAll, Command<ReparseCommand>() },
58-
{ RubberduckHotkey.CodeExplorer, Command<CodeExplorerCommand>() },
59-
{ RubberduckHotkey.IndentModule, Command<IndentCurrentModuleCommand>() },
60-
{ RubberduckHotkey.IndentProcedure, Command<IndentCurrentProcedureCommand>() },
61-
{ RubberduckHotkey.FindSymbol, Command<FindSymbolCommand>() },
62-
{ RubberduckHotkey.RefactorMoveCloserToUsage, Command<RefactorMoveCloserToUsageCommand>() },
63-
{ RubberduckHotkey.InspectionResults, Command<InspectionResultsCommand>() },
64-
{ RubberduckHotkey.RefactorExtractMethod, Command<RefactorExtractMethodCommand>() },
65-
{ RubberduckHotkey.RefactorRename, Command<CodePaneRefactorRenameCommand>() },
66-
{ RubberduckHotkey.TestExplorer, Command<TestExplorerCommand>() }
67-
};
49+
return _commands.SingleOrDefault(s => s.Hotkey == hotkey);
6850
}
6951

7052
public void HookHotkeys()
@@ -92,7 +74,10 @@ public void HookHotkeys()
9274
RubberduckHotkey assigned;
9375
if (Enum.TryParse(hotkey.Name, out assigned))
9476
{
95-
AddHook(new Hotkey(_mainWindowHandle, hotkey.ToString(), _mappings[assigned]));
77+
var command = Command(assigned);
78+
Debug.Assert(command != null);
79+
80+
AddHook(new Hotkey(_mainWindowHandle, hotkey.ToString(), command));
9681
}
9782
}
9883
Attach();
@@ -214,9 +199,23 @@ private IntPtr WindowProc(IntPtr hWnd, uint uMsg, IntPtr wParam, IntPtr lParam)
214199
try
215200
{
216201
var suppress = false;
217-
if (hWnd == _mainWindowHandle && (WM)uMsg == WM.HOTKEY)
202+
switch ((WM) uMsg)
218203
{
219-
suppress = HandleHotkeyMessage(wParam);
204+
case WM.HOTKEY:
205+
suppress = hWnd == _mainWindowHandle && HandleHotkeyMessage(wParam);
206+
break;
207+
case WM.SETFOCUS:
208+
Attach();
209+
break;
210+
case WM.NCACTIVATE:
211+
if (wParam == IntPtr.Zero)
212+
{
213+
Detach();
214+
}
215+
break;
216+
case WM.CLOSE:
217+
Detach();
218+
break;
220219
}
221220

222221
return suppress

RetailCoder.VBE/Inspections/UntypedFunctionUsageInspection.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,9 @@ public UntypedFunctionUsageInspection(RubberduckParserState state)
4343
public override IEnumerable<InspectionResultBase> GetInspectionResults()
4444
{
4545
var declarations = BuiltInDeclarations
46-
// note: these *should* be functions, but somehow they're not defined as such
4746
.Where(item =>
4847
_tokens.Any(token => item.IdentifierName == token || item.IdentifierName == "_B_var_" + token) &&
49-
item.References.Any(reference => _tokens.Contains(reference.IdentifierName)));
48+
item.Scope.StartsWith("VBE7.DLL;"));
5049

5150
return declarations.SelectMany(declaration => declaration.References
5251
.Where(item => _tokens.Contains(item.IdentifierName))

RetailCoder.VBE/Inspections/UntypedFunctionUsageInspectionResult.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ public override void Fix()
6767
var module = Selection.QualifiedName.Component.CodeModule;
6868
var lines = module.Lines[selection.StartLine, selection.LineCount];
6969

70-
var result = lines.Replace(originalInstruction, newInstruction);
70+
var result = lines.Remove(Context.Start.Column, originalInstruction.Length)
71+
.Insert(Context.Start.Column, newInstruction);
7172
module.ReplaceLine(selection.StartLine, result);
7273
}
7374

RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerViewModel.cs

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public sealed class CodeExplorerViewModel : ViewModelBase, IDisposable
2323
private readonly FolderHelper _folderHelper;
2424
private readonly RubberduckParserState _state;
2525

26-
public CodeExplorerViewModel(FolderHelper folderHelper, RubberduckParserState state, List<ICommand> commands)
26+
public CodeExplorerViewModel(FolderHelper folderHelper, RubberduckParserState state, List<CommandBase> commands)
2727
{
2828
_folderHelper = folderHelper;
2929
_state = state;
@@ -143,14 +143,14 @@ public bool SortBySelection
143143
}
144144
}
145145

146-
private readonly ICommand _copyResultsCommand;
147-
public ICommand CopyResultsCommand { get { return _copyResultsCommand; } }
146+
private readonly CommandBase _copyResultsCommand;
147+
public CommandBase CopyResultsCommand { get { return _copyResultsCommand; } }
148148

149-
private readonly ICommand _setNameSortCommand;
150-
public ICommand SetNameSortCommand { get { return _setNameSortCommand; } }
149+
private readonly CommandBase _setNameSortCommand;
150+
public CommandBase SetNameSortCommand { get { return _setNameSortCommand; } }
151151

152-
private readonly ICommand _setSelectionSortCommand;
153-
public ICommand SetSelectionSortCommand { get { return _setSelectionSortCommand; } }
152+
private readonly CommandBase _setSelectionSortCommand;
153+
public CommandBase SetSelectionSortCommand { get { return _setSelectionSortCommand; } }
154154

155155
private bool _sortByType = true;
156156
public bool SortByType
@@ -419,64 +419,64 @@ private void SetErrorState(CodeExplorerItemViewModel itemNode, VBComponent compo
419419
}
420420
}
421421

422-
private readonly ICommand _refreshCommand;
423-
public ICommand RefreshCommand { get { return _refreshCommand; } }
422+
private readonly CommandBase _refreshCommand;
423+
public CommandBase RefreshCommand { get { return _refreshCommand; } }
424424

425-
private readonly ICommand _refreshComponentCommand;
426-
public ICommand RefreshComponentCommand { get { return _refreshComponentCommand; } }
425+
private readonly CommandBase _refreshComponentCommand;
426+
public CommandBase RefreshComponentCommand { get { return _refreshComponentCommand; } }
427427

428-
private readonly ICommand _navigateCommand;
429-
public ICommand NavigateCommand { get { return _navigateCommand; } }
428+
private readonly CommandBase _navigateCommand;
429+
public CommandBase NavigateCommand { get { return _navigateCommand; } }
430430

431-
private readonly ICommand _addTestModuleCommand;
432-
public ICommand AddTestModuleCommand { get { return _addTestModuleCommand; } }
431+
private readonly CommandBase _addTestModuleCommand;
432+
public CommandBase AddTestModuleCommand { get { return _addTestModuleCommand; } }
433433

434-
private readonly ICommand _addStdModuleCommand;
435-
public ICommand AddStdModuleCommand { get { return _addStdModuleCommand; } }
434+
private readonly CommandBase _addStdModuleCommand;
435+
public CommandBase AddStdModuleCommand { get { return _addStdModuleCommand; } }
436436

437-
private readonly ICommand _addClassModuleCommand;
438-
public ICommand AddClassModuleCommand { get { return _addClassModuleCommand; } }
437+
private readonly CommandBase _addClassModuleCommand;
438+
public CommandBase AddClassModuleCommand { get { return _addClassModuleCommand; } }
439439

440-
private readonly ICommand _addUserFormCommand;
441-
public ICommand AddUserFormCommand { get { return _addUserFormCommand; } }
440+
private readonly CommandBase _addUserFormCommand;
441+
public CommandBase AddUserFormCommand { get { return _addUserFormCommand; } }
442442

443-
private readonly ICommand _openDesignerCommand;
444-
public ICommand OpenDesignerCommand { get { return _openDesignerCommand; } }
443+
private readonly CommandBase _openDesignerCommand;
444+
public CommandBase OpenDesignerCommand { get { return _openDesignerCommand; } }
445445

446-
private readonly ICommand _openProjectPropertiesCommand;
447-
public ICommand OpenProjectPropertiesCommand { get { return _openProjectPropertiesCommand; } }
446+
private readonly CommandBase _openProjectPropertiesCommand;
447+
public CommandBase OpenProjectPropertiesCommand { get { return _openProjectPropertiesCommand; } }
448448

449-
private readonly ICommand _renameCommand;
450-
public ICommand RenameCommand { get { return _renameCommand; } }
449+
private readonly CommandBase _renameCommand;
450+
public CommandBase RenameCommand { get { return _renameCommand; } }
451451

452-
private readonly ICommand _indenterCommand;
453-
public ICommand IndenterCommand { get { return _indenterCommand; } }
452+
private readonly CommandBase _indenterCommand;
453+
public CommandBase IndenterCommand { get { return _indenterCommand; } }
454454

455-
private readonly ICommand _findAllReferencesCommand;
456-
public ICommand FindAllReferencesCommand { get { return _findAllReferencesCommand; } }
455+
private readonly CommandBase _findAllReferencesCommand;
456+
public CommandBase FindAllReferencesCommand { get { return _findAllReferencesCommand; } }
457457

458-
private readonly ICommand _findAllImplementationsCommand;
459-
public ICommand FindAllImplementationsCommand { get { return _findAllImplementationsCommand; } }
458+
private readonly CommandBase _findAllImplementationsCommand;
459+
public CommandBase FindAllImplementationsCommand { get { return _findAllImplementationsCommand; } }
460460

461-
private readonly ICommand _importCommand;
462-
public ICommand ImportCommand { get { return _importCommand; } }
461+
private readonly CommandBase _importCommand;
462+
public CommandBase ImportCommand { get { return _importCommand; } }
463463

464-
private readonly ICommand _exportCommand;
465-
public ICommand ExportCommand { get { return _exportCommand; } }
464+
private readonly CommandBase _exportCommand;
465+
public CommandBase ExportCommand { get { return _exportCommand; } }
466466

467-
private readonly ICommand _removeCommand;
468-
public ICommand RemoveCommand { get { return _removeCommand; } }
467+
private readonly CommandBase _removeCommand;
468+
public CommandBase RemoveCommand { get { return _removeCommand; } }
469469

470-
private readonly ICommand _printCommand;
471-
public ICommand PrintCommand { get { return _printCommand; } }
470+
private readonly CommandBase _printCommand;
471+
public CommandBase PrintCommand { get { return _printCommand; } }
472472

473-
private readonly ICommand _commitCommand;
474-
public ICommand CommitCommand { get { return _commitCommand; } }
473+
private readonly CommandBase _commitCommand;
474+
public CommandBase CommitCommand { get { return _commitCommand; } }
475475

476-
private readonly ICommand _undoCommand;
477-
public ICommand UndoCommand { get { return _undoCommand; } }
476+
private readonly CommandBase _undoCommand;
477+
public CommandBase UndoCommand { get { return _undoCommand; } }
478478

479-
private readonly ICommand _externalRemoveCommand;
479+
private readonly CommandBase _externalRemoveCommand;
480480

481481
// this is a special case--we have to reset SelectedItem to prevent a crash
482482
private void ExecuteRemoveComand(object param)

RetailCoder.VBE/Refactorings/MoveCloserToUsage/MoveCloserToUsageRefactoring.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,13 @@ private void MoveCloserToUsage()
110110

111111
private void _state_StateChanged(object sender, ParserStateEventArgs e)
112112
{
113-
if (e.State != ParserState.Ready) { return; }
113+
if (e.State != ParserState.ResolvedDeclarations) { return; }
114114

115115
var newTarget = _state.AllUserDeclarations.FirstOrDefault(
116116
item => item.ComponentName == _target.ComponentName &&
117117
item.IdentifierName == _target.IdentifierName &&
118118
item.ParentScope == _target.ParentScope &&
119-
item.Project == _target.Project &&
119+
item.ProjectId == _target.ProjectId &&
120120
Equals(item.Selection, _target.Selection));
121121

122122
if (newTarget != null)

0 commit comments

Comments
 (0)