Skip to content

Commit eb9f700

Browse files
committed
Merge branch 'next' of https://github.com/rubberduck-vba/Rubberduck into Issue3829
2 parents eb91056 + 7a599fe commit eb9f700

Some content is hidden

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

46 files changed

+926
-346
lines changed

license renamed to LICENSE

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
GNU GENERAL PUBLIC LICENSE
1+
GNU GENERAL PUBLIC LICENSE
22
Version 3, 29 June 2007
33

44
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
@@ -631,8 +631,8 @@ to attach them to the start of each source file to most effectively
631631
state the exclusion of warranty; and each file should have at least
632632
the "copyright" line and a pointer to where the full notice is found.
633633

634-
{one line to give the program's name and a brief idea of what it does.}
635-
Copyright (C) {year} {name of author}
634+
<one line to give the program's name and a brief idea of what it does.>
635+
Copyright (C) <year> <name of author>
636636

637637
This program is free software: you can redistribute it and/or modify
638638
it under the terms of the GNU General Public License as published by
@@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail.
652652
If the program does terminal interaction, make it output a short
653653
notice like this when it starts in an interactive mode:
654654

655-
{project} Copyright (C) {year} {fullname}
655+
<program> Copyright (C) <year> <name of author>
656656
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657657
This is free software, and you are welcome to redistribute it
658658
under certain conditions; type `show c' for details.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ If you like this project and would like to thank its contributors, you are welco
1919
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/rubberduck-vba/Rubberduck.svg)](http://isitmaintained.com/project/rubberduck-vba/Rubberduck "Average time to resolve an issue") [![Percentage of issues still open](http://isitmaintained.com/badge/open/rubberduck-vba/Rubberduck.svg)](http://isitmaintained.com/project/rubberduck-vba/Rubberduck "Percentage of issues still open")
2020

2121
> **[rubberduckvba.com](http://rubberduckvba.com)** [Wiki](https://github.com/retailcoder/Rubberduck/wiki) [Rubberduck News](https://rubberduckvba.wordpress.com/)
22-
> contact@rubberduckvba.com
22+
> devs@rubberduckvba.com
2323
> Follow [@rubberduckvba](https://twitter.com/rubberduckvba) on Twitter
2424
2525
---

Rubberduck.API/API/VBA/ParserState.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
using Rubberduck.Parsing.Symbols;
1212
using Rubberduck.Parsing.UIContext;
1313
using Rubberduck.VBEditor.ComManagement;
14+
using Rubberduck.VBEditor.Events;
1415
using Rubberduck.VBEditor.SafeComWrappers.VBA;
16+
using Rubberduck.VBEditor.Utility;
1517

1618
namespace Rubberduck.API.VBA
1719
{
@@ -50,11 +52,13 @@ public sealed class ParserState : IParserState, IDisposable
5052
private AttributeParser _attributeParser;
5153
private ParseCoordinator _parser;
5254
private VBE _vbe;
55+
private IVBEEvents _vbeEvents;
56+
private readonly IUiDispatcher _dispatcher;
5357

5458
public ParserState()
5559
{
56-
UiDispatcher.Initialize();
57-
ComMessagePumper.Initialize();
60+
UiContextProvider.Initialize();
61+
_dispatcher = new UiDispatcher(UiContextProvider.Instance());
5862
}
5963

6064
public void Initialize(Microsoft.Vbe.Interop.VBE vbe)
@@ -65,9 +69,10 @@ public void Initialize(Microsoft.Vbe.Interop.VBE vbe)
6569
}
6670

6771
_vbe = new VBE(vbe);
72+
_vbeEvents = VBEEvents.Initialize(_vbe);
6873
var declarationFinderFactory = new ConcurrentlyConstructedDeclarationFinderFactory();
6974
var projectRepository = new ProjectsRepository(_vbe);
70-
_state = new RubberduckParserState(null, projectRepository, declarationFinderFactory);
75+
_state = new RubberduckParserState(null, projectRepository, declarationFinderFactory, _vbeEvents);
7176
_state.StateChanged += _state_StateChanged;
7277

7378
var exporter = new ModuleExporter();
@@ -144,7 +149,7 @@ public void Parse()
144149
public void BeginParse()
145150
{
146151
// non-blocking call
147-
UiDispatcher.Invoke(() => _state.OnParseRequested(this));
152+
_dispatcher.Invoke(() => _state.OnParseRequested(this));
148153
}
149154

150155
public event Action OnParsed;
@@ -164,19 +169,19 @@ private void _state_StateChanged(object sender, EventArgs e)
164169
var errorHandler = OnError;
165170
if (_state.Status == Parsing.VBA.ParserState.Error && errorHandler != null)
166171
{
167-
UiDispatcher.Invoke(errorHandler.Invoke);
172+
_dispatcher.Invoke(errorHandler.Invoke);
168173
}
169174

170175
var parsedHandler = OnParsed;
171176
if (_state.Status == Parsing.VBA.ParserState.Parsed && parsedHandler != null)
172177
{
173-
UiDispatcher.Invoke(parsedHandler.Invoke);
178+
_dispatcher.Invoke(parsedHandler.Invoke);
174179
}
175180

176181
var readyHandler = OnReady;
177182
if (_state.Status == Parsing.VBA.ParserState.Ready && readyHandler != null)
178183
{
179-
UiDispatcher.Invoke(readyHandler.Invoke);
184+
_dispatcher.Invoke(readyHandler.Invoke);
180185
}
181186
}
182187

Rubberduck.Core/App.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using Rubberduck.UI.Command;
1616
using Rubberduck.VBEditor.ComManagement;
1717
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
18+
using Rubberduck.VBEditor.Utility;
1819
using Rubberduck.VersionCheck;
1920
using Application = System.Windows.Forms.Application;
2021

@@ -50,8 +51,7 @@ public App(IVBE vbe,
5051

5152
_configService.SettingsChanged += _configService_SettingsChanged;
5253

53-
UiDispatcher.Initialize();
54-
ComMessagePumper.Initialize();
54+
UiContextProvider.Initialize();
5555
}
5656

5757
private void _configService_SettingsChanged(object sender, ConfigurationChangedEventArgs e)

Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerViewModel.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
using Rubberduck.UI;
1515
using Rubberduck.UI.CodeExplorer.Commands;
1616
using Rubberduck.UI.Command;
17-
using Rubberduck.UI.Command.MenuItems;
1817
using Rubberduck.VBEditor;
1918
using Rubberduck.VBEditor.SafeComWrappers;
2019
using System.Windows;
@@ -32,17 +31,24 @@ public sealed class CodeExplorerViewModel : ViewModelBase, IDisposable
3231
private readonly IConfigProvider<WindowSettings> _windowSettingsProvider;
3332
private readonly GeneralSettings _generalSettings;
3433
private readonly WindowSettings _windowSettings;
34+
private readonly IUiDispatcher _uiDispatcher;
3535

3636
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
3737

38-
public CodeExplorerViewModel(FolderHelper folderHelper, RubberduckParserState state, List<CommandBase> commands,
39-
IConfigProvider<GeneralSettings> generalSettingsProvider, IConfigProvider<WindowSettings> windowSettingsProvider)
38+
public CodeExplorerViewModel(
39+
FolderHelper folderHelper,
40+
RubberduckParserState state,
41+
List<CommandBase> commands,
42+
IConfigProvider<GeneralSettings> generalSettingsProvider,
43+
IConfigProvider<WindowSettings> windowSettingsProvider,
44+
IUiDispatcher uiDispatcher)
4045
{
4146
_folderHelper = folderHelper;
4247
_state = state;
4348
_state.StateChanged += HandleStateChanged;
4449
_state.ModuleStateChanged += ParserState_ModuleStateChanged;
4550
_windowSettingsProvider = windowSettingsProvider;
51+
_uiDispatcher = uiDispatcher;
4652

4753
if (generalSettingsProvider != null)
4854
{
@@ -388,7 +394,7 @@ private void ParserState_ModuleStateChanged(object sender, ParseProgressEventArg
388394
var projectName = componentProject.Name;
389395
var folderNode = projectNode.Items.FirstOrDefault(f => f is CodeExplorerCustomFolderViewModel && f.Name == projectName);
390396

391-
UiDispatcher.Invoke(() =>
397+
_uiDispatcher.Invoke(() =>
392398
{
393399
try
394400
{

Rubberduck.Core/Refactorings/RemoveParameters/RemoveParametersRefactoring.cs

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
using Rubberduck.Parsing.VBA;
1111
using Rubberduck.UI;
1212
using Rubberduck.VBEditor;
13-
using Rubberduck.VBEditor.ComManagement;
1413
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
15-
using Antlr4.Runtime;
1614

1715
namespace Rubberduck.Refactorings.RemoveParameters
1816
{
@@ -22,13 +20,11 @@ public class RemoveParametersRefactoring : IRefactoring
2220
private readonly IRefactoringPresenterFactory<IRemoveParametersPresenter> _factory;
2321
private RemoveParametersModel _model;
2422
private readonly HashSet<IModuleRewriter> _rewriters = new HashSet<IModuleRewriter>();
25-
private readonly IProjectsProvider _projectsProvider;
2623

27-
public RemoveParametersRefactoring(IVBE vbe, IRefactoringPresenterFactory<IRemoveParametersPresenter> factory, IProjectsProvider projectsProvider)
24+
public RemoveParametersRefactoring(IVBE vbe, IRefactoringPresenterFactory<IRemoveParametersPresenter> factory)
2825
{
2926
_vbe = vbe;
3027
_factory = factory;
31-
_projectsProvider = projectsProvider;
3228
}
3329

3430
public void Refactor()
@@ -103,7 +99,10 @@ public void QuickFix(RubberduckParserState state, QualifiedSelection selection)
10399

104100
private void RemoveParameters()
105101
{
106-
if (_model.TargetDeclaration == null) { throw new NullReferenceException("Parameter is null"); }
102+
if (_model.TargetDeclaration == null)
103+
{
104+
throw new NullReferenceException("Parameter is null");
105+
}
107106

108107
AdjustReferences(_model.TargetDeclaration.References, _model.TargetDeclaration);
109108
AdjustSignatures();
@@ -137,19 +136,27 @@ private void AdjustReferences(IEnumerable<IdentifierReference> references, Decla
137136

138137
if (argumentList == null)
139138
{
140-
continue;
139+
var whitespaceIndexExpression =
140+
reference.Context.GetAncestor<VBAParser.WhitespaceIndexExprContext>();
141+
if (whitespaceIndexExpression != null)
142+
{
143+
argumentList = whitespaceIndexExpression.GetChild<VBAParser.ArgumentListContext>();
144+
}
141145
}
142146

143-
using (var module = _projectsProvider.Component(reference.QualifiedModuleName).CodeModule)
147+
if (argumentList == null)
144148
{
145-
RemoveCallArguments(argumentList, module);
149+
continue;
146150
}
151+
152+
RemoveCallArguments(argumentList, reference.QualifiedModuleName);
147153
}
148154
}
149155

150-
private void RemoveCallArguments(VBAParser.ArgumentListContext argList, ICodeModule module)
156+
private void RemoveCallArguments(VBAParser.ArgumentListContext argList, QualifiedModuleName module)
151157
{
152-
var rewriter = _model.State.GetRewriter(module.Parent);
158+
var rewriter = _model.State.GetRewriter(module);
159+
_rewriters.Add(rewriter);
153160

154161
var args = argList.children.OfType<VBAParser.ArgumentContext>().ToList();
155162
for (var i = 0; i < _model.Parameters.Count; i++)
@@ -161,6 +168,8 @@ private void RemoveCallArguments(VBAParser.ArgumentListContext argList, ICodeMod
161168

162169
if (_model.Parameters[i].IsParamArray)
163170
{
171+
//The following code works because it is neither allowed to use both named arguments
172+
//and a ParamArray nor optional arguments and a ParamArray.
164173
var index = i == 0 ? 0 : argList.children.IndexOf(args[i - 1]) + 1;
165174
for (var j = index; j < argList.children.Count; j++)
166175
{
@@ -169,7 +178,7 @@ private void RemoveCallArguments(VBAParser.ArgumentListContext argList, ICodeMod
169178
break;
170179
}
171180

172-
if (args.Count > i && args[i].positionalArgument() != null)
181+
if (args.Count > i && (args[i].positionalArgument() != null || args[i].missingArgument() != null))
173182
{
174183
rewriter.Remove(args[i]);
175184
}

Rubberduck.Core/Rubberduck.Core.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,9 +475,6 @@
475475
<Compile Include="UnitTesting\IFakes.cs" />
476476
<Compile Include="UnitTesting\ReturnTypeConverter.cs" />
477477
<Compile Include="UnitTesting\PermissiveObjectComparer.cs" />
478-
<Compile Include="VBERuntime\RegistryWrapper.cs" />
479-
<Compile Include="VBERuntime\IVBESettings.cs" />
480-
<Compile Include="VBERuntime\VBESettings.cs" />
481478
<Compile Include="VersionCheck\IVersionCheck.cs" />
482479
<Compile Include="UI\Command\MenuItems\CommandBars\AppCommandBarBase.cs" />
483480
<Compile Include="UI\Command\MenuItems\CommandBars\ContextSelectionLabelMenuItem.cs" />

Rubberduck.Core/Settings/GeneralSettings.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ public int MinimumLogLevel
5555

5656
public List<ExperimentalFeatures> EnableExperimentalFeatures { get; set; } = new List<ExperimentalFeatures>();
5757

58+
public GeneralSettings()
59+
{
60+
//Enforce non-default default value for members
61+
//In other words, if we want a bool to default to
62+
//true, it must be set here for correct behavior
63+
CompileBeforeParse = true;
64+
}
65+
5866
public bool Equals(GeneralSettings other)
5967
{
6068
return other != null &&

Rubberduck.Core/UI/Command/FindAllImplementationsCommand.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,13 @@ public class FindAllImplementationsCommand : CommandBase, IDisposable
2828
private readonly ISearchResultsWindowViewModel _viewModel;
2929
private readonly SearchResultPresenterInstanceManager _presenterService;
3030
private readonly IVBE _vbe;
31+
private readonly IUiDispatcher _uiDispatcher;
3132

3233
private new static readonly Logger Logger = LogManager.GetCurrentClassLogger();
3334

3435
public FindAllImplementationsCommand(INavigateCommand navigateCommand, IMessageBox messageBox,
3536
RubberduckParserState state, IVBE vbe, ISearchResultsWindowViewModel viewModel,
36-
SearchResultPresenterInstanceManager presenterService)
37+
SearchResultPresenterInstanceManager presenterService, IUiDispatcher uiDispatcher)
3738
: base(LogManager.GetCurrentClassLogger())
3839
{
3940
_navigateCommand = navigateCommand;
@@ -42,6 +43,7 @@ public FindAllImplementationsCommand(INavigateCommand navigateCommand, IMessageB
4243
_vbe = vbe;
4344
_viewModel = viewModel;
4445
_presenterService = presenterService;
46+
_uiDispatcher = uiDispatcher;
4547

4648
_state.StateChanged += _state_StateChanged;
4749
}
@@ -62,7 +64,7 @@ private void _state_StateChanged(object sender, ParserStateEventArgs e)
6264

6365
if (_viewModel == null) { return; }
6466

65-
UiDispatcher.InvokeAsync(UpdateTab);
67+
_uiDispatcher.InvokeAsync(UpdateTab);
6668
}
6769

6870
private void UpdateTab()

Rubberduck.Core/UI/Command/FindAllReferencesCommand.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using Rubberduck.Parsing.Symbols;
77
using Rubberduck.Parsing.UIContext;
88
using Rubberduck.Parsing.VBA;
9-
using Rubberduck.UI.Command.MenuItems;
109
using Rubberduck.UI.Controls;
1110
using Rubberduck.VBEditor;
1211
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
@@ -25,10 +24,11 @@ public class FindAllReferencesCommand : CommandBase, IDisposable
2524
private readonly ISearchResultsWindowViewModel _viewModel;
2625
private readonly SearchResultPresenterInstanceManager _presenterService;
2726
private readonly IVBE _vbe;
27+
private readonly IUiDispatcher _uiDispatcher;
2828

2929
public FindAllReferencesCommand(INavigateCommand navigateCommand, IMessageBox messageBox,
3030
RubberduckParserState state, IVBE vbe, ISearchResultsWindowViewModel viewModel,
31-
SearchResultPresenterInstanceManager presenterService)
31+
SearchResultPresenterInstanceManager presenterService, IUiDispatcher uiDispatcher)
3232
: base(LogManager.GetCurrentClassLogger())
3333
{
3434
_navigateCommand = navigateCommand;
@@ -37,6 +37,7 @@ public FindAllReferencesCommand(INavigateCommand navigateCommand, IMessageBox me
3737
_vbe = vbe;
3838
_viewModel = viewModel;
3939
_presenterService = presenterService;
40+
_uiDispatcher = uiDispatcher;
4041

4142
_state.StateChanged += _state_StateChanged;
4243
}
@@ -57,7 +58,7 @@ private void _state_StateChanged(object sender, ParserStateEventArgs e)
5758

5859
if (_viewModel == null) { return; }
5960

60-
UiDispatcher.InvokeAsync(UpdateTab);
61+
_uiDispatcher.InvokeAsync(UpdateTab);
6162
}
6263

6364
private void UpdateTab()

0 commit comments

Comments
 (0)