// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable enable using System.Collections.Immutable; using System.Threading; using System.Threading.Tasks; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.FindSymbols.Finders { internal class FieldSymbolReferenceFinder : AbstractReferenceFinder { protected override bool CanFind(IFieldSymbol symbol) => true; protected override Task> DetermineCascadedSymbolsAsync( IFieldSymbol symbol, Solution solution, IImmutableSet projects, FindReferencesSearchOptions options, CancellationToken cancellationToken) { if (symbol.AssociatedSymbol != null) { return Task.FromResult(ImmutableArray.Create(symbol.AssociatedSymbol)); } else { return SpecializedTasks.EmptyImmutableArray(); } } protected override Task> DetermineDocumentsToSearchAsync( IFieldSymbol symbol, Project project, IImmutableSet documents, FindReferencesSearchOptions options, CancellationToken cancellationToken) { return FindDocumentsAsync(project, documents, findInGlobalSuppressions: true, cancellationToken, symbol.Name); } protected override Task> FindReferencesInDocumentAsync( IFieldSymbol symbol, Document document, SemanticModel semanticModel, FindReferencesSearchOptions options, CancellationToken cancellationToken) { return FindReferencesInDocumentUsingSymbolNameAsync(symbol, document, semanticModel, cancellationToken); } } }