提交 8b7ad834 编写于 作者: C CyrusNajmabadi

Don't require spell checker.

上级 b4c9c9e6
......@@ -16,9 +16,9 @@
namespace Microsoft.CodeAnalysis.FindSymbols
{
internal partial class SymbolTreeInfo
internal partial class SymbolTreeInfo : IChecksummedObject
{
public readonly Checksum Checksum;
public Checksum Checksum { get; }
/// <summary>
/// To prevent lots of allocations, we concatenate all the names in all our
......
......@@ -158,11 +158,9 @@ private static Metadata GetMetadataNoThrow(PortableExecutableReference reference
var result = TryLoadOrCreateAsync(
solution,
checksum,
filePath,
loadOnly,
createAsync: () => CreateMetadataSymbolTreeInfoAsync(solution, checksum, reference, cancellationToken),
keySuffix: "_Metadata",
getPersistedChecksum: info => info.Checksum,
keySuffix: "_Metadata_" + filePath,
readObject: reader => ReadSymbolTreeInfo(reader, (names, nodes) => GetSpellCheckerTask(solution, checksum, filePath, names, nodes)),
cancellationToken: cancellationToken);
Contract.ThrowIfFalse(result != null || loadOnly == true, "Result can only be null if 'loadOnly: true' was passed.");
......
......@@ -32,11 +32,9 @@ internal partial class SymbolTreeInfo : IObjectWritable
var result = TryLoadOrCreateAsync(
solution,
checksum,
filePath,
loadOnly: false,
createAsync: createAsync,
keySuffix: "_SpellChecker",
getPersistedChecksum: s => s.Checksum,
keySuffix: "_SpellChecker_" + filePath,
readObject: SpellChecker.ReadFrom,
cancellationToken: CancellationToken.None);
Contract.ThrowIfNull(result, "Result should never be null as we passed 'loadOnly: false'.");
......@@ -50,13 +48,11 @@ internal partial class SymbolTreeInfo : IObjectWritable
private static async Task<T> TryLoadOrCreateAsync<T>(
Solution solution,
Checksum checksum,
string filePath,
bool loadOnly,
Func<Task<T>> createAsync,
string keySuffix,
Func<T, Checksum> getPersistedChecksum,
Func<ObjectReader, T> readObject,
CancellationToken cancellationToken) where T : class, IObjectWritable
CancellationToken cancellationToken) where T : class, IObjectWritable, IChecksummedObject
{
if (checksum == null)
{
......@@ -70,7 +66,7 @@ internal partial class SymbolTreeInfo : IObjectWritable
using (var storage = persistentStorageService.GetStorage(solution, checkBranchId: false))
{
// Get the unique key to identify our data.
var key = PrefixMetadataSymbolTreeInfo + keySuffix + "_" + filePath;
var key = PrefixMetadataSymbolTreeInfo + keySuffix;
using (var stream = await storage.ReadStreamAsync(key, cancellationToken).ConfigureAwait(false))
using (var reader = ObjectReader.TryGetReader(stream))
{
......@@ -80,7 +76,7 @@ internal partial class SymbolTreeInfo : IObjectWritable
// If we're able to, and the version of the persisted data matches
// our version, then we can reuse this instance.
result = readObject(reader);
if (result != null && checksum == getPersistedChecksum(result))
if (result != null && checksum == result.Checksum)
{
return result;
}
......
......@@ -32,11 +32,9 @@ private static void FreeSymbolMap(MultiDictionary<string, ISymbol> symbolMap)
var result = TryLoadOrCreateAsync(
project.Solution,
checksum,
project.FilePath,
loadOnly: false,
createAsync: () => CreateSourceSymbolTreeInfoAsync(project, checksum, cancellationToken),
keySuffix: "_Source",
getPersistedChecksum: info => info.Checksum,
keySuffix: "_Source_" + project.FilePath,
readObject: reader => ReadSymbolTreeInfo(reader, (names, nodes) => GetSpellCheckerTask(project.Solution, checksum, project.FilePath, names, nodes)),
cancellationToken: cancellationToken);
Contract.ThrowIfNull(result, "Result should never be null as we passed 'loadOnly: false'.");
......
......@@ -10,7 +10,7 @@
namespace Roslyn.Utilities
{
internal class SpellChecker : IObjectWritable
internal class SpellChecker : IObjectWritable, IChecksummedObject
{
private const string SerializationFormat = "3";
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册