From 8bbd654ecf5373aef5b4984fc79437d2ce5ccbac Mon Sep 17 00:00:00 2001 From: CyrusNajmabadi Date: Wed, 28 Sep 2016 23:51:03 -0700 Subject: [PATCH] Move SymbolSearch options down to teh Workspace layer. --- .../AddUsing/AddUsingTests_NuGet.cs | 4 ++-- .../AddImport/AddImportTests_NuGet.vb | 4 ++-- ...rtCodeFixProvider.SymbolReferenceFinder.cs | 4 ++-- src/Features/Core/Portable/Features.csproj | 2 -- .../Shared/Options/AddImportOptions.cs | 15 ------------- .../Options/AddImportOptionsProvider.cs | 18 ---------------- .../Options/ServiceComponentOnOffOptions.cs | 4 +--- .../ServiceComponentOnOffOptionsProvider.cs | 3 +-- .../Options/AdvancedOptionPageControl.xaml.cs | 5 +++-- .../CSharp/Impl/Options/AutomationObject.cs | 9 ++++---- .../PackageInstallerServiceFactory.cs | 7 ++++--- .../Def/SymbolSearch/SymbolSearchService.cs | 6 +++--- .../Options/AdvancedOptionPageControl.xaml.vb | 5 +++-- .../Impl/Options/AutomationObject.vb | 9 ++++---- .../SymbolSearch/SymbolSearchOptions.cs | 19 +++++++++++++++++ .../SymbolSearchOptionsProvider.cs | 21 +++++++++++++++++++ .../Core/Portable/Workspaces.csproj | 2 ++ 17 files changed, 73 insertions(+), 64 deletions(-) delete mode 100644 src/Features/Core/Portable/Shared/Options/AddImportOptions.cs delete mode 100644 src/Features/Core/Portable/Shared/Options/AddImportOptionsProvider.cs create mode 100644 src/Workspaces/Core/Portable/SymbolSearch/SymbolSearchOptions.cs create mode 100644 src/Workspaces/Core/Portable/SymbolSearch/SymbolSearchOptionsProvider.cs diff --git a/src/EditorFeatures/CSharpTest/Diagnostics/AddUsing/AddUsingTests_NuGet.cs b/src/EditorFeatures/CSharpTest/Diagnostics/AddUsing/AddUsingTests_NuGet.cs index 8d2fed741de..ad4b7afcf93 100644 --- a/src/EditorFeatures/CSharpTest/Diagnostics/AddUsing/AddUsingTests_NuGet.cs +++ b/src/EditorFeatures/CSharpTest/Diagnostics/AddUsing/AddUsingTests_NuGet.cs @@ -34,8 +34,8 @@ protected override async Task 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; } diff --git a/src/EditorFeatures/VisualBasicTest/Diagnostics/AddImport/AddImportTests_NuGet.vb b/src/EditorFeatures/VisualBasicTest/Diagnostics/AddImport/AddImportTests_NuGet.vb index 7e78ede1fa1..ac381ca0b2f 100644 --- a/src/EditorFeatures/VisualBasicTest/Diagnostics/AddImport/AddImportTests_NuGet.vb +++ b/src/EditorFeatures/VisualBasicTest/Diagnostics/AddImport/AddImportTests_NuGet.vb @@ -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 diff --git a/src/Features/Core/Portable/CodeFixes/AddImport/AbstractAddImportCodeFixProvider.SymbolReferenceFinder.cs b/src/Features/Core/Portable/CodeFixes/AddImport/AbstractAddImportCodeFixProvider.SymbolReferenceFinder.cs index e19030d5575..5ad08888814 100644 --- a/src/Features/Core/Portable/CodeFixes/AddImport/AbstractAddImportCodeFixProvider.SymbolReferenceFinder.cs +++ b/src/Features/Core/Portable/CodeFixes/AddImport/AbstractAddImportCodeFixProvider.SymbolReferenceFinder.cs @@ -266,9 +266,9 @@ private async Task> 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) diff --git a/src/Features/Core/Portable/Features.csproj b/src/Features/Core/Portable/Features.csproj index 90a0a9e54c9..030206d56ea 100644 --- a/src/Features/Core/Portable/Features.csproj +++ b/src/Features/Core/Portable/Features.csproj @@ -372,9 +372,7 @@ - - diff --git a/src/Features/Core/Portable/Shared/Options/AddImportOptions.cs b/src/Features/Core/Portable/Shared/Options/AddImportOptions.cs deleted file mode 100644 index 3ffc3f9e5b3..00000000000 --- a/src/Features/Core/Portable/Shared/Options/AddImportOptions.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Microsoft.CodeAnalysis.Options; - -namespace Microsoft.CodeAnalysis.Shared.Options -{ - internal class AddImportOptions - { - public static PerLanguageOption SuggestForTypesInReferenceAssemblies = - new PerLanguageOption(nameof(AddImportOptions), nameof(SuggestForTypesInReferenceAssemblies), defaultValue: false, - storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.SuggestForTypesInReferenceAssemblies")); - - public static PerLanguageOption SuggestForTypesInNuGetPackages = - new PerLanguageOption(nameof(AddImportOptions), nameof(SuggestForTypesInNuGetPackages), defaultValue: false, - storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.SuggestForTypesInNuGetPackages")); - } -} diff --git a/src/Features/Core/Portable/Shared/Options/AddImportOptionsProvider.cs b/src/Features/Core/Portable/Shared/Options/AddImportOptionsProvider.cs deleted file mode 100644 index ebe37f4d267..00000000000 --- a/src/Features/Core/Portable/Shared/Options/AddImportOptionsProvider.cs +++ /dev/null @@ -1,18 +0,0 @@ -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 -{ - [ExportOptionProvider, Shared] - internal class AddImportOptionsProvider : IOptionProvider - { - private readonly IEnumerable _options = ImmutableArray.Create( - AddImportOptions.SuggestForTypesInReferenceAssemblies, - AddImportOptions.SuggestForTypesInNuGetPackages); - - public IEnumerable GetOptions() => _options; - } -} diff --git a/src/Features/Core/Portable/Shared/Options/ServiceComponentOnOffOptions.cs b/src/Features/Core/Portable/Shared/Options/ServiceComponentOnOffOptions.cs index 17c8c217663..f843b8d898d 100644 --- a/src/Features/Core/Portable/Shared/Options/ServiceComponentOnOffOptions.cs +++ b/src/Features/Core/Portable/Shared/Options/ServiceComponentOnOffOptions.cs @@ -10,7 +10,5 @@ namespace Microsoft.CodeAnalysis.Shared.Options internal static class ServiceComponentOnOffOptions { public static readonly Option DiagnosticProvider = new Option(nameof(ServiceComponentOnOffOptions), nameof(DiagnosticProvider), defaultValue: true); - - public static readonly Option SymbolSearch = new Option(nameof(ServiceComponentOnOffOptions), nameof(SymbolSearch), defaultValue: true); } -} +} \ No newline at end of file diff --git a/src/Features/Core/Portable/Shared/Options/ServiceComponentOnOffOptionsProvider.cs b/src/Features/Core/Portable/Shared/Options/ServiceComponentOnOffOptionsProvider.cs index 6d3fd5fd0e8..a258c719f54 100644 --- a/src/Features/Core/Portable/Shared/Options/ServiceComponentOnOffOptionsProvider.cs +++ b/src/Features/Core/Portable/Shared/Options/ServiceComponentOnOffOptionsProvider.cs @@ -12,8 +12,7 @@ namespace Microsoft.CodeAnalysis.Shared.Options internal class ServiceComponentOnOffOptionsProvider : IOptionProvider { private readonly IEnumerable _options = ImmutableArray.Create( - ServiceComponentOnOffOptions.DiagnosticProvider, - ServiceComponentOnOffOptions.SymbolSearch); + ServiceComponentOnOffOptions.DiagnosticProvider); public IEnumerable GetOptions() => _options; } diff --git a/src/VisualStudio/CSharp/Impl/Options/AdvancedOptionPageControl.xaml.cs b/src/VisualStudio/CSharp/Impl/Options/AdvancedOptionPageControl.xaml.cs index 2c19fcd2259..f44fa195a53 100644 --- a/src/VisualStudio/CSharp/Impl/Options/AdvancedOptionPageControl.xaml.cs +++ b/src/VisualStudio/CSharp/Impl/Options/AdvancedOptionPageControl.xaml.cs @@ -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); diff --git a/src/VisualStudio/CSharp/Impl/Options/AutomationObject.cs b/src/VisualStudio/CSharp/Impl/Options/AutomationObject.cs index db53cff5af8..1b5b53e718c 100644 --- a/src/VisualStudio/CSharp/Impl/Options/AutomationObject.cs +++ b/src/VisualStudio/CSharp/Impl/Options/AutomationObject.cs @@ -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 diff --git a/src/VisualStudio/Core/Def/Packaging/PackageInstallerServiceFactory.cs b/src/VisualStudio/Core/Def/Packaging/PackageInstallerServiceFactory.cs index 58ebae0260c..4fa0141da5a 100644 --- a/src/VisualStudio/Core/Def/Packaging/PackageInstallerServiceFactory.cs +++ b/src/VisualStudio/Core/Def/Packaging/PackageInstallerServiceFactory.cs @@ -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; diff --git a/src/VisualStudio/Core/Def/SymbolSearch/SymbolSearchService.cs b/src/VisualStudio/Core/Def/SymbolSearch/SymbolSearchService.cs index cd8a0551d35..6aae8a05442 100644 --- a/src/VisualStudio/Core/Def/SymbolSearch/SymbolSearchService.cs +++ b/src/VisualStudio/Core/Def/SymbolSearch/SymbolSearchService.cs @@ -87,9 +87,9 @@ private static IRemoteControlService CreateRemoteControlService(VSShell.SVsServi string localSettingsDirectory, Func reportAndSwallowException, CancellationTokenSource cancellationTokenSource) - : base(workspace, ServiceComponentOnOffOptions.SymbolSearch, - AddImportOptions.SuggestForTypesInReferenceAssemblies, - AddImportOptions.SuggestForTypesInNuGetPackages) + : base(workspace, SymbolSearchOptions.Enabled, + SymbolSearchOptions.SuggestForTypesInReferenceAssemblies, + SymbolSearchOptions.SuggestForTypesInNuGetPackages) { if (remoteControlService == null) { diff --git a/src/VisualStudio/VisualBasic/Impl/Options/AdvancedOptionPageControl.xaml.vb b/src/VisualStudio/VisualBasic/Impl/Options/AdvancedOptionPageControl.xaml.vb index 6583e99e8f4..274cce8c604 100644 --- a/src/VisualStudio/VisualBasic/Impl/Options/AdvancedOptionPageControl.xaml.vb +++ b/src/VisualStudio/VisualBasic/Impl/Options/AdvancedOptionPageControl.xaml.vb @@ -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) diff --git a/src/VisualStudio/VisualBasic/Impl/Options/AutomationObject.vb b/src/VisualStudio/VisualBasic/Impl/Options/AutomationObject.vb index a4c1e9131a9..1c2349f6c7b 100644 --- a/src/VisualStudio/VisualBasic/Impl/Options/AutomationObject.vb +++ b/src/VisualStudio/VisualBasic/Impl/Options/AutomationObject.vb @@ -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 @@ -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 diff --git a/src/Workspaces/Core/Portable/SymbolSearch/SymbolSearchOptions.cs b/src/Workspaces/Core/Portable/SymbolSearch/SymbolSearchOptions.cs new file mode 100644 index 00000000000..e62ed7ba083 --- /dev/null +++ b/src/Workspaces/Core/Portable/SymbolSearch/SymbolSearchOptions.cs @@ -0,0 +1,19 @@ +// 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; + +namespace Microsoft.CodeAnalysis.SymbolSearch +{ + internal class SymbolSearchOptions + { + public static readonly Option Enabled = new Option(nameof(SymbolSearchOptions), nameof(Enabled), defaultValue: true); + + public static PerLanguageOption SuggestForTypesInReferenceAssemblies = + new PerLanguageOption(nameof(SymbolSearchOptions), nameof(SuggestForTypesInReferenceAssemblies), defaultValue: false, + storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.SuggestForTypesInReferenceAssemblies")); + + public static PerLanguageOption SuggestForTypesInNuGetPackages = + new PerLanguageOption(nameof(SymbolSearchOptions), nameof(SuggestForTypesInNuGetPackages), defaultValue: false, + storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.SuggestForTypesInNuGetPackages")); + } +} diff --git a/src/Workspaces/Core/Portable/SymbolSearch/SymbolSearchOptionsProvider.cs b/src/Workspaces/Core/Portable/SymbolSearch/SymbolSearchOptionsProvider.cs new file mode 100644 index 00000000000..5c771b0d7df --- /dev/null +++ b/src/Workspaces/Core/Portable/SymbolSearch/SymbolSearchOptionsProvider.cs @@ -0,0 +1,21 @@ +// 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.SymbolSearch +{ + [ExportOptionProvider, Shared] + internal class SymbolSearchOptionsProvider : IOptionProvider + { + private readonly IEnumerable _options = ImmutableArray.Create( + SymbolSearchOptions.Enabled, + SymbolSearchOptions.SuggestForTypesInReferenceAssemblies, + SymbolSearchOptions.SuggestForTypesInNuGetPackages); + + public IEnumerable GetOptions() => _options; + } +} \ No newline at end of file diff --git a/src/Workspaces/Core/Portable/Workspaces.csproj b/src/Workspaces/Core/Portable/Workspaces.csproj index 75b53c6420b..cb1d5a2cd7c 100644 --- a/src/Workspaces/Core/Portable/Workspaces.csproj +++ b/src/Workspaces/Core/Portable/Workspaces.csproj @@ -493,6 +493,8 @@ + + -- GitLab