Skip to content

Commit 944b9de

Browse files
committed
minor fixes. ref.#1974
1 parent 0a63b70 commit 944b9de

File tree

6 files changed

+38
-10
lines changed

6 files changed

+38
-10
lines changed

RetailCoder.VBE/Common/DeclarationExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -456,9 +456,9 @@ public static Declaration FindInterfaceMember(this IEnumerable<Declaration> decl
456456
var members = FindInterfaceMembers(declarations);
457457
var matches = members.Where(m => !m.IsBuiltIn && implementation.IdentifierName == m.ComponentName + '_' + m.IdentifierName).ToList();
458458

459-
return matches.Count > 1
460-
? matches.SingleOrDefault(m => m.ProjectId == implementation.ProjectId)
461-
: matches.First();
459+
return matches.Count > 1
460+
? matches.SingleOrDefault(m => m.ProjectId == implementation.ProjectId)
461+
: matches.FirstOrDefault();
462462
}
463463

464464
public static Declaration FindTarget(this IEnumerable<Declaration> declarations, QualifiedSelection selection)

RetailCoder.VBE/UI/CodeExplorer/CodeExplorerControl.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@
399399
Command="{Binding FindAllImplementationsCommand}"
400400
CommandParameter="{Binding SelectedItem}" />
401401
</MenuItem>
402-
<MenuItem Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=SmartIndenterMenu}"
402+
<MenuItem Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=CodeExplorer_Indent}"
403403
Command="{Binding IndenterCommand}"
404404
CommandParameter="{Binding SelectedItem}" />
405405
<Separator />
@@ -764,7 +764,7 @@
764764
Visibility="{Binding CanExecuteIndenterCommand, Converter={StaticResource BoolToVisibility}, UpdateSourceTrigger=PropertyChanged}"
765765
Command="{Binding IndenterCommand}"
766766
CommandParameter="{Binding SelectedItem}"
767-
Content="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=SmartIndenterMenu}" />
767+
Content="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=CodeExplorer_Indent}" />
768768
<controls:LinkButton Margin="4"
769769
Visibility="{Binding CanExecuteRenameCommand, Converter={StaticResource BoolToVisibility}}"
770770
Command="{Binding RenameCommand}"

RetailCoder.VBE/UI/Command/FindAllImplementationsCommand.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ private IEnumerable<Declaration> FindAllImplementationsOfClass(Declaration targe
182182
if (target.DeclarationType != DeclarationType.ClassModule)
183183
{
184184
name = string.Empty;
185-
return null;
185+
return Enumerable.Empty<Declaration>();
186186
}
187187

188188
var identifiers = declarations as IList<Declaration> ?? declarations.ToList();
@@ -201,7 +201,7 @@ private IEnumerable<Declaration> FindAllImplementationsOfMember(Declaration targ
201201
if (!target.DeclarationType.HasFlag(DeclarationType.Member))
202202
{
203203
name = string.Empty;
204-
return null;
204+
return Enumerable.Empty<Declaration>();
205205
}
206206

207207
var items = declarations as IList<Declaration> ?? declarations.ToList();
@@ -218,6 +218,11 @@ private IEnumerable<Declaration> FindAllImplementationsOfMember(Declaration targ
218218
}
219219

220220
var member = items.FindInterfaceMember(target);
221+
if (member == null)
222+
{
223+
name = string.Empty;
224+
return Enumerable.Empty<Declaration>();
225+
}
221226
name = member.ComponentName + "." + member.IdentifierName;
222227
return items.FindInterfaceImplementationMembers(member.IdentifierName)
223228
.Where(item => item.IdentifierName == member.ComponentName + "_" + member.IdentifierName);

RetailCoder.VBE/UI/RubberduckUI.Designer.cs

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

RetailCoder.VBE/UI/RubberduckUI.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,4 +1730,7 @@ All our stargazers, likers &amp; followers, for the warm fuzzies
17301730
<data name="TestExplorerMenu_AddTestModule" xml:space="preserve">
17311731
<value>Test M&amp;odule</value>
17321732
</data>
1733+
<data name="CodeExplorer_Indent" xml:space="preserve">
1734+
<value>Indent</value>
1735+
</data>
17331736
</root>

Rubberduck.Parsing/VBA/RubberduckParser.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using System.Diagnostics;
1313
using Rubberduck.VBEditor.Extensions;
1414
using System.IO;
15+
using System.Linq;
1516
using NLog;
1617
// ReSharper disable LoopCanBeConvertedToQuery
1718

@@ -660,10 +661,20 @@ public void Dispose()
660661
{
661662
State.ParseRequest -= ReparseRequested;
662663

663-
if (_cancellationTokens[0] != null)
664+
if (_cancellationTokens.Any(cts => cts != null))
664665
{
665-
_cancellationTokens[0].Cancel();
666-
_cancellationTokens[0].Dispose();
666+
foreach (var cts in _cancellationTokens.ToList())
667+
{
668+
try
669+
{
670+
cts.Cancel();
671+
cts.Dispose();
672+
}
673+
finally
674+
{
675+
_cancellationTokens.Remove(cts);
676+
}
677+
}
667678
}
668679
}
669680
}

0 commit comments

Comments
 (0)