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

Don't require spell checker.

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