提交 2e0cedda 编写于 作者: C cyrusn

Provide a way for options to be set on the workspace.

***NO_CI***
 (changeset 1275257)
上级 6bf81cec
......@@ -286,7 +286,7 @@ internal static SyntaxNode Format(SyntaxNode node, IEnumerable<TextSpan> spans,
var languageFormatter = workspace.Services.GetLanguageServices(node.Language).GetService<ISyntaxFormattingService>();
if (languageFormatter != null)
{
options = options ?? workspace.GetOptions();
options = options ?? workspace.Options;
rules = rules ?? GetDefaultFormattingRules(workspace, node.Language);
return languageFormatter.Format(node, spans, options, rules, cancellationToken).GetFormattedRoot(cancellationToken);
}
......@@ -321,7 +321,7 @@ internal static IList<TextChange> GetFormattedTextChanges(SyntaxNode node, IEnum
var languageFormatter = workspace.Services.GetLanguageServices(node.Language).GetService<ISyntaxFormattingService>();
if (languageFormatter != null)
{
options = options ?? workspace.GetOptions();
options = options ?? workspace.Options;
rules = rules ?? GetDefaultFormattingRules(workspace, node.Language);
return languageFormatter.Format(node, spans, options, rules, cancellationToken).GetTextChanges(cancellationToken);
}
......
......@@ -17,7 +17,7 @@ public static class Recommender
OptionSet options = null,
CancellationToken cancellationToken = default(CancellationToken))
{
options = options ?? workspace.GetOptions();
options = options ?? workspace.Options;
var languageRecommender = workspace.Services.GetLanguageServices(semanticModel.Language).GetService<IRecommendationService>();
return languageRecommender.GetRecommendedSymbolsAtPosition(workspace, semanticModel, position, options, cancellationToken);
......
......@@ -195,7 +195,7 @@ internal async Task<Solution> SimplifyAsync(Solution solution, IEnumerable<Docum
if (replacementTextValid)
{
var optionSet = solution.Workspace.GetOptions();
var optionSet = solution.Workspace.Options;
document = await Simplifier.ReduceAsync(document, Simplifier.Annotation, optionSet, cancellationToken).ConfigureAwait(false);
document = await Formatter.FormatAsync(document, Formatter.Annotation, cancellationToken: cancellationToken).ConfigureAwait(false);
}
......
......@@ -45,7 +45,7 @@ public async Task<Document> ReduceAsync(Document document, IEnumerable<TextSpan>
return document;
}
optionSet = optionSet ?? document.Project.Solution.Workspace.GetOptions();
optionSet = optionSet ?? document.Project.Solution.Workspace.Options;
var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
......
......@@ -153,11 +153,19 @@ protected Solution SetCurrentSolution(Solution solution)
}
/// <summary>
/// Get's the set of all global options.
/// Gets or sets the set of all global options.
/// </summary>
public OptionSet GetOptions()
public OptionSet Options
{
return this.services.GetService<IOptionService>().GetOptions();
get
{
return this.services.GetService<IOptionService>().GetOptions();
}
set
{
this.services.GetService<IOptionService>().SetOptions(value);
}
}
/// <summary>
......
......@@ -43,7 +43,7 @@ public abstract class FormattingTestBase
var syntaxTree = document.GetSyntaxTreeAsync().Result;
var options = workspace.GetOptions();
var options = workspace.Options;
if (changedOptionSet != null)
{
foreach (var entry in changedOptionSet)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册