提交 8bbd654e 编写于 作者: C CyrusNajmabadi

Move SymbolSearch options down to teh Workspace layer.

上级 87e8e65c
......@@ -34,8 +34,8 @@ protected override async Task<TestWorkspace> CreateWorkspaceFromFileAsync(string
{
var workspace = await base.CreateWorkspaceFromFileAsync(definition, parseOptions, compilationOptions);
workspace.Options = workspace.Options
.WithChangedOption(AddImportOptions.SuggestForTypesInNuGetPackages, LanguageNames.CSharp, true)
.WithChangedOption(AddImportOptions.SuggestForTypesInReferenceAssemblies, LanguageNames.CSharp, true);
.WithChangedOption(SymbolSearchOptions.SuggestForTypesInNuGetPackages, LanguageNames.CSharp, true)
.WithChangedOption(SymbolSearchOptions.SuggestForTypesInReferenceAssemblies, LanguageNames.CSharp, true);
return workspace;
}
......
......@@ -26,8 +26,8 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.CodeActions.AddImp
Protected Overrides Async Function CreateWorkspaceFromFileAsync(definition As String, parseOptions As ParseOptions, compilationOptions As CompilationOptions) As Task(Of TestWorkspace)
Dim workspace = Await MyBase.CreateWorkspaceFromFileAsync(definition, parseOptions, compilationOptions)
workspace.Options = workspace.Options.
WithChangedOption(AddImportOptions.SuggestForTypesInNuGetPackages, LanguageNames.VisualBasic, True).
WithChangedOption(AddImportOptions.SuggestForTypesInReferenceAssemblies, LanguageNames.VisualBasic, True)
WithChangedOption(SymbolSearchOptions.SuggestForTypesInNuGetPackages, LanguageNames.VisualBasic, True).
WithChangedOption(SymbolSearchOptions.SuggestForTypesInReferenceAssemblies, LanguageNames.VisualBasic, True)
Return workspace
End Function
......
......@@ -266,9 +266,9 @@ private async Task<IList<SymbolReference>> GetMatchingTypesAsync(SearchScope sea
var options = workspaceServices.Workspace.Options;
var searchReferenceAssemblies = options.GetOption(
AddImportOptions.SuggestForTypesInReferenceAssemblies, language);
SymbolSearchOptions.SuggestForTypesInReferenceAssemblies, language);
var searchNugetPackages = options.GetOption(
AddImportOptions.SuggestForTypesInNuGetPackages, language);
SymbolSearchOptions.SuggestForTypesInNuGetPackages, language);
if (symbolSearchService != null &&
searchReferenceAssemblies)
......
......@@ -372,9 +372,7 @@
<Compile Include="RemoveUnnecessaryImports\AbstractRemoveUnnecessaryImportsService.cs" />
<Compile Include="ReplaceMethodWithProperty\ReplaceMethodWithPropertyCodeRefactoringProvider.cs" />
<Compile Include="ReplaceMethodWithProperty\IReplaceMethodWithPropertyService.cs" />
<Compile Include="Shared\Options\AddImportOptionsProvider.cs" />
<Compile Include="Shared\Extensions\ProjectExtensions.cs" />
<Compile Include="Shared\Options\AddImportOptions.cs" />
<Compile Include="Shared\Options\ServiceComponentOnOffOptionsProvider.cs" />
<Compile Include="Shared\Options\ServiceFeatureOnOffOptions.cs" />
<Compile Include="Shared\Options\ServiceFeatureOnOffOptionsProvider.cs" />
......
......@@ -10,7 +10,5 @@ namespace Microsoft.CodeAnalysis.Shared.Options
internal static class ServiceComponentOnOffOptions
{
public static readonly Option<bool> DiagnosticProvider = new Option<bool>(nameof(ServiceComponentOnOffOptions), nameof(DiagnosticProvider), defaultValue: true);
public static readonly Option<bool> SymbolSearch = new Option<bool>(nameof(ServiceComponentOnOffOptions), nameof(SymbolSearch), defaultValue: true);
}
}
}
\ No newline at end of file
......@@ -12,8 +12,7 @@ namespace Microsoft.CodeAnalysis.Shared.Options
internal class ServiceComponentOnOffOptionsProvider : IOptionProvider
{
private readonly IEnumerable<IOption> _options = ImmutableArray.Create(
ServiceComponentOnOffOptions.DiagnosticProvider,
ServiceComponentOnOffOptions.SymbolSearch);
ServiceComponentOnOffOptions.DiagnosticProvider);
public IEnumerable<IOption> GetOptions() => _options;
}
......
......@@ -7,6 +7,7 @@
using Microsoft.CodeAnalysis.Editor.Shared.Options;
using Microsoft.CodeAnalysis.ExtractMethod;
using Microsoft.CodeAnalysis.Shared.Options;
using Microsoft.CodeAnalysis.SymbolSearch;
using Microsoft.VisualStudio.LanguageServices.Implementation;
using Microsoft.VisualStudio.LanguageServices.Implementation.Options;
......@@ -19,8 +20,8 @@ public AdvancedOptionPageControl(IServiceProvider serviceProvider) : base(servic
InitializeComponent();
BindToOption(PlaceSystemNamespaceFirst, GenerationOptions.PlaceSystemNamespaceFirst, LanguageNames.CSharp);
BindToOption(SuggestForTypesInReferenceAssemblies, AddImportOptions.SuggestForTypesInReferenceAssemblies, LanguageNames.CSharp);
BindToOption(SuggestForTypesInNuGetPackages, AddImportOptions.SuggestForTypesInNuGetPackages, LanguageNames.CSharp);
BindToOption(SuggestForTypesInReferenceAssemblies, SymbolSearchOptions.SuggestForTypesInReferenceAssemblies, LanguageNames.CSharp);
BindToOption(SuggestForTypesInNuGetPackages, SymbolSearchOptions.SuggestForTypesInNuGetPackages, LanguageNames.CSharp);
BindToOption(Split_string_literals_on_enter, SplitStringLiteralOptions.Enabled, LanguageNames.CSharp);
BindToOption(EnterOutliningMode, FeatureOnOffOptions.Outlining, LanguageNames.CSharp);
......
......@@ -15,6 +15,7 @@
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Shared.Options;
using Microsoft.CodeAnalysis.Simplification;
using Microsoft.CodeAnalysis.SymbolSearch;
namespace Microsoft.VisualStudio.LanguageServices.CSharp.Options
{
......@@ -359,14 +360,14 @@ public int SortUsings_PlaceSystemFirst
public int AddImport_SuggestForTypesInReferenceAssemblies
{
get { return GetBooleanOption(AddImportOptions.SuggestForTypesInReferenceAssemblies); }
set { SetBooleanOption(AddImportOptions.SuggestForTypesInReferenceAssemblies, value); }
get { return GetBooleanOption(SymbolSearchOptions.SuggestForTypesInReferenceAssemblies); }
set { SetBooleanOption(SymbolSearchOptions.SuggestForTypesInReferenceAssemblies, value); }
}
public int AddImport_SuggestForTypesInNuGetPackages
{
get { return GetBooleanOption(AddImportOptions.SuggestForTypesInNuGetPackages); }
set { SetBooleanOption(AddImportOptions.SuggestForTypesInNuGetPackages, value); }
get { return GetBooleanOption(SymbolSearchOptions.SuggestForTypesInNuGetPackages); }
set { SetBooleanOption(SymbolSearchOptions.SuggestForTypesInNuGetPackages, value); }
}
public int Space_AfterBasesColon
......
......@@ -15,6 +15,7 @@
using Microsoft.CodeAnalysis.Packaging;
using Microsoft.CodeAnalysis.Shared.Options;
using Microsoft.CodeAnalysis.Shared.Utilities;
using Microsoft.CodeAnalysis.SymbolSearch;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.ComponentModelHost;
using Microsoft.VisualStudio.Editor;
......@@ -61,9 +62,9 @@ internal partial class PackageInstallerService : AbstractDelayStartedService, IP
public PackageInstallerService(
VisualStudioWorkspaceImpl workspace,
IVsEditorAdaptersFactoryService editorAdaptersFactoryService)
: base(workspace, ServiceComponentOnOffOptions.SymbolSearch,
AddImportOptions.SuggestForTypesInReferenceAssemblies,
AddImportOptions.SuggestForTypesInNuGetPackages)
: base(workspace, SymbolSearchOptions.Enabled,
SymbolSearchOptions.SuggestForTypesInReferenceAssemblies,
SymbolSearchOptions.SuggestForTypesInNuGetPackages)
{
_workspace = workspace;
_editorAdaptersFactoryService = editorAdaptersFactoryService;
......
......@@ -87,9 +87,9 @@ private static IRemoteControlService CreateRemoteControlService(VSShell.SVsServi
string localSettingsDirectory,
Func<Exception, bool> reportAndSwallowException,
CancellationTokenSource cancellationTokenSource)
: base(workspace, ServiceComponentOnOffOptions.SymbolSearch,
AddImportOptions.SuggestForTypesInReferenceAssemblies,
AddImportOptions.SuggestForTypesInNuGetPackages)
: base(workspace, SymbolSearchOptions.Enabled,
SymbolSearchOptions.SuggestForTypesInReferenceAssemblies,
SymbolSearchOptions.SuggestForTypesInNuGetPackages)
{
if (remoteControlService == null)
{
......
......@@ -5,6 +5,7 @@ Imports Microsoft.CodeAnalysis.Editing
Imports Microsoft.CodeAnalysis.Editor.Shared.Options
Imports Microsoft.CodeAnalysis.ExtractMethod
Imports Microsoft.CodeAnalysis.Shared.Options
Imports Microsoft.CodeAnalysis.SymbolSearch
Imports Microsoft.VisualStudio.LanguageServices.Implementation
Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.Options
......@@ -15,8 +16,8 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.Options
InitializeComponent()
BindToOption(PlaceSystemNamespaceFirst, GenerationOptions.PlaceSystemNamespaceFirst, LanguageNames.VisualBasic)
BindToOption(SuggestForTypesInReferenceAssemblies, AddImportOptions.SuggestForTypesInReferenceAssemblies, LanguageNames.VisualBasic)
BindToOption(SuggestForTypesInNuGetPackages, AddImportOptions.SuggestForTypesInNuGetPackages, LanguageNames.VisualBasic)
BindToOption(SuggestForTypesInReferenceAssemblies, SymbolSearchOptions.SuggestForTypesInReferenceAssemblies, LanguageNames.VisualBasic)
BindToOption(SuggestForTypesInNuGetPackages, SymbolSearchOptions.SuggestForTypesInNuGetPackages, LanguageNames.VisualBasic)
BindToOption(EnableEndConstruct, FeatureOnOffOptions.EndConstruct, LanguageNames.VisualBasic)
BindToOption(EnableOutlining, FeatureOnOffOptions.Outlining, LanguageNames.VisualBasic)
......
......@@ -10,6 +10,7 @@ Imports Microsoft.CodeAnalysis.ExtractMethod
Imports Microsoft.CodeAnalysis.Options
Imports Microsoft.CodeAnalysis.Shared.Options
Imports Microsoft.CodeAnalysis.Simplification
Imports Microsoft.CodeAnalysis.SymbolSearch
Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.Options
<ComVisible(True)>
......@@ -207,19 +208,19 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.Options
Public Property Option_SuggestImportsForTypesInReferenceAssemblies As Boolean
Get
Return GetBooleanOption(AddImportOptions.SuggestForTypesInReferenceAssemblies)
Return GetBooleanOption(SymbolSearchOptions.SuggestForTypesInReferenceAssemblies)
End Get
Set(value As Boolean)
SetBooleanOption(AddImportOptions.SuggestForTypesInReferenceAssemblies, value)
SetBooleanOption(SymbolSearchOptions.SuggestForTypesInReferenceAssemblies, value)
End Set
End Property
Public Property Option_SuggestImportsForTypesInNuGetPackages As Boolean
Get
Return GetBooleanOption(AddImportOptions.SuggestForTypesInNuGetPackages)
Return GetBooleanOption(SymbolSearchOptions.SuggestForTypesInNuGetPackages)
End Get
Set(value As Boolean)
SetBooleanOption(AddImportOptions.SuggestForTypesInNuGetPackages, value)
SetBooleanOption(SymbolSearchOptions.SuggestForTypesInNuGetPackages, value)
End Set
End Property
......
using Microsoft.CodeAnalysis.Options;
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.CodeAnalysis.Shared.Options
using Microsoft.CodeAnalysis.Options;
namespace Microsoft.CodeAnalysis.SymbolSearch
{
internal class AddImportOptions
internal class SymbolSearchOptions
{
public static readonly Option<bool> Enabled = new Option<bool>(nameof(SymbolSearchOptions), nameof(Enabled), defaultValue: true);
public static PerLanguageOption<bool> SuggestForTypesInReferenceAssemblies =
new PerLanguageOption<bool>(nameof(AddImportOptions), nameof(SuggestForTypesInReferenceAssemblies), defaultValue: false,
new PerLanguageOption<bool>(nameof(SymbolSearchOptions), nameof(SuggestForTypesInReferenceAssemblies), defaultValue: false,
storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.SuggestForTypesInReferenceAssemblies"));
public static PerLanguageOption<bool> SuggestForTypesInNuGetPackages =
new PerLanguageOption<bool>(nameof(AddImportOptions), nameof(SuggestForTypesInNuGetPackages), defaultValue: false,
new PerLanguageOption<bool>(nameof(SymbolSearchOptions), nameof(SuggestForTypesInNuGetPackages), defaultValue: false,
storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.SuggestForTypesInNuGetPackages"));
}
}
using Microsoft.CodeAnalysis.Options;
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Options.Providers;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Composition;
namespace Microsoft.CodeAnalysis.Shared.Options
namespace Microsoft.CodeAnalysis.SymbolSearch
{
[ExportOptionProvider, Shared]
internal class AddImportOptionsProvider : IOptionProvider
internal class SymbolSearchOptionsProvider : IOptionProvider
{
private readonly IEnumerable<IOption> _options = ImmutableArray.Create<IOption>(
AddImportOptions.SuggestForTypesInReferenceAssemblies,
AddImportOptions.SuggestForTypesInNuGetPackages);
SymbolSearchOptions.Enabled,
SymbolSearchOptions.SuggestForTypesInReferenceAssemblies,
SymbolSearchOptions.SuggestForTypesInNuGetPackages);
public IEnumerable<IOption> GetOptions() => _options;
}
}
}
\ No newline at end of file
......@@ -493,6 +493,8 @@
<Compile Include="SymbolKey\SymbolKey.ArrayTypeSymbolKey.cs" />
<Compile Include="SymbolKey\SymbolKey.SymbolKeyWriter.cs" />
<Compile Include="SymbolKey\SymbolKey.cs" />
<Compile Include="SymbolSearch\SymbolSearchOptions.cs" />
<Compile Include="SymbolSearch\SymbolSearchOptionsProvider.cs" />
<Compile Include="SymbolSearch\ISymbolSearchService.cs" />
<Compile Include="FindSymbols\SymbolTree\ISymbolTreeInfoCacheService.cs" />
<Compile Include="FindSymbols\FindReferences\MetadataUnifyingEquivalenceComparer.cs" />
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册