Skip to content

Commit 86c3eb9

Browse files
committed
clear type cache on parse
1 parent 282f99a commit 86c3eb9

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

Rubberduck.Core/UI/Command/ComCommands/ReparseCommand.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Linq;
44
using System.Runtime.InteropServices;
55
using Rubberduck.Interaction;
6+
using Rubberduck.Parsing.ComReflection.TypeLibReflection;
67
using Rubberduck.Parsing.VBA;
78
using Rubberduck.Resources;
89
using Rubberduck.Settings;
@@ -30,6 +31,7 @@ public class ReparseCommand : ComCommandBase
3031
private readonly IMessageBox _messageBox;
3132
private readonly RubberduckParserState _state;
3233
private readonly GeneralSettings _settings;
34+
private static readonly ICachedTypeService TypeCacheService = CachedTypeService.Instance;
3335

3436
public ReparseCommand(
3537
IVBE vbe,
@@ -93,6 +95,10 @@ protected override void OnExecute(object parameter)
9395
}
9496
}
9597
}
98+
foreach (var project in _state.Projects)
99+
{
100+
TypeCacheService.TryInvalidate(project.Name);
101+
}
96102
_state.OnParseRequested(this);
97103
}
98104

Rubberduck.Parsing/ComReflection/TypeLibReflection/CachedTypeService.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace Rubberduck.Parsing.ComReflection.TypeLibReflection
2424
/// </remarks>
2525
public interface ICachedTypeService
2626
{
27-
bool TryInvalidate(string project, string progId);
27+
bool TryInvalidate(string project, string progId = null);
2828
bool TryGetCachedType(string progId, out Type type);
2929
bool TryGetCachedType(string project, string progId, out Type type);
3030
bool TryGetCachedType(ITypeInfo typeInfo, out Type type);
@@ -163,11 +163,18 @@ private static bool TryGetValue(string project, string progId, out Type type)
163163
return false;
164164
}
165165

166-
public bool TryInvalidate(string project, string progId)
166+
public bool TryInvalidate(string project, string progId = null)
167167
{
168168
if (TypeCaches.TryGetValue(project?.ToLowerInvariant() ?? string.Empty, out var cache))
169169
{
170-
return cache.Remove(progId);
170+
if (!string.IsNullOrWhiteSpace(progId))
171+
{
172+
return cache.Remove(progId);
173+
}
174+
else
175+
{
176+
return TypeCaches.TryRemove(cache.Key, out _);
177+
}
171178
}
172179

173180
return false;

0 commit comments

Comments
 (0)