Skip to content

Commit f78d8ef

Browse files
committed
Merge branch 'rubberduck-vba/next' into next
2 parents d3263e5 + 2a09ccf commit f78d8ef

File tree

287 files changed

+4576
-19467
lines changed

Some content is hidden

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

287 files changed

+4576
-19467
lines changed

License.rtf

Lines changed: 398 additions & 820 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ If you like this project and would like to thank its contributors, you are welco
88
[![GoFundMe campaign](https://user-images.githubusercontent.com/5751684/29191799-e3d20b72-7dec-11e7-8ec6-0c69da4a3135.png)](https://www.gofundme.com/rubberduckvba)
99
-->
1010

11-
Branch | Description | Build Status |
12-
|------------|---|--------------|
13-
| **master** | The last released build | ![master branch build status][masterBuildStatus] |
14-
| **next** | The current build (dev) | ![next branch build status][nextBuildStatus] |
11+
|Branch | Description | Build Status | Download link |
12+
|------------|---|--------------|-|
13+
| **master** | The last released build | ![master branch build status][masterBuildStatus] | [stable](https://github.com/rubberduck-vba/Rubberduck/releases/latest) |
14+
| **next** | The current build (dev) | ![next branch build status][nextBuildStatus] | [dev](https://github.com/rubberduck-vba/Rubberduck/releases) |
1515

1616
[nextBuildStatus]:https://ci.appveyor.com/api/projects/status/we3pdnkeebo4nlck/branch/next?svg=true
1717
[masterBuildStatus]:https://ci.appveyor.com/api/projects/status/we3pdnkeebo4nlck/branch/master?svg=true
@@ -26,8 +26,10 @@ Branch | Description | Build Status |
2626

2727
* [Attributions](https://github.com/rubberduck-vba/Rubberduck/blob/next/docs/Attributions.md)
2828
* [About](https://github.com/rubberduck-vba/Rubberduck/blob/next/docs/About.md)
29-
* [Getting Started](https://github.com/rubberduck-vba/Rubberduck/blob/next/docs/GettingStarted.md)
29+
* [Installing](https://github.com/rubberduck-vba/Rubberduck/wiki/Installing)
30+
* [Getting Started](https://github.com/rubberduck-vba/Rubberduck/blob/next/docs/GettingStarted.md) using Rubberduck
3031
* [Contributing](https://github.com/rubberduck-vba/Rubberduck/blob/next/CONTRIBUTING.md)
32+
* [User Testimonials](https://github.com/rubberduck-vba/Rubberduck/blob/next/thanks.md)
3133

3234
---
3335

RetailCoder.VBE/API/VBA/ParserState.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
using Rubberduck.Parsing.VBA;
1111
using Rubberduck.UI.Command.MenuItems;
1212
using Rubberduck.Parsing.Symbols;
13+
using Rubberduck.Parsing.UIContext;
1314
using Rubberduck.VBEditor.ComManagement;
15+
using Rubberduck.VBEditor.Events;
1416
using Rubberduck.VBEditor.SafeComWrappers.VBA;
1517

1618
namespace Rubberduck.API.VBA
@@ -54,6 +56,7 @@ public sealed class ParserState : IParserState, IDisposable
5456
public ParserState()
5557
{
5658
UiDispatcher.Initialize();
59+
ComMessagePumper.Initialize();
5760
}
5861

5962
public void Initialize(Microsoft.Vbe.Interop.VBE vbe)

RetailCoder.VBE/App.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
using System.Globalization;
1212
using System.Windows.Forms;
1313
using Rubberduck.Parsing.Inspections.Resources;
14+
using Rubberduck.Parsing.UIContext;
1415
using Rubberduck.UI.Command;
16+
using Rubberduck.VBEditor.ComManagement;
1517
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
1618
using Rubberduck.VersionCheck;
1719
using Application = System.Windows.Forms.Application;
@@ -49,6 +51,7 @@ public App(IVBE vbe,
4951
_configService.SettingsChanged += _configService_SettingsChanged;
5052

5153
UiDispatcher.Initialize();
54+
ComMessagePumper.Initialize();
5255
}
5356

5457
private void _configService_SettingsChanged(object sender, ConfigurationChangedEventArgs e)

RetailCoder.VBE/Extension.cs

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ public class _Extension : IDTExtensibility2
4242

4343
private IWindsorContainer _container;
4444
private App _app;
45-
private IComSafe _comSafe;
4645
private readonly Logger _logger = LogManager.GetCurrentClassLogger();
4746

4847
public void OnAddInsUpdate(ref Array custom) { }
@@ -52,9 +51,6 @@ public void OnConnection(object Application, ext_ConnectMode ConnectMode, object
5251
{
5352
try
5453
{
55-
ComSafeManager.ResetComSafe();
56-
_comSafe = ComSafeManager.GetCurrentComSafe();
57-
5854
if (Application is Microsoft.Vbe.Interop.VBE vbe1)
5955
{
6056
_ide = new VBEditor.SafeComWrappers.VBA.VBE(vbe1);
@@ -270,18 +266,6 @@ private void ShutdownAddIn()
270266
_container.Dispose();
271267
_container = null;
272268
}
273-
274-
if (_comSafe != null)
275-
{
276-
_logger.Log(LogLevel.Trace, "Disposing COM safe...");
277-
_comSafe.Dispose();
278-
_comSafe = null;
279-
_addin = null;
280-
_ide = null;
281-
}
282-
283-
_isInitialized = false;
284-
_logger.Log(LogLevel.Info, "No exceptions were thrown.");
285269
}
286270
catch (Exception e)
287271
{
@@ -291,11 +275,30 @@ private void ShutdownAddIn()
291275
}
292276
finally
293277
{
294-
_logger.Log(LogLevel.Trace, "Unregistering AppDomain handlers....");
295-
currentDomain.AssemblyResolve -= LoadFromSameFolder;
296-
currentDomain.UnhandledException -= HandlAppDomainException;
297-
_logger.Log(LogLevel.Trace, "Done. Main Shutdown completed. Toolwindows follow. Quack!");
298-
_isInitialized = false;
278+
try
279+
{
280+
_logger.Log(LogLevel.Trace, "Disposing COM safe...");
281+
ComSafeManager.DisposeAndResetComSafe();
282+
_addin = null;
283+
_ide = null;
284+
285+
_isInitialized = false;
286+
_logger.Log(LogLevel.Info, "No exceptions were thrown.");
287+
}
288+
catch (Exception e)
289+
{
290+
_logger.Error(e);
291+
_logger.Log(LogLevel.Warn, "Exception disposing the ComSafe has been swallowed.");
292+
//throw; // <<~ uncomment to crash the process
293+
}
294+
finally
295+
{
296+
_logger.Log(LogLevel.Trace, "Unregistering AppDomain handlers....");
297+
currentDomain.AssemblyResolve -= LoadFromSameFolder;
298+
currentDomain.UnhandledException -= HandlAppDomainException;
299+
_logger.Log(LogLevel.Trace, "Done. Main Shutdown completed. Toolwindows follow. Quack!");
300+
_isInitialized = false;
301+
}
299302
}
300303
}
301304
}

RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerProjectViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public CodeExplorerProjectViewModel(FolderHelper folderHelper, Declaration decla
3636
FillFolders(declarations.ToList());
3737
Items = _folderTree.Items.ToList();
3838

39-
_icon = Declaration.Project.Protection == ProjectProtection.Locked
39+
_icon = Declaration.Project?.Protection == ProjectProtection.Locked
4040
? GetImageSource(resx.lock__exclamation)
4141
: GetImageSource(resx.ObjectLibrary);
4242
}

RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerViewModel.cs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
using Rubberduck.VBEditor;
1919
using Rubberduck.VBEditor.SafeComWrappers;
2020
using System.Windows;
21+
using Rubberduck.Parsing.UIContext;
2122

2223
// ReSharper disable CanBeReplacedWithTryCastAndCheckForNull
2324
// ReSharper disable ExplicitCallerInfoArgument
@@ -91,10 +92,7 @@ public CodeExplorerViewModel(FolderHelper folderHelper, RubberduckParserState st
9192
}
9293

9394
PrintCommand = commands.OfType<PrintCommand>().SingleOrDefault();
94-
95-
CommitCommand = commands.OfType<CommitCommand>().SingleOrDefault();
96-
UndoCommand = commands.OfType<UndoCommand>().SingleOrDefault();
97-
95+
9896
CopyResultsCommand = commands.OfType<CopyResultsCommand>().SingleOrDefault();
9997

10098
SetNameSortCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), param =>
@@ -362,7 +360,7 @@ private void UpdateNodes(IEnumerable<CodeExplorerItemViewModel> oldList, IEnumer
362360
}
363361
}
364362

365-
private void ParserState_ModuleStateChanged(object sender, Parsing.ParseProgressEventArgs e)
363+
private void ParserState_ModuleStateChanged(object sender, ParseProgressEventArgs e)
366364
{
367365
// if we are resolving references, we already have the declarations and don't need to display error
368366
if (!(e.State == ParserState.Error ||
@@ -375,7 +373,7 @@ private void ParserState_ModuleStateChanged(object sender, Parsing.ParseProgress
375373
var componentProject = _state.ProjectsProvider.Project(e.Module.ProjectId);
376374
{
377375
var projectNode = Projects.OfType<CodeExplorerProjectViewModel>()
378-
.FirstOrDefault(p => p.Declaration.Project.Equals(componentProject));
376+
.FirstOrDefault(p => p.Declaration.Project?.Equals(componentProject) ?? false);
379377

380378
if (projectNode == null)
381379
{
@@ -424,7 +422,7 @@ private Declaration CreateDeclaration(QualifiedModuleName module)
424422
{
425423
var projectDeclaration =
426424
_state.DeclarationFinder.UserDeclarations(DeclarationType.Project)
427-
.FirstOrDefault(item => item.Project.ProjectId == module.ProjectId);
425+
.FirstOrDefault(item => item.ProjectId == module.ProjectId);
428426

429427
if (module.ComponentType == ComponentType.StandardModule)
430428
{
@@ -533,9 +531,6 @@ private void SwitchNodeState(CodeExplorerItemViewModel node, bool expandedState)
533531
public CommandBase RemoveCommand { get; }
534532

535533
public CommandBase PrintCommand { get; }
536-
537-
public CommandBase CommitCommand { get; }
538-
public CommandBase UndoCommand { get; }
539534

540535
private readonly CommandBase _externalRemoveCommand;
541536

@@ -554,9 +549,7 @@ private void ExecuteRemoveComand(object param)
554549
public Visibility ExportVisibility => CanExecuteExportAllCommand ? Visibility.Collapsed : Visibility.Visible;
555550

556551
public Visibility ExportAllVisibility => CanExecuteExportAllCommand ? Visibility.Visible : Visibility.Collapsed;
557-
558-
public bool EnableSourceControl => _generalSettings.EnableExperimentalFeatures.Any(a => a.Key == RubberduckUI.GeneralSettings_EnableSourceControl);
559-
552+
560553
public Visibility TreeViewVisibility => Projects == null || Projects.Count == 0 ? Visibility.Collapsed : Visibility.Visible;
561554

562555
public Visibility EmptyUIRefreshMessageVisibility => _isBusy ? Visibility.Hidden : Visibility.Visible;

RetailCoder.VBE/Navigation/RegexSearchReplace/RegexSearchReplace.cs

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ private List<RegexSearchResult> SearchSelection(string searchPattern)
9696
{
9797
using (var pane = _vbe.ActiveCodePane)
9898
{
99+
if (pane == null || pane.IsWrappingNullReference)
100+
{
101+
return new List<RegexSearchResult>();
102+
}
103+
99104
using (var module = pane.CodeModule)
100105
{
101106
var results = GetResultsFromModule(module, searchPattern);
@@ -119,21 +124,22 @@ private List<RegexSearchResult> SearchCurrentBlock(string searchPattern)
119124
var state = _parser.State;
120125
using (var pane = _vbe.ActiveCodePane)
121126
{
127+
if (pane == null || pane.IsWrappingNullReference)
128+
{
129+
return new List<RegexSearchResult>();
130+
}
131+
122132
using (var module = pane.CodeModule)
123133
{
124134
var results = GetResultsFromModule(module, searchPattern);
125135

126-
using (var moduleParent = module.Parent)
127-
{
128-
var qualifiedSelection =
129-
new QualifiedSelection(new QualifiedModuleName(moduleParent), pane.Selection);
130-
dynamic block = state.AllDeclarations.FindTarget(qualifiedSelection, declarationTypes).Context
131-
.Parent;
132-
var selection = new Selection(block.Start.Line, block.Start.Column, block.Stop.Line,
133-
block.Stop.Column);
134-
135-
return results.Where(r => selection.Contains(r.Selection)).ToList();
136-
}
136+
var qualifiedSelection = pane.GetQualifiedSelection();
137+
dynamic block = state.AllDeclarations.FindTarget(qualifiedSelection.Value, declarationTypes).Context
138+
.Parent;
139+
var selection = new Selection(block.Start.Line, block.Start.Column, block.Stop.Line,
140+
block.Stop.Column);
141+
142+
return results.Where(r => selection.Contains(r.Selection)).ToList();
137143
}
138144
}
139145
}
@@ -142,6 +148,11 @@ private List<RegexSearchResult> SearchCurrentFile(string searchPattern)
142148
{
143149
using (var pane = _vbe.ActiveCodePane)
144150
{
151+
if (pane == null || pane.IsWrappingNullReference)
152+
{
153+
return new List<RegexSearchResult>();
154+
}
155+
145156
using (var codeModule = pane.CodeModule)
146157
{
147158
return GetResultsFromModule(codeModule, searchPattern).ToList();

RetailCoder.VBE/Properties/Settings.Designer.cs

Lines changed: 19 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)