forked from dotnet/roslyn
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request dotnet#54654 from CyrusNajmabadi/farOrder2
Update FAR engine to be able to work without having access to all projects at the same time.
- Loading branch information
Showing
33 changed files
with
716 additions
and
707 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 0 additions & 33 deletions
33
src/Workspaces/Core/Portable/FindSymbols/FindReferences/FindReferencesCascadeDirection.cs
This file was deleted.
Oops, something went wrong.
62 changes: 62 additions & 0 deletions
62
.../Portable/FindSymbols/FindReferences/FindReferencesSearchEngine.BidirectionalSymbolSet.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// 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. | ||
|
||
using System.Collections.Generic; | ||
using System.Collections.Immutable; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.CodeAnalysis.Shared.Extensions; | ||
using Roslyn.Utilities; | ||
|
||
namespace Microsoft.CodeAnalysis.FindSymbols | ||
{ | ||
internal partial class FindReferencesSearchEngine | ||
{ | ||
/// <summary> | ||
/// Symbol set used when <see cref="FindReferencesSearchOptions.UnidirectionalHierarchyCascade"/> is <see | ||
/// langword="false"/>. This symbol set will cascade up *and* down the inheritance hierarchy for all symbols we | ||
/// are searching for. This is the symbol set used for features like 'Rename', where all cascaded symbols must | ||
/// be updated in order to keep the code compiling. | ||
/// </summary> | ||
private sealed class BidirectionalSymbolSet : SymbolSet | ||
{ | ||
/// <summary> | ||
/// When we're cascading in both direction, we can just keep all symbols in a single set. We'll always be | ||
/// examining all of them to go in both up and down directions in every project we process. Any time we | ||
/// add a new symbol to it we'll continue to cascade in both directions looking for more. | ||
/// </summary> | ||
private readonly HashSet<ISymbol> _allSymbols = new(); | ||
|
||
public BidirectionalSymbolSet(FindReferencesSearchEngine engine, HashSet<ISymbol> initialSymbols, HashSet<ISymbol> upSymbols) | ||
: base(engine) | ||
{ | ||
_allSymbols.AddRange(initialSymbols); | ||
_allSymbols.AddRange(upSymbols); | ||
} | ||
|
||
public override ImmutableArray<ISymbol> GetAllSymbols() | ||
=> _allSymbols.ToImmutableArray(); | ||
|
||
public override async Task InheritanceCascadeAsync(Project project, CancellationToken cancellationToken) | ||
{ | ||
// Start searching using the current set of symbols built up so far. | ||
var workQueue = new Stack<ISymbol>(); | ||
workQueue.Push(_allSymbols); | ||
|
||
var projects = ImmutableHashSet.Create(project); | ||
|
||
while (workQueue.Count > 0) | ||
{ | ||
var current = workQueue.Pop(); | ||
|
||
// For each symbol we're examining try to walk both up and down from it to see if we discover any | ||
// new symbols in this project. As long as we keep finding symbols, we'll keep searching from them | ||
// in both directions. | ||
await AddDownSymbolsAsync(this.Engine, current, _allSymbols, workQueue, projects, cancellationToken).ConfigureAwait(false); | ||
await AddUpSymbolsAsync(this.Engine, current, _allSymbols, workQueue, projects, cancellationToken).ConfigureAwait(false); | ||
} | ||
} | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...e/Portable/FindSymbols/FindReferences/FindReferencesSearchEngine.NonCascadingSymbolSet.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// 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. | ||
|
||
using System.Collections.Immutable; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Microsoft.CodeAnalysis.FindSymbols | ||
{ | ||
internal partial class FindReferencesSearchEngine | ||
{ | ||
/// <summary> | ||
/// A symbol set used when the find refs caller does not want cascading. This is a trivial impl that basically | ||
/// just wraps the initial symbol provided and doesn't need to do anything beyond that. | ||
/// </summary> | ||
private sealed class NonCascadingSymbolSet : SymbolSet | ||
{ | ||
private readonly ImmutableArray<ISymbol> _symbols; | ||
|
||
public NonCascadingSymbolSet(FindReferencesSearchEngine engine, ISymbol searchSymbol) : base(engine) | ||
{ | ||
_symbols = ImmutableArray.Create(searchSymbol); | ||
} | ||
|
||
public override ImmutableArray<ISymbol> GetAllSymbols() | ||
=> _symbols; | ||
|
||
public override Task InheritanceCascadeAsync(Project project, CancellationToken cancellationToken) | ||
{ | ||
// Nothing to do here. We're in a non-cascading scenario, so even as we encounter a new project we | ||
// don't have to figure out what new symbols may be found. | ||
return Task.CompletedTask; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.