Skip to content

Commit 3f125c1

Browse files
committed
Merge remote-tracking branch 'upstream/next' into rkapka-master
# Conflicts: # RubberduckTests/RubberduckTests.csproj
2 parents c7c23f2 + 0fdf379 commit 3f125c1

File tree

112 files changed

+4326
-1075
lines changed

Some content is hidden

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

112 files changed

+4326
-1075
lines changed

Rubberduck.API/VBA/Parser.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Runtime.InteropServices;
77
using System.Threading;
88
using Rubberduck.Common;
9+
using Rubberduck.Parsing.ComReflection;
910
using Rubberduck.Parsing.PreProcessing;
1011
using Rubberduck.Parsing.Rewriter;
1112
using Rubberduck.Parsing.Symbols.DeclarationLoaders;
@@ -116,7 +117,9 @@ internal Parser(object vbe) : this()
116117
var parserStateManager = new ParserStateManager(_state);
117118
var referenceRemover = new ReferenceRemover(_state, moduleToModuleReferenceManager);
118119
var supertypeClearer = new SupertypeClearer(_state);
119-
var comSynchronizer = new COMReferenceSynchronizer(_state, parserStateManager);
120+
var comLibraryProvider = new ComLibraryProvider();
121+
var referencedDeclarationsCollector = new LibraryReferencedDeclarationsCollector(comLibraryProvider);
122+
var comSynchronizer = new COMReferenceSynchronizer(_state, parserStateManager, projectRepository, referencedDeclarationsCollector);
120123
var builtInDeclarationLoader = new BuiltInDeclarationLoader(
121124
_state,
122125
new List<ICustomDeclarationLoader>

Rubberduck.CodeAnalysis/Inspections/Concrete/EmptyModuleInspection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public override bool VisitModuleDeclarations(VBAParser.ModuleDeclarationsContext
8787

8888
public override bool VisitModuleDeclarationsElement(VBAParser.ModuleDeclarationsElementContext context)
8989
{
90-
return context.variableStmt() == null
90+
return context.moduleVariableStmt() == null
9191
&& context.constStmt() == null
9292
&& context.enumerationStmt() == null
9393
&& context.udtDeclaration() == null

Rubberduck.CodeAnalysis/Inspections/Concrete/ModuleScopeDimKeywordInspection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public void ClearContexts()
4545

4646
public override void ExitVariableStmt([NotNull] VBAParser.VariableStmtContext context)
4747
{
48-
if (context.DIM() != null && context.Parent is VBAParser.ModuleDeclarationsElementContext)
48+
if (context.DIM() != null && context.TryGetAncestor<VBAParser.ModuleDeclarationsElementContext>(out _))
4949
{
5050
_contexts.Add(new QualifiedContext<ParserRuleContext>(CurrentModuleName, context));
5151
}

Rubberduck.Core/App.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,13 @@ public void Startup()
116116

117117
CheckForLegacyIndenterSettings();
118118
_appMenus.Initialize();
119-
_hooks.HookHotkeys(); // need to hook hotkeys before we localize menus, to correctly display ShortcutTexts
119+
_hooks.HookHotkeys(); // need to hook hotkeys before we localize menus, to correctly display ShortcutTexts
120120
_appMenus.Localize();
121121

122122
if (_config.UserSettings.GeneralSettings.CanCheckVersion)
123123
{
124124
_checkVersionCommand.Execute(null);
125-
}
125+
}
126126
}
127127

128128
public void Shutdown()

Rubberduck.Core/AppMenu.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4-
using System.Threading;
54
using NLog;
65
using Rubberduck.Parsing;
76
using Rubberduck.Parsing.VBA;
@@ -63,6 +62,7 @@ public void Localize()
6362
{
6463
_stateBar.Localize();
6564
_stateBar.SetStatusLabelCaption(_parser.State.Status);
65+
6666
foreach (var menu in _menus)
6767
{
6868
menu.Localize();

Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerComponentViewModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ public bool IsTestModule
164164
{ ComponentType.VBForm, DeclarationType.VbForm },
165165
{ ComponentType.MDIForm, DeclarationType.MdiForm},
166166
{ ComponentType.UserControl, DeclarationType.UserControl},
167+
{ ComponentType.DocObject, DeclarationType.DocObject},
167168
{ ComponentType.ResFile, DeclarationType.ResFile},
168169
{ ComponentType.RelatedDocument, DeclarationType.RelatedDocument},
169170
{ ComponentType.PropPage, DeclarationType.PropPage},

Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerViewModel.cs

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using Rubberduck.VBEditor.SafeComWrappers;
2020
using System.Windows;
2121
using Rubberduck.Parsing.UIContext;
22+
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
2223

2324
// ReSharper disable CanBeReplacedWithTryCastAndCheckForNull
2425
// ReSharper disable ExplicitCallerInfoArgument
@@ -33,6 +34,7 @@ public sealed class CodeExplorerViewModel : ViewModelBase, IDisposable
3334
private readonly GeneralSettings _generalSettings;
3435
private readonly WindowSettings _windowSettings;
3536
private readonly IUiDispatcher _uiDispatcher;
37+
private readonly VBEKind _vbeKind;
3638

3739
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
3840

@@ -42,14 +44,16 @@ public CodeExplorerViewModel(
4244
List<CommandBase> commands,
4345
IConfigProvider<GeneralSettings> generalSettingsProvider,
4446
IConfigProvider<WindowSettings> windowSettingsProvider,
45-
IUiDispatcher uiDispatcher)
47+
IUiDispatcher uiDispatcher,
48+
IVBE vbe)
4649
{
4750
_folderHelper = folderHelper;
4851
_state = state;
4952
_state.StateChanged += HandleStateChanged;
5053
_state.ModuleStateChanged += ParserState_ModuleStateChanged;
5154
_windowSettingsProvider = windowSettingsProvider;
5255
_uiDispatcher = uiDispatcher;
56+
_vbeKind = vbe.Kind;
5357

5458
if (generalSettingsProvider != null)
5559
{
@@ -68,15 +72,19 @@ public CodeExplorerViewModel(
6872
o => reparseCommand.Execute(o),
6973
o => !IsBusy && reparseCommand != null && reparseCommand.CanExecute(o));
7074

71-
OpenCommand = commands.OfType<UI.CodeExplorer.Commands.OpenCommand>().SingleOrDefault();
75+
OpenCommand = commands.OfType<OpenCommand>().SingleOrDefault();
7276
OpenDesignerCommand = commands.OfType<OpenDesignerCommand>().SingleOrDefault();
7377

74-
AddTestModuleCommand = commands.OfType<UI.CodeExplorer.Commands.AddTestModuleCommand>().SingleOrDefault();
75-
AddTestModuleWithStubsCommand = commands.OfType<AddTestModuleWithStubsCommand>().SingleOrDefault();
76-
78+
AddVBFormCommand = commands.OfType<AddVBFormCommand>().SingleOrDefault();
79+
AddMDIFormCommand = commands.OfType<AddMDIFormCommand>().SingleOrDefault();
80+
AddUserFormCommand = commands.OfType<AddUserFormCommand>().SingleOrDefault();
7781
AddStdModuleCommand = commands.OfType<AddStdModuleCommand>().SingleOrDefault();
7882
AddClassModuleCommand = commands.OfType<AddClassModuleCommand>().SingleOrDefault();
79-
AddUserFormCommand = commands.OfType<AddUserFormCommand>().SingleOrDefault();
83+
AddUserControlCommand = commands.OfType<AddUserControlCommand>().SingleOrDefault();
84+
AddPropertyPageCommand = commands.OfType<AddPropertyPageCommand>().SingleOrDefault();
85+
AddUserDocumentCommand = commands.OfType<AddUserDocumentCommand>().SingleOrDefault();
86+
AddTestModuleCommand = commands.OfType<UI.CodeExplorer.Commands.AddTestModuleCommand>().SingleOrDefault();
87+
AddTestModuleWithStubsCommand = commands.OfType<AddTestModuleWithStubsCommand>().SingleOrDefault();
8088

8189
OpenProjectPropertiesCommand = commands.OfType<OpenProjectPropertiesCommand>().SingleOrDefault();
8290
RenameCommand = commands.OfType<RenameCommand>().SingleOrDefault();
@@ -90,7 +98,7 @@ public CodeExplorerViewModel(
9098

9199
ImportCommand = commands.OfType<ImportCommand>().SingleOrDefault();
92100
ExportCommand = commands.OfType<ExportCommand>().SingleOrDefault();
93-
ExportAllCommand = commands.OfType<Rubberduck.UI.Command.ExportAllCommand>().SingleOrDefault();
101+
ExportAllCommand = commands.OfType<ExportAllCommand>().SingleOrDefault();
94102

95103
_externalRemoveCommand = commands.OfType<RemoveCommand>().SingleOrDefault();
96104
if (_externalRemoveCommand != null)
@@ -511,11 +519,17 @@ private void SwitchNodeState(CodeExplorerItemViewModel node, bool expandedState)
511519

512520
public CommandBase OpenCommand { get; }
513521

522+
523+
public CommandBase AddVBFormCommand { get; }
524+
public CommandBase AddMDIFormCommand { get; }
525+
public CommandBase AddUserFormCommand { get; }
526+
public CommandBase AddStdModuleCommand { get; }
527+
public CommandBase AddClassModuleCommand { get; }
528+
public CommandBase AddUserControlCommand { get; }
529+
public CommandBase AddPropertyPageCommand { get; }
530+
public CommandBase AddUserDocumentCommand { get; }
514531
public CommandBase AddTestModuleCommand { get; }
515532
public CommandBase AddTestModuleWithStubsCommand { get; }
516-
public CommandBase AddStdModuleCommand { get; }
517-
public CommandBase AddClassModuleCommand { get; }
518-
public CommandBase AddUserFormCommand { get; }
519533

520534
public CommandBase OpenDesignerCommand { get; }
521535
public CommandBase OpenProjectPropertiesCommand { get; }
@@ -552,14 +566,18 @@ private void ExecuteRemoveComand(object param)
552566

553567
private bool CanExecuteExportAllCommand => ExportAllCommand.CanExecute(SelectedItem);
554568

555-
public Visibility ExportVisibility => CanExecuteExportAllCommand ? Visibility.Collapsed : Visibility.Visible;
569+
public Visibility ExportVisibility => _vbeKind == VBEKind.Standalone || CanExecuteExportAllCommand ? Visibility.Collapsed : Visibility.Visible;
556570

557571
public Visibility ExportAllVisibility => CanExecuteExportAllCommand ? Visibility.Visible : Visibility.Collapsed;
558572

559573
public Visibility TreeViewVisibility => Projects == null || Projects.Count == 0 ? Visibility.Collapsed : Visibility.Visible;
560574

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

577+
public Visibility VB6Visibility => _vbeKind == VBEKind.Standalone ? Visibility.Visible : Visibility.Collapsed;
578+
579+
public Visibility VBAVisibility => _vbeKind == VBEKind.Hosted ? Visibility.Visible : Visibility.Collapsed;
580+
563581
public void FilterByName(IEnumerable<CodeExplorerItemViewModel> nodes, string searchString)
564582
{
565583
foreach (var item in nodes)

Rubberduck.Core/Rubberduck.Core.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,11 @@
382382
<Compile Include="AutoComplete\AutoCompleteClosingParenthese.cs" />
383383
<Compile Include="AutoComplete\AutoCompleteClosingString.cs" />
384384
<Compile Include="AutoComplete\AutoCompleteService.cs" />
385+
<Compile Include="UI\CodeExplorer\Commands\AddPropertyPageCommand.cs" />
386+
<Compile Include="UI\CodeExplorer\Commands\AddUserDocumentCommand.cs" />
387+
<Compile Include="UI\CodeExplorer\Commands\AddUserControlCommand.cs" />
388+
<Compile Include="UI\CodeExplorer\Commands\AddMDIFormCommand.cs" />
389+
<Compile Include="UI\CodeExplorer\Commands\AddVBFormCommand.cs" />
385390
<Compile Include="UI\CodeExplorer\Commands\AddTestModuleWithStubsCommand.cs" />
386391
<Compile Include="UI\CodeExplorer\Commands\CodeExplorerCommandAttribute.cs" />
387392
<Compile Include="UI\CodeExplorer\Commands\AddUserFormCommand.cs" />

0 commit comments

Comments
 (0)