Skip to content

Commit 71fcacd

Browse files
committed
resolved conflicts
2 parents f153743 + f4d7638 commit 71fcacd

File tree

185 files changed

+20268
-24562
lines changed

Some content is hidden

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

185 files changed

+20268
-24562
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ _TeamCity*
8383
# NCrunch
8484
*.ncrunch*
8585
.*crunch*.local.xml
86+
_Ncrunch*
8687

8788
# Installshield output folder
8889
[Ee]xpress/

RetailCoder.VBE/API/Declaration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ internal Declaration(RubberduckDeclaration declaration)
4040

4141
protected RubberduckDeclaration Instance { get { return _declaration; } }
4242

43+
public bool IsArray { get { return _declaration.IsArray; } }
4344
public string Name { get { return _declaration.IdentifierName; } }
4445
public Accessibility Accessibility { get { return (Accessibility)_declaration.Accessibility; } }
4546
public DeclarationType DeclarationType {get { return TypeMappings[_declaration.DeclarationType]; }}
4647
public string TypeName { get { return _declaration.AsTypeName; } }
47-
public bool IsArray { get { return _declaration.IsArray(); } }
4848

4949
private static readonly IDictionary<Parsing.Symbols.DeclarationType,DeclarationType> TypeMappings =
5050
new Dictionary<Parsing.Symbols.DeclarationType, DeclarationType>

RetailCoder.VBE/App.cs

Lines changed: 47 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ namespace Rubberduck
2323
{
2424
public sealed class App : IDisposable
2525
{
26+
private const string FILE_TARGET_NAME = "file";
2627
private readonly VBE _vbe;
2728
private readonly IMessageBox _messageBox;
2829
private readonly IRubberduckParser _parser;
@@ -41,7 +42,7 @@ public sealed class App : IDisposable
4142
private readonly IConnectionPoint _projectsEventsConnectionPoint;
4243
private readonly int _projectsEventsCookie;
4344

44-
private readonly IDictionary<string, Tuple<IConnectionPoint, int>> _componentsEventsConnectionPoints =
45+
private readonly IDictionary<string, Tuple<IConnectionPoint, int>> _componentsEventsConnectionPoints =
4546
new Dictionary<string, Tuple<IConnectionPoint, int>>();
4647
private readonly IDictionary<string, Tuple<IConnectionPoint, int>> _referencesEventsConnectionPoints =
4748
new Dictionary<string, Tuple<IConnectionPoint, int>>();
@@ -74,7 +75,7 @@ public App(VBE vbe, IMessageBox messageBox,
7475

7576
_sink = new VBProjectsEventsSink();
7677
var connectionPointContainer = (IConnectionPointContainer)_vbe.VBProjects;
77-
var interfaceId = typeof (_dispVBProjectsEvents).GUID;
78+
var interfaceId = typeof(_dispVBProjectsEvents).GUID;
7879
connectionPointContainer.FindConnectionPoint(ref interfaceId, out _projectsEventsConnectionPoint);
7980

8081
_sink.ProjectAdded += sink_ProjectAdded;
@@ -130,9 +131,32 @@ private bool ShouldEvaluateCanExecute(Declaration selectedDeclaration, ParserSta
130131

131132
private void _configService_SettingsChanged(object sender, EventArgs e)
132133
{
134+
_config = _configService.LoadConfiguration();
133135
// also updates the ShortcutKey text
134136
_appMenus.Localize();
135137
_hooks.HookHotkeys();
138+
UpdateLoggingLevel();
139+
}
140+
141+
private void UpdateLoggingLevel()
142+
{
143+
var fileRule = LogManager.Configuration.LoggingRules.Where(rule => rule.Targets.Any(t => t.Name == FILE_TARGET_NAME)).FirstOrDefault();
144+
if (fileRule == null)
145+
{
146+
return;
147+
}
148+
if (_config.UserSettings.GeneralSettings.DetailedLoggingEnabled)
149+
{
150+
// "Enable" should have been called "Add" perhaps?
151+
fileRule.EnableLoggingForLevel(LogLevel.Trace);
152+
fileRule.EnableLoggingForLevel(LogLevel.Debug);
153+
}
154+
else
155+
{
156+
fileRule.DisableLoggingForLevel(LogLevel.Trace);
157+
fileRule.DisableLoggingForLevel(LogLevel.Debug);
158+
}
159+
LogManager.ReconfigExistingLoggers();
136160
}
137161

138162
public void Startup()
@@ -142,6 +166,7 @@ public void Startup()
142166
_appMenus.Localize();
143167
Task.Delay(1000).ContinueWith(t => UiDispatcher.Invoke(() => _parser.State.OnParseRequested(this))).ConfigureAwait(false);
144168
_hooks.HookHotkeys();
169+
UpdateLoggingLevel();
145170
}
146171

147172
public void Shutdown()
@@ -161,7 +186,7 @@ async void sink_ProjectRemoved(object sender, DispatcherEventArgs<VBProject> e)
161186
{
162187
if (e.Item.Protection == vbext_ProjectProtection.vbext_pp_locked)
163188
{
164-
Debug.WriteLine(string.Format("Locked project '{0}' was removed.", e.Item.Name));
189+
_logger.Debug("Locked project '{0}' was removed.", e.Item.Name);
165190
return;
166191
}
167192

@@ -170,7 +195,7 @@ async void sink_ProjectRemoved(object sender, DispatcherEventArgs<VBProject> e)
170195
_referencesEventsSinks.Remove(projectId);
171196
_parser.State.RemoveProject(e.Item);
172197

173-
Debug.WriteLine(string.Format("Project '{0}' was removed.", e.Item.Name));
198+
_logger.Debug("Project '{0}' was removed.", e.Item.Name);
174199
Tuple<IConnectionPoint, int> componentsTuple;
175200
if (_componentsEventsConnectionPoints.TryGetValue(projectId, out componentsTuple))
176201
{
@@ -186,18 +211,18 @@ async void sink_ProjectRemoved(object sender, DispatcherEventArgs<VBProject> e)
186211
}
187212
}
188213

189-
private readonly IDictionary<string,VBComponentsEventsSink> _componentsEventsSinks =
190-
new Dictionary<string,VBComponentsEventsSink>();
214+
private readonly IDictionary<string, VBComponentsEventsSink> _componentsEventsSinks =
215+
new Dictionary<string, VBComponentsEventsSink>();
191216

192-
private readonly IDictionary<string,ReferencesEventsSink> _referencesEventsSinks =
217+
private readonly IDictionary<string, ReferencesEventsSink> _referencesEventsSinks =
193218
new Dictionary<string, ReferencesEventsSink>();
194219

195220
async void sink_ProjectAdded(object sender, DispatcherEventArgs<VBProject> e)
196221
{
197-
Debug.WriteLine(string.Format("Project '{0}' was added.", e.Item.Name));
222+
_logger.Debug("Project '{0}' was added.", e.Item.Name);
198223
if (e.Item.Protection == vbext_ProjectProtection.vbext_pp_locked)
199224
{
200-
Debug.WriteLine("Project is protected and will not be added to parser state.");
225+
_logger.Debug("Project is protected and will not be added to parser state.");
201226
return;
202227
}
203228

@@ -221,12 +246,12 @@ private void RegisterComponentsEventSink(VBComponents components, string project
221246
if (_componentsEventsSinks.ContainsKey(projectId))
222247
{
223248
// already registered - this is caused by the initial load+rename of a project in the VBE
224-
Debug.WriteLine("Components sink already registered.");
249+
_logger.Debug("Components sink already registered.");
225250
return;
226251
}
227252

228253
var connectionPointContainer = (IConnectionPointContainer)components;
229-
var interfaceId = typeof (_dispVBComponentsEvents).GUID;
254+
var interfaceId = typeof(_dispVBComponentsEvents).GUID;
230255

231256
IConnectionPoint connectionPoint;
232257
connectionPointContainer.FindConnectionPoint(ref interfaceId, out connectionPoint);
@@ -244,7 +269,7 @@ private void RegisterComponentsEventSink(VBComponents components, string project
244269
connectionPoint.Advise(componentsSink, out cookie);
245270

246271
_componentsEventsConnectionPoints.Add(projectId, Tuple.Create(connectionPoint, cookie));
247-
Debug.WriteLine("Components sink registered and advising.");
272+
_logger.Debug("Components sink registered and advising.");
248273
}
249274

250275
async void sink_ComponentSelected(object sender, DispatcherEventArgs<VBComponent> e)
@@ -254,7 +279,7 @@ async void sink_ComponentSelected(object sender, DispatcherEventArgs<VBComponent
254279
return;
255280
}
256281

257-
Debug.WriteLine(string.Format("Component '{0}' was selected.", e.Item.Name));
282+
_logger.Debug("Component '{0}' was selected.", e.Item.Name);
258283
// do something?
259284
}
260285

@@ -265,7 +290,7 @@ async void sink_ComponentRenamed(object sender, DispatcherRenamedEventArgs<VBCom
265290
return;
266291
}
267292

268-
Debug.WriteLine("Component '{0}' was renamed to '{1}'.", e.OldName, e.Item.Name);
293+
_logger.Debug("Component '{0}' was renamed to '{1}'.", e.OldName, e.Item.Name);
269294

270295
_parser.State.RemoveRenamedComponent(e.Item, e.OldName);
271296
}
@@ -277,7 +302,7 @@ async void sink_ComponentRemoved(object sender, DispatcherEventArgs<VBComponent>
277302
return;
278303
}
279304

280-
Debug.WriteLine(string.Format("Component '{0}' was removed.", e.Item.Name));
305+
_logger.Debug("Component '{0}' was removed.", e.Item.Name);
281306
_parser.State.ClearStateCache(e.Item, true);
282307
}
283308

@@ -288,7 +313,7 @@ async void sink_ComponentReloaded(object sender, DispatcherEventArgs<VBComponent
288313
return;
289314
}
290315

291-
Debug.WriteLine(string.Format("Component '{0}' was reloaded.", e.Item.Name));
316+
_logger.Debug("Component '{0}' was reloaded.", e.Item.Name);
292317
_parser.State.OnParseRequested(sender, e.Item);
293318
}
294319

@@ -299,7 +324,7 @@ async void sink_ComponentAdded(object sender, DispatcherEventArgs<VBComponent> e
299324
return;
300325
}
301326

302-
Debug.WriteLine(string.Format("Component '{0}' was added.", e.Item.Name));
327+
_logger.Debug("Component '{0}' was added.", e.Item.Name);
303328
_parser.State.OnParseRequested(sender, e.Item);
304329
}
305330

@@ -310,7 +335,7 @@ async void sink_ComponentActivated(object sender, DispatcherEventArgs<VBComponen
310335
return;
311336
}
312337

313-
Debug.WriteLine(string.Format("Component '{0}' was activated.", e.Item.Name));
338+
_logger.Debug("Component '{0}' was activated.", e.Item.Name);
314339
// do something?
315340
}
316341

@@ -321,7 +346,7 @@ async void sink_ProjectRenamed(object sender, DispatcherRenamedEventArgs<VBProje
321346
return;
322347
}
323348

324-
Debug.WriteLine("Project '{0}' (ID {1}) was renamed to '{2}'.", e.OldName, e.Item.HelpFile, e.Item.Name);
349+
_logger.Debug("Project '{0}' (ID {1}) was renamed to '{2}'.", e.OldName, e.Item.HelpFile, e.Item.Name);
325350
_parser.State.RemoveProject(e.Item.HelpFile);
326351
_parser.State.OnParseRequested(sender);
327352
}
@@ -333,7 +358,7 @@ async void sink_ProjectActivated(object sender, DispatcherEventArgs<VBProject> e
333358
return;
334359
}
335360

336-
Debug.WriteLine(string.Format("Project '{0}' was activated.", e.Item.Name));
361+
_logger.Debug("Project '{0}' was activated.", e.Item.Name);
337362
// do something?
338363
}
339364
#endregion
@@ -346,7 +371,7 @@ private void _stateBar_Refresh(object sender, EventArgs e)
346371

347372
private void Parser_StateChanged(object sender, EventArgs e)
348373
{
349-
Debug.WriteLine("App handles StateChanged ({0}), evaluating menu states...", _parser.State.Status);
374+
_logger.Debug("App handles StateChanged ({0}), evaluating menu states...", _parser.State.Status);
350375
_appMenus.EvaluateCanExecute(_parser.State);
351376
}
352377

@@ -436,7 +461,7 @@ public void Dispose()
436461
}
437462

438463
if (_autoSave != null)
439-
{
464+
{
440465
_autoSave.Dispose();
441466
_autoSave = null;
442467
}

RetailCoder.VBE/Common/DeclarationExtensions.cs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,7 @@ public static IEnumerable<Declaration> InScope(this IEnumerable<Declaration> dec
190190
public static IEnumerable<Declaration> FindInterfaces(this IEnumerable<Declaration> declarations)
191191
{
192192
var classes = declarations.Where(item => item.DeclarationType == DeclarationType.ClassModule);
193-
var interfaces = classes.Where(item => item.References.Any(reference =>
194-
reference.Context.Parent is VBAParser.ImplementsStmtContext));
195-
193+
var interfaces = classes.Where(item => ((ClassModuleDeclaration)item).Subtypes.Any(s => !s.IsBuiltIn));
196194
return interfaces;
197195
}
198196

@@ -233,8 +231,8 @@ public static IEnumerable<Declaration> FindBuiltInEventHandlers(this IEnumerable
233231
}
234232

235233
/// <summary>
236-
/// Gets the <see cref="Declaration"/> of the specified <see cref="type"/>,
237-
/// at the specified <see cref="selection"/>.
234+
/// Gets the <see cref="Declaration"/> of the specified <see cref="DeclarationType"/>,
235+
/// at the specified <see cref="QualifiedSelection"/>.
238236
/// Returns the declaration if selection is on an identifier reference.
239237
/// </summary>
240238
public static Declaration FindSelectedDeclaration(this IEnumerable<Declaration> declarations, QualifiedSelection selection, DeclarationType type, Func<Declaration, Selection> selector = null)
@@ -243,8 +241,8 @@ public static Declaration FindSelectedDeclaration(this IEnumerable<Declaration>
243241
}
244242

245243
/// <summary>
246-
/// Gets the <see cref="Declaration"/> of the specified <see cref="types"/>,
247-
/// at the specified <see cref="selection"/>.
244+
/// Gets the <see cref="Declaration"/> of the specified <see cref="DeclarationType"/>,
245+
/// at the specified <see cref="QualifiedSelection"/>.
248246
/// Returns the declaration if selection is on an identifier reference.
249247
/// </summary>
250248
public static Declaration FindSelectedDeclaration(this IEnumerable<Declaration> declarations, QualifiedSelection selection, IEnumerable<DeclarationType> types, Func<Declaration, Selection> selector = null)
@@ -365,7 +363,7 @@ private static IEnumerable<Declaration> GetTypeMembers(this IEnumerable<Declarat
365363
return declarations.Where(item => item.Project != null && item.ProjectId == type.ProjectId && item.ParentScope == type.Scope);
366364
}
367365

368-
/// <summary>
366+
/// <summary>
369367
/// Finds all class members that are interface implementation members.
370368
/// </summary>
371369
public static IEnumerable<Declaration> FindInterfaceImplementationMembers(this IEnumerable<Declaration> declarations)
@@ -532,7 +530,7 @@ public static Declaration FindInterface(this IEnumerable<Declaration> declaratio
532530
{
533531
foreach (var reference in declaration.References)
534532
{
535-
var implementsStmt = reference.Context.Parent as VBAParser.ImplementsStmtContext;
533+
var implementsStmt = ParserRuleContextHelper.GetParent<VBAParser.ImplementsStmtContext>(reference.Context);
536534

537535
if (implementsStmt == null) { continue; }
538536

RetailCoder.VBE/Common/Hotkeys/Hotkey.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Windows.Forms;
55
using System.Windows.Input;
66
using Rubberduck.Common.WinAPI;
7+
using NLog;
78

89
namespace Rubberduck.Common.Hotkeys
910
{
@@ -12,6 +13,7 @@ public class Hotkey : IHotkey
1213
private readonly string _key;
1314
private readonly ICommand _command;
1415
private readonly IntPtr _hWndVbe;
16+
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
1517

1618
public Hotkey(IntPtr hWndVbe, string key, ICommand command, Keys secondKey = Keys.None)
1719
{
@@ -82,13 +84,13 @@ private void HookKey(Keys key, uint shift)
8284
var success = User32.RegisterHotKey(_hWndVbe, hookId, shift, (uint)key);
8385
if (!success)
8486
{
85-
Debug.WriteLine(Rubberduck.UI.RubberduckUI.CommonHotkey_KeyNotRegistered, key);
87+
_logger.Debug(Rubberduck.UI.RubberduckUI.CommonHotkey_KeyNotRegistered, key);
8688
//throw new Win32Exception(Rubberduck.UI.RubberduckUI.CommonHotkey_KeyNotRegistered, key);
8789
}
8890

8991
HotkeyInfo = new HotkeyInfo(hookId, Combo);
9092
IsAttached = true;
91-
Debug.WriteLine("Hotkey '{0}' hooked successfully to command '{1}'", Key, Command.GetType()); //no translation needed for Debug.Writeline
93+
_logger.Debug("Hotkey '{0}' hooked successfully to command '{1}'", Key, Command.GetType()); //no translation needed for Debug.Writeline
9294
}
9395

9496
private static readonly IDictionary<char,uint> Modifiers = new Dictionary<char, uint>

RetailCoder.VBE/Common/RubberduckHooks.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using Rubberduck.Settings;
1212
using Rubberduck.UI.Command;
1313
using Rubberduck.UI.Command.Refactorings;
14+
using NLog;
1415

1516
namespace Rubberduck.Common
1617
{
@@ -28,6 +29,7 @@ public class RubberduckHooks : IRubberduckHooks
2829
private readonly IEnumerable<ICommand> _commands;
2930
private readonly IList<IAttachable> _hooks = new List<IAttachable>();
3031
private readonly IDictionary<RubberduckHotkey, ICommand> _mappings;
32+
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
3133

3234
public RubberduckHooks(VBE vbe, IGeneralConfigService config, IEnumerable<ICommand> commands)
3335
{
@@ -151,7 +153,7 @@ public void Attach()
151153
}
152154
catch (Win32Exception exception)
153155
{
154-
Debug.WriteLine(exception);
156+
_logger.Error(exception);
155157
}
156158
}
157159

@@ -172,7 +174,7 @@ public void Detach()
172174
}
173175
catch (Win32Exception exception)
174176
{
175-
Debug.WriteLine(exception);
177+
_logger.Error(exception);
176178
}
177179
IsAttached = false;
178180
}
@@ -182,12 +184,12 @@ private void hook_MessageReceived(object sender, HookEventArgs e)
182184
var hotkey = sender as IHotkey;
183185
if (hotkey != null)
184186
{
185-
Debug.WriteLine("Hotkey message received");
187+
_logger.Debug("Hotkey message received");
186188
hotkey.Command.Execute(null);
187189
return;
188190
}
189191

190-
Debug.WriteLine("Unknown message received");
192+
_logger.Debug("Unknown message received");
191193
OnMessageReceived(sender, e);
192194
}
193195

@@ -221,7 +223,7 @@ private IntPtr WindowProc(IntPtr hWnd, uint uMsg, IntPtr wParam, IntPtr lParam)
221223
}
222224
catch (Exception exception)
223225
{
224-
Debug.WriteLine(exception);
226+
_logger.Error(exception);
225227
}
226228

227229
return IntPtr.Zero;
@@ -244,7 +246,7 @@ private bool HandleHotkeyMessage(IntPtr wParam)
244246
}
245247
catch (Exception exception)
246248
{
247-
Debug.WriteLine(exception);
249+
_logger.Error(exception);
248250
}
249251
return processed;
250252
}

0 commit comments

Comments
 (0)