Skip to content

Commit 19de9cd

Browse files
author
Andrin Meier
committed
merge next
2 parents f3ea0a2 + 57acde0 commit 19de9cd

17 files changed

+619
-538
lines changed

README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,6 @@ This library makes localizing WPF applications at runtime using resx files a bre
9292

9393
> Licensed under [The Code Project Open License](http://www.codeproject.com/info/cpol10.aspx).
9494
95-
###[EventHook](https://github.com/justcoding121/Windows-User-Action-Hook)
96-
97-
> A one stop library for global windows user actions such mouse, keyboard, clipboard, website visit & print events.
98-
99-
This library allows Rubberduck to detect righ-click actions in the active code pane, to dynamically enable/disable menu commands depending on the current context/selection. We're also using it to capture keypresses, to trigger a reparse of the current module as it's being modified.
100-
10195
##Icons
10296

10397
We didn't come up with these icons ourselves! Here's who did what:

RetailCoder.VBE/App.cs

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ public class App : IDisposable
4444
private readonly IDictionary<VBProjectsEventsSink, Tuple<IConnectionPoint, int>> _referencesEventsConnectionPoints =
4545
new Dictionary<VBProjectsEventsSink, Tuple<IConnectionPoint, int>>();
4646

47-
private readonly IDictionary<Type, Action> _hookActions;
48-
4947
public App(VBE vbe, IMessageBox messageBox,
5048
IRubberduckParser parser,
5149
IGeneralConfigService configService,
@@ -69,6 +67,7 @@ public App(VBE vbe, IMessageBox messageBox,
6967
_configService.SettingsChanged += _configService_SettingsChanged;
7068
_configService.LanguageChanged += ConfigServiceLanguageChanged;
7169
_parser.State.StateChanged += Parser_StateChanged;
70+
_parser.State.StatusMessageUpdate += State_StatusMessageUpdate;
7271
_stateBar.Refresh += _stateBar_Refresh;
7372

7473
var sink = new VBProjectsEventsSink();
@@ -83,40 +82,38 @@ public App(VBE vbe, IMessageBox messageBox,
8382

8483
_projectsEventsConnectionPoint.Advise(sink, out _projectsEventsCookie);
8584

86-
_hookActions = new Dictionary<Type, Action>
87-
{
88-
{ typeof(MouseHook), HandleMouseMessage },
89-
{ typeof(KeyboardHook), HandleKeyboardMessage },
90-
};
91-
92-
9385
UiDispatcher.Initialize();
9486
}
9587

96-
private void _hooks_MessageReceived(object sender, HookEventArgs e)
88+
private void State_StatusMessageUpdate(object sender, RubberduckStatusMessageEventArgs e)
9789
{
98-
var hookType = sender.GetType();
99-
Action action;
100-
if (_hookActions.TryGetValue(hookType, out action))
90+
var message = e.Message;
91+
if (message == ParserState.LoadingReference.ToString())
10192
{
102-
action.Invoke();
93+
// note: ugly hack to enable Rubberduck.Parsing assembly to do this
94+
message = RubberduckUI.ParserState_LoadingReference;
10395
}
104-
}
10596

106-
private void HandleMouseMessage()
107-
{
108-
RefreshSelection();
97+
_stateBar.SetStatusText(message);
10998
}
11099

111-
private void HandleKeyboardMessage()
100+
private void _hooks_MessageReceived(object sender, HookEventArgs e)
112101
{
113102
RefreshSelection();
114103
}
115104

105+
private ParserState _lastStatus;
116106
private void RefreshSelection()
117107
{
118108
_stateBar.SetSelectionText(_parser.State.FindSelectedDeclaration(_vbe.ActiveCodePane));
119-
_appMenus.EvaluateCanExecute(_parser.State);
109+
110+
var currentStatus = _parser.State.Status;
111+
if (_lastStatus != currentStatus)
112+
{
113+
_appMenus.EvaluateCanExecute(_parser.State);
114+
}
115+
116+
_lastStatus = currentStatus;
120117
}
121118

122119
private void _configService_SettingsChanged(object sender, EventArgs e)

RetailCoder.VBE/Common/DeclarationExtensions.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Reflection;
23
using System.Collections.Generic;
34
using System.Diagnostics;
45
using System.Diagnostics.CodeAnalysis;
@@ -449,12 +450,16 @@ public static Declaration FindTarget(this IEnumerable<Declaration> declarations,
449450
foreach (var reference in declaration.References)
450451
{
451452
var proc = (dynamic)reference.Context.Parent;
452-
VBAParser.ArgsCallContext paramList;
453+
var paramList = proc ;
453454

454455
// This is to prevent throws when this statement fails:
455456
// (VBAParser.ArgsCallContext)proc.argsCall();
456-
try { paramList = (VBAParser.ArgsCallContext)proc.argsCall(); }
457-
catch { continue; }
457+
var method = ((Type) proc.GetType()).GetMethod("argsCall");
458+
if (method != null)
459+
{
460+
try { paramList = method.Invoke(proc, null); }
461+
catch { continue; }
462+
}
458463

459464
if (paramList == null) { continue; }
460465

RetailCoder.VBE/Inspections/InspectionsUI.de.resx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,4 +509,16 @@
509509
<data name="QualifiedSelectionInspection" xml:space="preserve">
510510
<value>{0}: {1} - {2}.{3}, Zeile {4}</value>
511511
</data>
512+
<data name="SetObjectVariableQuickFix" xml:space="preserve">
513+
<value>Benutze das Schlüsselwort 'Set'</value>
514+
</data>
515+
<data name="ObjectVariableNotSetInspectionResultFormat" xml:space="preserve">
516+
<value>Objektvariable '{0}' wird ohne das 'Set' Schlüsselwort zugewiesen</value>
517+
</data>
518+
<data name="ObjectVariableNotSetInspectionMeta" xml:space="preserve">
519+
<value>Rubberduck hat festgestellt, dass die Variable eine Objektvaribale ist, die ohne 'Set' Schlüsselwort zugewiesen wird. Dies führt zu dem Laufzeitfehler 91 'Objekt oder With Block Variable wurden nicht gesetzt'.</value>
520+
</data>
521+
<data name="ObjectVariableNotSetInspectionName" xml:space="preserve">
522+
<value>Zuweiseung in eine Objektvariable benötigt das 'Set'-Schlüsselwort.</value>
523+
</data>
512524
</root>

RetailCoder.VBE/Inspections/Inspector.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Threading.Tasks;
77
using Rubberduck.Parsing.VBA;
88
using Rubberduck.Settings;
9+
using Rubberduck.UI;
910

1011
namespace Rubberduck.Inspections
1112
{
@@ -54,6 +55,7 @@ public async Task<IList<ICodeInspectionResult>> FindIssuesAsync(RubberduckParser
5455

5556
await Task.Yield();
5657

58+
state.OnStatusMessageUpdate(RubberduckUI.CodeInspections_Inspecting);
5759
UpdateInspectionSeverity();
5860
//OnReset();
5961

@@ -84,6 +86,7 @@ public async Task<IList<ICodeInspectionResult>> FindIssuesAsync(RubberduckParser
8486
}
8587

8688
Task.WaitAll(inspections);
89+
state.OnStatusMessageUpdate(RubberduckUI.ResourceManager.GetString("ParserState_" + state.Status)); // should be "Ready"
8790

8891
return allIssues.ToList();
8992
}

RetailCoder.VBE/Inspections/UntypedFunctionUsageInspection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public override IEnumerable<InspectionResultBase> GetInspectionResults()
4444
{
4545
var declarations = BuiltInDeclarations
4646
// note: these *should* be functions, but somehow they're not defined as such
47-
.Where(item => _tokens.Any(token => item.References.Any() && (item.IdentifierName == token || item.IdentifierName == "_B_var_" + token)));
47+
.Where(item => _tokens.Any(token => (item.IdentifierName == token || item.IdentifierName == "_B_var_" + token)) && item.References.Any());
4848

4949
return declarations.SelectMany(declaration => declaration.References
5050
.Select(item => new UntypedFunctionUsageInspectionResult(this, string.Format(Description, declaration.IdentifierName), item.QualifiedModuleName, item.Context)));

RetailCoder.VBE/Inspections/VariableTypeNotDeclaredInspection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public override IEnumerable<InspectionResultBase> GetInspectionResults()
2121
var issues = from item in UserDeclarations
2222
where (item.DeclarationType == DeclarationType.Variable
2323
|| item.DeclarationType == DeclarationType.Constant
24-
|| item.DeclarationType == DeclarationType.Parameter)
24+
|| (item.DeclarationType == DeclarationType.Parameter && !item.IsArray()))
2525
&& !item.IsTypeSpecified()
2626
select new VariableTypeNotDeclaredInspectionResult(this, item);
2727

RetailCoder.VBE/UI/Command/MenuItems/RubberduckCommandBar.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ private void _statusButton_Click(CommandBarButton Ctrl, ref bool CancelDefault)
4141

4242
public void SetStatusText(string value = null)
4343
{
44+
Debug.WriteLine(string.Format("RubberduckCommandBar status text changes to '{0}'.", value));
4445
UiDispatcher.Invoke(() => _statusButton.Caption = value ?? RubberduckUI.ResourceManager.GetString("ParserState_" + _state.Status));
4546
}
4647

@@ -50,6 +51,7 @@ public void SetSelectionText(Declaration declaration)
5051
{
5152
var selection = _vbe.ActiveCodePane.GetSelection();
5253
SetSelectionText(selection);
54+
_selectionButton.TooltipText = _selectionButton.Caption;
5355
}
5456
else if (declaration != null && !declaration.IsBuiltIn && declaration.DeclarationType != DeclarationType.ClassModule && declaration.DeclarationType != DeclarationType.ProceduralModule)
5557
{
@@ -58,6 +60,9 @@ public void SetSelectionText(Declaration declaration)
5860
declaration.QualifiedSelection.Selection,
5961
declaration.IdentifierName,
6062
RubberduckUI.ResourceManager.GetString("DeclarationType_" + declaration.DeclarationType));
63+
_selectionButton.TooltipText = string.IsNullOrEmpty(declaration.DescriptionString)
64+
? _selectionButton.Caption
65+
: declaration.DescriptionString;
6166
}
6267
else if (declaration != null)
6368
{
@@ -67,6 +72,9 @@ public void SetSelectionText(Declaration declaration)
6772
declaration.IdentifierName,
6873
RubberduckUI.ResourceManager.GetString("DeclarationType_" + declaration.DeclarationType),
6974
selection.Selection);
75+
_selectionButton.TooltipText = string.IsNullOrEmpty(declaration.DescriptionString)
76+
? _selectionButton.Caption
77+
: declaration.DescriptionString;
7078
}
7179
}
7280

RetailCoder.VBE/UI/Command/Refactorings/FormDesignerRefactorRenameCommand.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,10 @@ private Declaration GetTarget()
5959
}
6060

6161
return _state.AllUserDeclarations
62-
.FirstOrDefault(item => item.IdentifierName == control.Name &&
63-
item.ComponentName == Vbe.SelectedVBComponent.Name &&
64-
Vbe.ActiveVBProject.HelpFile == item.ProjectId);
62+
.FirstOrDefault(item => item.DeclarationType == DeclarationType.Control
63+
&& Vbe.ActiveVBProject.HelpFile == item.ProjectId
64+
&& item.ComponentName == Vbe.SelectedVBComponent.Name
65+
&& item.IdentifierName == control.Name);
6566
}
6667
}
6768

0 commit comments

Comments
 (0)