本文整理汇总了C#中ImmutableArray.ToLookup方法的典型用法代码示例。如果您正苦于以下问题:C# ImmutableArray.ToLookup方法的具体用法?C# ImmutableArray.ToLookup怎么用?C# ImmutableArray.ToLookup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImmutableArray
的用法示例。
在下文中一共展示了ImmutableArray.ToLookup方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateAnalysisResults
private ImmutableDictionary<DiagnosticAnalyzer, AnalysisResult> CreateAnalysisResults(
Project project, ImmutableArray<StateSet> stateSets, ProjectAnalysisData oldAnalysisData, ImmutableArray<DiagnosticData> diagnostics)
{
using (var poolObject = SharedPools.Default<HashSet<string>>().GetPooledObject())
{
// we can't distinguish locals and non locals from build diagnostics nor determine right snapshot version for the build.
// so we put everything in as semantic local with default version. this lets us to replace those to live diagnostics when needed easily.
var version = VersionStamp.Default;
var lookup = diagnostics.ToLookup(d => d.Id);
var builder = ImmutableDictionary.CreateBuilder<DiagnosticAnalyzer, AnalysisResult>();
foreach (var stateSet in stateSets)
{
var descriptors = HostAnalyzerManager.GetDiagnosticDescriptors(stateSet.Analyzer);
var liveDiagnostics = MergeDiagnostics(ConvertToLiveDiagnostics(lookup, descriptors, poolObject.Object), GetDiagnostics(oldAnalysisData.GetResult(stateSet.Analyzer)));
var group = liveDiagnostics.GroupBy(d => d.DocumentId);
var result = new AnalysisResult(
project.Id,
version,
documentIds: group.Where(g => g.Key != null).Select(g => g.Key).ToImmutableHashSet(),
syntaxLocals: ImmutableDictionary<DocumentId, ImmutableArray<DiagnosticData>>.Empty,
semanticLocals: group.Where(g => g.Key != null).ToImmutableDictionary(g => g.Key, g => g.ToImmutableArray()),
nonLocals: ImmutableDictionary<DocumentId, ImmutableArray<DiagnosticData>>.Empty,
others: group.Where(g => g.Key == null).SelectMany(g => g).ToImmutableArrayOrEmpty());
builder.Add(stateSet.Analyzer, result);
}
return builder.ToImmutable();
}
}
示例2: CreateDiagnosticIdLookup
private static ILookup<string, DiagnosticData> CreateDiagnosticIdLookup(ImmutableArray<DiagnosticData> diagnostics)
{
if (diagnostics.Length == 0)
{
return null;
}
return diagnostics.ToLookup(d => d.Id);
}
示例3: SetReferenceLocations
private void SetReferenceLocations(ImmutableArray<InlineRenameLocation> locations)
{
AssertIsForeground();
var locationsByDocument = locations.ToLookup(l => l.Document.Id);
_isApplyingEdit = true;
foreach (var textBuffer in _openTextBuffers.Keys)
{
var documents = textBuffer.AsTextContainer().GetRelatedDocuments();
if (!documents.Any(d => locationsByDocument.Contains(d.Id)))
{
_openTextBuffers[textBuffer].SetReferenceSpans(SpecializedCollections.EmptyEnumerable<TextSpan>());
}
else
{
var spans = documents.SelectMany(d => locationsByDocument[d.Id]).Select(l => l.TextSpan).Distinct();
_openTextBuffers[textBuffer].SetReferenceSpans(spans);
}
}
_isApplyingEdit = false;
}