Skip to content

Commit e9f2766

Browse files
committed
added ParseAllCommand and hotkey (Ctrl+Backtick), and moved some of the commands' CanExecute /FindTarget logic into RubberduckParserState. Context menu lag is acceptable now.
1 parent 9888833 commit e9f2766

22 files changed

+223
-113
lines changed

RetailCoder.VBE/App.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public App(VBE vbe, IMessageBox messageBox,
8585
_hookActions = new Dictionary<Type, Action>
8686
{
8787
{ typeof(MouseHook), HandleMouseMessage },
88-
{ typeof(KeyboardHook), HandleKeyboardMessage },
88+
//{ typeof(KeyboardHook), HandleKeyboardMessage },
8989
};
9090

9191

RetailCoder.VBE/Common/Hotkeys/Hotkey.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ private static uint GetModifierValue(ref string key)
129129

130130
private static Keys GetCombo(string key)
131131
{
132-
return (Keys)Enum.Parse(typeof(Keys), key.Trim('%', '^', '+')) // will break with special keys, e.g. {f12}
132+
return GetKey(key.Trim('%', '^', '+')) // will break with special keys, e.g. {f12}
133133
| (key.Contains("%") ? Keys.Alt : Keys.None)
134134
| (key.Contains("^") ? Keys.Control : Keys.None)
135135
| (key.Contains("+") ? Keys.Shift : Keys.None);
@@ -146,6 +146,9 @@ private static Keys GetKey(string keyCode)
146146
case "~":
147147
result = Keys.Return;
148148
break;
149+
case "`":
150+
result = Keys.Oemtilde;
151+
break;
149152
default:
150153
if (!string.IsNullOrEmpty(keyCode))
151154
{

RetailCoder.VBE/Common/RubberduckHooks.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public void HookHotkeys()
4444
var config = _config.LoadConfiguration();
4545
var settings = config.UserSettings.GeneralSettings.HotkeySettings;
4646

47-
AddHook(new KeyboardHook(_vbe));
47+
//AddHook(new KeyboardHook(_vbe));
4848
AddHook(new MouseHook(_vbe));
4949
foreach (var hotkey in settings.Where(hotkey => hotkey.IsEnabled))
5050
{

RetailCoder.VBE/Inspections/ParameterCanBeByValInspection.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,9 @@ public override IEnumerable<InspectionResultBase> GetInspectionResults()
4545
var declarations = UserDeclarations.ToList();
4646

4747
IEnumerable<Declaration> interfaceMembers = null;
48-
_dispatcher.Invoke(() =>
49-
{
50-
interfaceMembers = declarations.FindInterfaceMembers()
51-
.Concat(declarations.FindInterfaceImplementationMembers())
52-
.ToList();
53-
});
48+
interfaceMembers = declarations.FindInterfaceMembers()
49+
.Concat(declarations.FindInterfaceImplementationMembers())
50+
.ToList();
5451

5552
var formEventHandlerScopes = declarations.FindFormEventHandlers()
5653
.Select(handler => handler.Scope);

RetailCoder.VBE/Rubberduck.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@
361361
</Compile>
362362
<Compile Include="UI\Command\IndentCurrentModuleCommand.cs" />
363363
<Compile Include="UI\Command\MenuItems\InspectionResultsCommandMenuItem.cs" />
364+
<Compile Include="UI\Command\ReparseCommand.cs" />
364365
<Compile Include="UI\Command\ShowParserErrorsCommand.cs" />
365366
<Compile Include="UI\Command\SyntaxErrorExtensions.cs" />
366367
<Compile Include="UI\Controls\DeclarationTypeToStringConverter.cs" />

RetailCoder.VBE/Settings/ConfigurationLoader.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ private IDictionary<RubberduckHotkey, ICommand> GetCommandMappings()
8989
{
9090
return new Dictionary<RubberduckHotkey, ICommand>
9191
{
92+
{ RubberduckHotkey.ParseAll, Command<ReparseCommand>() },
9293
{ RubberduckHotkey.CodeExplorer, Command<CodeExplorerCommand>() },
9394
{ RubberduckHotkey.IndentModule, Command<IndentCurrentModuleCommand>() },
9495
{ RubberduckHotkey.IndentProcedure, Command<IndentCurrentProcedureCommand>() },
@@ -183,6 +184,7 @@ private GeneralSettings GetDefaultGeneralSettings()
183184
return new GeneralSettings(new DisplayLanguageSetting("en-US"),
184185
new[]
185186
{
187+
new HotkeySetting{Name=RubberduckHotkey.ParseAll.ToString(), IsEnabled=true, HasCtrlModifier = true, Key1="`", Command = commandMappings[RubberduckHotkey.ParseAll]},
186188
new HotkeySetting{Name=RubberduckHotkey.IndentProcedure.ToString(), IsEnabled=true, HasCtrlModifier = true, Key1="P", Command = commandMappings[RubberduckHotkey.IndentProcedure]},
187189
new HotkeySetting{Name=RubberduckHotkey.IndentModule.ToString(), IsEnabled=true, HasCtrlModifier = true, Key1="M", Command = commandMappings[RubberduckHotkey.IndentModule]},
188190
new HotkeySetting{Name=RubberduckHotkey.CodeExplorer.ToString(), IsEnabled=true, HasCtrlModifier = true, Key1="R", Command = commandMappings[RubberduckHotkey.CodeExplorer]},

RetailCoder.VBE/Settings/RubberduckHotkey.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ namespace Rubberduck.Settings
22
{
33
public enum RubberduckHotkey
44
{
5+
ParseAll,
56
IndentProcedure,
67
IndentModule,
78
CodeExplorer,

RetailCoder.VBE/UI/CodeInspections/InspectionResultsViewModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ private async void _state_StateChanged(object sender, EventArgs e)
164164
}
165165

166166
Debug.WriteLine("Running code inspections...");
167+
IsBusy = true;
167168
var results = await _inspector.FindIssuesAsync(_state, CancellationToken.None);
168169
_dispatcher.Invoke(() =>
169170
{

RetailCoder.VBE/UI/Command/FindAllImplementationsCommand.cs

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,7 @@ private Declaration FindTarget(object parameter)
115115
return declaration;
116116
}
117117

118-
var selection = _vbe.ActiveCodePane.GetSelection();
119-
if (!selection.Equals(default(QualifiedSelection)))
120-
{
121-
declaration = _state.AllDeclarations
122-
.SingleOrDefault(item => item.DeclarationType != DeclarationType.Project &&
123-
item.DeclarationType != DeclarationType.ModuleOption &&
124-
(IsSelectedDeclaration(selection, item) ||
125-
item.References.Any(reference => IsSelectedReference(selection, reference))));
126-
}
127-
return declaration;
118+
return _state.FindSelecteDeclaration(_vbe.ActiveCodePane);
128119
}
129120

130121
private IEnumerable<Declaration> FindImplementations(Declaration target)
@@ -183,17 +174,5 @@ private IEnumerable<Declaration> FindAllImplementationsOfMember(Declaration targ
183174
return items.FindInterfaceImplementationMembers(member.IdentifierName)
184175
.Where(item => item.IdentifierName == member.ComponentName + "_" + member.IdentifierName);
185176
}
186-
187-
private static bool IsSelectedDeclaration(QualifiedSelection selection, Declaration declaration)
188-
{
189-
return declaration.QualifiedSelection.QualifiedName.Equals(selection.QualifiedName)
190-
&& declaration.QualifiedSelection.Selection.ContainsFirstCharacter(selection.Selection);
191-
}
192-
193-
private static bool IsSelectedReference(QualifiedSelection selection, IdentifierReference reference)
194-
{
195-
return reference.QualifiedModuleName.Equals(selection.QualifiedName)
196-
&& reference.Selection.ContainsFirstCharacter(selection.Selection);
197-
}
198177
}
199178
}

RetailCoder.VBE/UI/Command/FindAllReferencesCommand.cs

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@
44
using System.Runtime.InteropServices;
55
using System.Windows.Forms;
66
using Microsoft.Vbe.Interop;
7-
using Rubberduck.Common;
87
using Rubberduck.Parsing.Symbols;
98
using Rubberduck.Parsing.VBA;
109
using Rubberduck.UI.Controls;
11-
using Rubberduck.VBEditor;
12-
using Rubberduck.VBEditor.VBEInterfaces.RubberduckCodePane;
1310

1411
namespace Rubberduck.UI.Command
1512
{
@@ -113,28 +110,7 @@ private Declaration FindTarget(object parameter)
113110
return declaration;
114111
}
115112

116-
var selection = _vbe.ActiveCodePane.GetSelection();
117-
if (!selection.Equals(default(QualifiedSelection)))
118-
{
119-
declaration = _state.AllDeclarations
120-
.SingleOrDefault(item => item.DeclarationType != DeclarationType.Project &&
121-
item.DeclarationType != DeclarationType.ModuleOption &&
122-
(IsSelectedDeclaration(selection, item) ||
123-
item.References.Any(reference => IsSelectedReference(selection, reference))));
124-
}
125-
return declaration;
126-
}
127-
128-
private static bool IsSelectedDeclaration(QualifiedSelection selection, Declaration declaration)
129-
{
130-
return declaration.QualifiedSelection.QualifiedName.Equals(selection.QualifiedName)
131-
&& declaration.QualifiedSelection.Selection.ContainsFirstCharacter(selection.Selection);
132-
}
133-
134-
private static bool IsSelectedReference(QualifiedSelection selection, IdentifierReference reference)
135-
{
136-
return reference.QualifiedModuleName.Equals(selection.QualifiedName)
137-
&& reference.Selection.ContainsFirstCharacter(selection.Selection);
113+
return _state.FindSelecteDeclaration(_vbe.ActiveCodePane);
138114
}
139115
}
140116
}

0 commit comments

Comments
 (0)