提交 a7ed2071 编写于 作者: C Cyrus Najmabadi

Push options down.

上级 1dee0682
......@@ -208,7 +208,7 @@ public Task<IInlineRenameLocationSet> FindRenameLocationsAsync(OptionSet optionS
// If this is the first call, then just start finding the initial set of rename
// locations.
_underlyingFindRenameLocationsTask = Renamer.FindRenameLocationsAsync(
_document.Project.Solution, this.RenameSymbol, RenameOptionSet.From(optionSet), cancellationToken);
_document.Project.Solution, this.RenameSymbol, optionSet, cancellationToken);
renameTask = _underlyingFindRenameLocationsTask;
// null out the option set. We don't need it anymore, and this will ensure
......@@ -231,7 +231,8 @@ private async Task<IInlineRenameLocationSet> GetLocationSetAsync(Task<RenameLoca
var locationSet = await renameTask.ConfigureAwait(false);
if (optionSet != null)
{
locationSet = await locationSet.FindWithUpdatedOptionsAsync(RenameOptionSet.From(optionSet), cancellationToken).ConfigureAwait(false);
locationSet = await locationSet.FindWithUpdatedOptionsAsync(
RenameOptionSet.From(_document.Project.Solution, optionSet), cancellationToken).ConfigureAwait(false);
}
return new InlineRenameLocationSet(this, locationSet);
......
......@@ -281,7 +281,7 @@ private async Task<Result> EncapsulateFieldAsync(IFieldSymbol field, Document do
CancellationToken cancellationToken)
{
var initialLocations = await Renamer.FindRenameLocationsAsync(
solution, field, RenameOptionSet.From(solution.Options), cancellationToken).ConfigureAwait(false);
solution, field, optionSet: null, cancellationToken).ConfigureAwait(false);
return await Renamer.RenameAsync(
initialLocations.Filter(filter), finalName,
......
......@@ -85,7 +85,7 @@ private async Task<Solution> ProcessResultAsync(CodeFixContext context, Diagnost
var solution = context.Document.Project.Solution;
var fieldLocations = await Renamer.FindRenameLocationsAsync(
solution, fieldSymbol, RenameOptionSet.From(solution.Options), cancellationToken).ConfigureAwait(false);
solution, fieldSymbol, optionSet: null, cancellationToken).ConfigureAwait(false);
// First, create the updated property we want to replace the old property with
var isWrittenToOutsideOfConstructor = IsWrittenToOutsideOfConstructorOrProperty(fieldSymbol, fieldLocations, property, cancellationToken);
......
......@@ -35,11 +35,15 @@ public RenameOptionSet(bool renameOverloads, bool renameInStrings, bool renameIn
RenameFile = renameFile;
}
internal static RenameOptionSet From(OptionSet options)
=> new RenameOptionSet(
internal static RenameOptionSet From(Solution solution, OptionSet options)
{
options ??= solution.Options;
return new RenameOptionSet(
options.GetOption(RenameOptions.RenameOverloads),
options.GetOption(RenameOptions.RenameInStrings),
options.GetOption(RenameOptions.RenameInComments),
options.GetOption(RenameOptions.RenameFile));
}
}
}
......@@ -6,9 +6,7 @@
using System.Collections.Immutable;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Internal.Log;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Remote;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.Rename
......@@ -32,14 +30,14 @@ public static class Renamer
optionSet ??= solution.Options;
var renameOptions = RenameOptionSet.From(optionSet);
return RenameSymbolAsync(solution, symbol, newName, renameOptions, nonConflictSymbols: null, cancellationToken);
return RenameSymbolAsync(solution, symbol, newName, optionSet, nonConflictSymbols: null, cancellationToken);
}
internal static Task<RenameLocations> FindRenameLocationsAsync(
Solution solution, ISymbol symbol, RenameOptionSet options, CancellationToken cancellationToken)
Solution solution, ISymbol symbol, OptionSet optionSet, CancellationToken cancellationToken)
{
return RenameLocations.FindLocationsAsync(symbol, solution, options, cancellationToken);
return RenameLocations.FindLocationsAsync(
symbol, solution, RenameOptionSet.From(solution, optionSet), cancellationToken);
}
internal static async Task<Solution> RenameAsync(
......@@ -62,7 +60,7 @@ public static class Renamer
Solution solution,
ISymbol symbol,
string newName,
RenameOptionSet options,
OptionSet optionSet,
ImmutableHashSet<ISymbol> nonConflictSymbols,
CancellationToken cancellationToken)
{
......@@ -73,7 +71,7 @@ public static class Renamer
cancellationToken.ThrowIfCancellationRequested();
var renameLocations = await FindRenameLocationsAsync(solution, symbol, options, cancellationToken).ConfigureAwait(false);
var renameLocations = await FindRenameLocationsAsync(solution, symbol, optionSet, cancellationToken).ConfigureAwait(false);
return await RenameAsync(renameLocations, newName, nonConflictSymbols, cancellationToken).ConfigureAwait(false);
}
}
......
......@@ -4,7 +4,6 @@
using System.Collections.Generic;
using System.Threading;
using Microsoft.CodeAnalysis.Shared.Extensions;
namespace Microsoft.CodeAnalysis
{
......
......@@ -29,8 +29,8 @@ internal partial class CodeAnalysisService : IRemoteRenamer
if (symbol == null)
return null;
var result = await Renamer.FindRenameLocationsAsync(
solution, symbol, options.Rehydrate(), cancellationToken).ConfigureAwait(false);
var result = await RenameLocations.FindLocationsAsync(
symbol, solution, options.Rehydrate(), cancellationToken).ConfigureAwait(false);
return result.Dehydrate(solution, cancellationToken);
}
}, cancellationToken);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册