Skip to content

Commit f67eeff

Browse files
author
Andrew Mansell
committed
Merge branch 'next' of https://github.com/rubberduck-vba/Rubberduck into 3997
# Conflicts: # Rubberduck.VBEEditor/Rubberduck.VBEditor.csproj
2 parents bd0f2d7 + bfd6a95 commit f67eeff

File tree

68 files changed

+3980
-356
lines changed

Some content is hidden

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

68 files changed

+3980
-356
lines changed

Rubberduck.CodeAnalysis/Inspections/Concrete/ProcedureCanBeWrittenAsFunctionInspection.cs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,19 @@ protected override IEnumerable<IInspectionResult> DoGetInspectionResults()
3636
.Concat(builtinHandlers)
3737
.Concat(userDeclarations.Where(item => item.IsWithEvents)));
3838

39-
return Listener.Contexts.Where(context => context.Context.Parent is VBAParser.SubStmtContext)
40-
.Select(context => contextLookup[(VBAParser.SubStmtContext)context.Context.Parent])
41-
.Where(decl => !IsIgnoringInspectionResultFor(decl, AnnotationName) &&
42-
!ignored.Contains(decl) &&
43-
userDeclarations.Where(item => item.IsWithEvents)
44-
.All(withEvents => userDeclarations.FindEventProcedures(withEvents) == null) &&
45-
!builtinHandlers.Contains(decl))
46-
.Select(result => new DeclarationInspectionResult(this,
47-
string.Format(InspectionResults.ProcedureCanBeWrittenAsFunctionInspection, result.IdentifierName),
48-
result));
39+
return Listener.Contexts
40+
.Where(context => context.Context.Parent is VBAParser.SubStmtContext
41+
&& contextLookup[context.Context.GetChild<VBAParser.ArgContext>()].References
42+
.Any(reference => reference.IsAssignment))
43+
.Select(context => contextLookup[(VBAParser.SubStmtContext)context.Context.Parent])
44+
.Where(decl => !IsIgnoringInspectionResultFor(decl, AnnotationName) &&
45+
!ignored.Contains(decl) &&
46+
userDeclarations.Where(item => item.IsWithEvents)
47+
.All(withEvents => userDeclarations.FindEventProcedures(withEvents) == null) &&
48+
!builtinHandlers.Contains(decl))
49+
.Select(result => new DeclarationInspectionResult(this,
50+
string.Format(InspectionResults.ProcedureCanBeWrittenAsFunctionInspection, result.IdentifierName),
51+
result));
4952
}
5053

5154
public class SingleByRefParamArgListListener : VBAParserBaseListener, IInspectionListener

Rubberduck.Core/UI/Command/AddTestMethodCommand.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Collections.Generic;
12
using System.Linq;
23
using System.Runtime.InteropServices;
34
using NLog;
@@ -114,10 +115,16 @@ protected override void OnExecute(object parameter)
114115

115116
private string GetNextTestMethodName(IVBComponent component)
116117
{
117-
var names = component.GetTests(_vbe, _state).Select(test => test.Declaration.IdentifierName);
118-
var index = names.Count(n => n.StartsWith(TestMethodBaseName)) + 1;
118+
var names = new HashSet<string>(_state.DeclarationFinder.Members(component.QualifiedModuleName)
119+
.Select(test => test.IdentifierName).Where(decl => decl.StartsWith(TestMethodBaseName)));
119120

120-
return string.Concat(TestMethodBaseName, index);
121+
var index = 1;
122+
while (names.Contains($"{TestMethodBaseName}{index}"))
123+
{
124+
index++;
125+
}
126+
127+
return $"{TestMethodBaseName}{index}";
121128
}
122129
}
123130
}

Rubberduck.Core/UI/Command/AddTestMethodExpectedErrorCommand.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Collections.Generic;
12
using System.Linq;
23
using System.Runtime.InteropServices;
34
using NLog;
@@ -117,10 +118,16 @@ protected override void OnExecute(object parameter)
117118

118119
private string GetNextTestMethodName(IVBComponent component)
119120
{
120-
var names = component.GetTests(_vbe, _state).Select(test => test.Declaration.IdentifierName);
121-
var index = names.Count(n => n.StartsWith(TestMethodBaseName)) + 1;
121+
var names = new HashSet<string>(_state.DeclarationFinder.Members(component.QualifiedModuleName)
122+
.Select(test => test.IdentifierName).Where(decl => decl.StartsWith(TestMethodBaseName)));
122123

123-
return string.Concat(TestMethodBaseName, index);
124+
var index = 1;
125+
while (names.Contains($"{TestMethodBaseName}{index}"))
126+
{
127+
index++;
128+
}
129+
130+
return $"{TestMethodBaseName}{index}";
124131
}
125132
}
126133
}

Rubberduck.Core/UI/Command/AddTestModuleCommand.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,15 @@ protected override void OnExecute(object parameter)
246246

247247
private string GetNextTestModuleName(IVBProject project)
248248
{
249-
var names = project.ComponentNames();
250-
var index = names.Count(n => n.StartsWith(TestModuleBaseName)) + 1;
249+
var names = new HashSet<string>(project.ComponentNames().Where(module => module.StartsWith(TestModuleBaseName)));
251250

252-
return string.Concat(TestModuleBaseName, index);
251+
var index = 1;
252+
while (names.Contains($"{TestModuleBaseName}{index}"))
253+
{
254+
index++;
255+
}
256+
257+
return $"{TestModuleBaseName}{index}";
253258
}
254259

255260
private IEnumerable<Declaration> GetDeclarationsToStub(Declaration parentDeclaration)

Rubberduck.Core/UI/Command/FindAllImplementationsCommand.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ private IEnumerable<Declaration> FindAllImplementationsOfClass(Declaration targe
213213
var identifiers = declarations as IList<Declaration> ?? declarations.ToList();
214214

215215
var result = target.References
216-
.Where(reference => reference.Context.Parent is VBAParser.ImplementsStmtContext)
216+
.Where(reference => reference.Context.Parent.Parent is VBAParser.ImplementsStmtContext)
217217
.SelectMany(reference => identifiers.Where(identifier => identifier.IdentifierName == reference.QualifiedModuleName.ComponentName))
218218
.ToList();
219219

@@ -239,7 +239,8 @@ private IEnumerable<Declaration> FindAllImplementationsOfMember(Declaration targ
239239
{
240240
name = target.ComponentName + "." + target.IdentifierName;
241241
return items.FindInterfaceImplementationMembers(target.IdentifierName)
242-
.Where(item => item.IdentifierName == target.ComponentName + "_" + target.IdentifierName);
242+
.Where(item => item.DeclarationType == target.DeclarationType
243+
&& item.IdentifierName == target.ComponentName + "_" + target.IdentifierName);
243244
}
244245

245246
var member = items.FindInterfaceMember(target);
@@ -250,7 +251,8 @@ private IEnumerable<Declaration> FindAllImplementationsOfMember(Declaration targ
250251
}
251252
name = member.ComponentName + "." + member.IdentifierName;
252253
return items.FindInterfaceImplementationMembers(member.IdentifierName)
253-
.Where(item => item.IdentifierName == member.ComponentName + "_" + member.IdentifierName);
254+
.Where(item => item.DeclarationType == target.DeclarationType
255+
&& item.IdentifierName == member.ComponentName + "_" + member.IdentifierName);
254256
}
255257

256258
public void Dispose()

Rubberduck.Core/UI/UnitTesting/TestExplorerControl.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@
484484
<Border Grid.Row="0" Grid.RowSpan="3" Background="#FFEEF5FD" />
485485

486486
<ToolBarTray Grid.Row="0" IsLocked="True">
487-
<ToolBar IsEnabled="{Binding Model.IsReady}" Style="{StaticResource ToolBarWithOverflowOnlyShowingWhenNeededStyle}">
487+
<ToolBar Style="{StaticResource ToolBarWithOverflowOnlyShowingWhenNeededStyle}">
488488
<ToolBar.Resources>
489489
<Style TargetType="Image">
490490
<Setter Property="Height" Value="16" />

Rubberduck.Core/UI/UnitTesting/TestExplorerControl.xaml.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
using System;
2-
using System.Windows.Controls;
32
using System.Windows.Data;
43
using System.Windows.Threading;
5-
using System.Windows.Input;
64

75
namespace Rubberduck.UI.UnitTesting
86
{
@@ -37,9 +35,17 @@ private void OnTestCompleted(object sender, EventArgs eventArgs)
3735
{
3836
_dispatcher.Invoke(() =>
3937
{
40-
if (FindResource("ResultsByOutcome") is CollectionViewSource resource)
38+
if (FindResource("ResultsByOutcome") is CollectionViewSource outcome)
4139
{
42-
resource.View.Refresh();
40+
outcome.View.Refresh();
41+
}
42+
if (FindResource("ResultsByModule") is CollectionViewSource module)
43+
{
44+
module.View.Refresh();
45+
}
46+
if (FindResource("ResultsByCategory") is CollectionViewSource category)
47+
{
48+
category.View.Refresh();
4349
}
4450
});
4551
}

Rubberduck.Core/UI/UnitTesting/TestExplorerViewModel.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ public TestExplorerViewModel(IVBE vbe,
3434
IClipboardWriter clipboard,
3535
IGeneralConfigService configService,
3636
ISettingsFormFactory settingsFormFactory,
37-
IMessageBox messageBox)
37+
IMessageBox messageBox,
38+
ReparseCommand reparseCommand)
3839
{
3940
_vbe = vbe;
4041
_state = state;
@@ -54,7 +55,7 @@ public TestExplorerViewModel(IVBE vbe,
5455
AddTestMethodCommand = new AddTestMethodCommand(vbe, state);
5556
AddErrorTestMethodCommand = new AddTestMethodExpectedErrorCommand(vbe, state);
5657

57-
RefreshCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteRefreshCommand, CanExecuteRefreshCommand);
58+
RefreshCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteRefreshCommand, o => !Model.IsBusy && reparseCommand.CanExecute(o));
5859
RepeatLastRunCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteRepeatLastRunCommand, CanExecuteRepeatLastRunCommand);
5960
RunNotExecutedTestsCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteRunNotExecutedTestsCommand, CanExecuteRunNotExecutedTestsCommand);
6061
RunInconclusiveTestsCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteRunInconclusiveTestsCommand, CanExecuteRunInconclusiveTestsCommand);
@@ -262,11 +263,6 @@ private void ExecuteRefreshCommand(object parameter)
262263
SelectedTest = null;
263264
}
264265

265-
private bool CanExecuteRefreshCommand(object parameter)
266-
{
267-
return !Model.IsBusy && _state.IsDirty();
268-
}
269-
270266
private void EnsureRubberduckIsReferencedForEarlyBoundTests()
271267
{
272268
var projectIdsOfMembersUsingAddInLibrary = _state.DeclarationFinder.AllUserDeclarations
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
; Czech Custom Messages Include -- Must be encoded in UTF-8 BOM
2+
Czech.PerUser=Aktuální Uživatel
3+
Czech.Everyone=Všichni Uživatelé
4+
Czech.RegisterAddin=Opravit VBE Addin registraci
5+
Czech.ProgramOnTheWeb=Webová stránka Rubberduck VBA
6+
Czech.UninstallProgram=Odinstalovat Rubberduck
7+
Czech.NETFramework46NotInstalled=Microsoft .NET Framework 4.6 instalace nebyla detekována.
8+
Czech.InstallPerUserOrAllUsersCaption=Vyberte možnosti instalace
9+
Czech.InstallPerUserOrAllUsersMessage=Pro koho má být aplikace instalována?
10+
Czech.InstallPerUserOrAllUsersAdminDescription=Prosím vyberte, zda má být tento software dostupný pro všechny uživatele, nebo jen pro vás.
11+
Czech.InstallPerUserOrAllUsersAdminButtonCaption=&Všichni uživatelé tohoto počítače
12+
Czech.InstallPerUserOrAllUsersUserButtonCaption=&Pouze vy
13+
Czech.ElevationRequiredForSelectedFolderWarning=Vybraná složka vyžaduje pro zápis práva administrátora. Nainstalovat pro všechny uživatele?
14+
Czech.ElevationRequestFailMessage=Administrátorský použadavek se nezdařil. Kód: &d
15+
Czech.RegisterAddInCaption=Registrovat VBE Add-in
16+
Czech.RegisterAddInMessage=Provést registraci uživatele VBE addinu.
17+
Czech.RegisterAddInDescription=VBE Add-ins jsou registrovány na základě uživatele, i když byl doplněk VBE nainstalován pro všechny uživatele. Proto je třeba provést registraci na základě každého uživatele.
18+
Czech.RegisterAddInButtonCaption=Registrovat Rubberduck VBE Add-in
19+
Czech.WillExecuteAdminInstall=Rubberduck Add-In bude k dispozici všem uživatelům.%n%nPOZNÁMKA: každý uživatel musí individuálně zaregistrovat Rubberduck Add-In, %nprotože se jedná o per-uživatel nastavení, které není možné aplikovat na všechny uživatele.%n%nPo dokončení instalace bude k dispozici zástupce s názvem "Opravit VBA Addin registraci"%nnacházející se ve složce, kam byl Rubberduck nainstalován a bude k dispozici pro všechny uživatele.
20+
Czech.WillLaunchAdminInstall=Instalátor si vyžádá práva administrátora, aby mohl provést instalaci pro všechny uživatele,%na poté bude pokračovat registrací doplňku pro aktuálního uživatele.
21+
Czech.WillInstallForCurrentUser=Rubberduck Add-In bude k dispozici pouze pro aktuálního uživatele%na nebude vyžadovat práva administrátora
22+
Czech.UninstallOldVersionPrompt=Vypadá to, že existuje předchozí verze Rubberducku instalována v %s módu a měla by být odinstalována. Pokračovat?
23+
Czech.UninstallOldVersionFail=Nelze odinstalovat předchozí verzi Rubberducku. Zkuste jej odinstalovat pomocí ovládacího panelu - programy a funkce - a poté spustit instalátor znovu.
24+
Czech.WarnInstallPerUserOverEveryone=Zdá se, že je nainstalována verze Rubberducku pro všechny uživatele. Pokud budete pokračovat s per-uživatel instalací, bude mít přednost před původní instalací. Přesto pokračovat?
25+
Czech.ElevationRequestFailMessage=Nelze odinstalovat předchozí verzi Rubberducku. Před instalací nové verze bude nejspíše nutné ji odinstalovat přímo.

0 commit comments

Comments
 (0)