Skip to content

Commit

Permalink
Revert "Make solution options global (#59168)"
Browse files Browse the repository at this point in the history
This reverts commit f52633c.
  • Loading branch information
RikkiGibson authored Feb 14, 2022
1 parent c74fc4e commit 407eb1c
Show file tree
Hide file tree
Showing 90 changed files with 978 additions and 804 deletions.
6 changes: 3 additions & 3 deletions src/EditorFeatures/CSharp/GoToBase/CSharpGoToBaseService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable disable

using System;
using System.Composition;
using Microsoft.CodeAnalysis.GoToBase;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Options;

namespace Microsoft.CodeAnalysis.CSharp.GoToBase
{
[ExportLanguageService(typeof(IGoToBaseService), LanguageNames.CSharp), Shared]
internal sealed class CSharpGoToBaseService : AbstractGoToBaseService
internal class CSharpGoToBaseService : AbstractGoToBaseService
{
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public CSharpGoToBaseService()
: base()
{
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using Microsoft.CodeAnalysis.Editor.Host;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Options;

namespace Microsoft.CodeAnalysis.Editor.CSharp.GoToDefinition
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
using Microsoft.CodeAnalysis.Editor.GoToDefinition;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Options;

namespace Microsoft.CodeAnalysis.Editor.CSharp.GoToDefinition
{
[ExportLanguageService(typeof(IGoToSymbolService), LanguageNames.CSharp), Shared]
internal sealed class CSharpGoToSymbolService : AbstractGoToSymbolService
internal class CSharpGoToSymbolService : AbstractGoToSymbolService
{
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@ public async Task TestGetTagsOnBufferTagger()
using var workspace = TestWorkspace.CreateCSharp("class C { C c; }");
var document = workspace.Documents.First();

var listenerProvider = workspace.GetService<IAsynchronousOperationListenerProvider>();
var listenerProvider = workspace.ExportProvider.GetExportedValue<IAsynchronousOperationListenerProvider>();

var provider = new CopyPasteAndPrintingClassificationBufferTaggerProvider(
workspace.GetService<IThreadingContext>(),
workspace.GetService<ClassificationTypeMap>(),
listenerProvider,
workspace.GlobalOptions);
workspace.ExportProvider.GetExportedValue<IThreadingContext>(),
workspace.ExportProvider.GetExportedValue<ClassificationTypeMap>(),
listenerProvider);

var tagger = provider.CreateTagger<IClassificationTag>(document.GetTextBuffer())!;
using var disposable = (IDisposable)tagger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ private static async Task<QuickInfoItem> GetQuickinfo(TestWorkspace workspace, D
{
var diagnosticAnalyzerService = workspace.ExportProvider.GetExportedValue<IDiagnosticAnalyzerService>();
var provider = new CSharpDiagnosticAnalyzerQuickInfoProvider(diagnosticAnalyzerService);
var info = await provider.GetQuickInfoAsync(new QuickInfoContext(document, position, SymbolDescriptionOptions.Default, CancellationToken.None));
var options = SymbolDescriptionOptions.From(document.Project);
var info = await provider.GetQuickInfoAsync(new QuickInfoContext(document, position, options, CancellationToken.None));
return info;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Classification;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.QuickInfo;
using Microsoft.CodeAnalysis.Editor.Host;
Expand Down Expand Up @@ -569,7 +568,8 @@ protected override async Task AssertNoContentAsync(
int position)
{
var provider = CreateProvider();
Assert.Null(await provider.GetQuickInfoAsync(new QuickInfoContext(document, position, SymbolDescriptionOptions.Default, CancellationToken.None)));
var options = SymbolDescriptionOptions.From(document.Project);
Assert.Null(await provider.GetQuickInfoAsync(new QuickInfoContext(document, position, options, CancellationToken.None)));
}

protected override async Task AssertContentIsAsync(
Expand All @@ -580,7 +580,8 @@ protected override async Task AssertContentIsAsync(
string expectedDocumentationComment = null)
{
var provider = CreateProvider();
var info = await provider.GetQuickInfoAsync(new QuickInfoContext(document, position, SymbolDescriptionOptions.Default, CancellationToken.None));
var options = SymbolDescriptionOptions.From(document.Project);
var info = await provider.GetQuickInfoAsync(new QuickInfoContext(document, position, options, CancellationToken.None));
Assert.NotNull(info);
Assert.NotEqual(0, info.RelatedSpans.Length);

Expand All @@ -590,7 +591,7 @@ protected override async Task AssertContentIsAsync(
var streamingPresenter = workspace.ExportProvider.GetExport<IStreamingFindUsagesPresenter>();
var quickInfoItem = await IntellisenseQuickInfoBuilder.BuildItemAsync(
trackingSpan.Object, info, document,
ClassificationOptions.Default, threadingContext, operationExecutor,
threadingContext, operationExecutor,
AsynchronousOperationListenerProvider.NullListener,
streamingPresenter, CancellationToken.None);
var containerElement = quickInfoItem.Item as ContainerElement;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using Microsoft.CodeAnalysis.FindUsages;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Internal.Log;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Shared.TestHooks;
using Microsoft.VisualStudio.Commanding;
Expand All @@ -29,22 +28,19 @@ internal sealed class FindBaseSymbolsCommandHandler :
AbstractNavigationCommandHandler<FindBaseSymbolsCommandArgs>
{
private readonly IAsynchronousOperationListener _asyncListener;
private readonly IGlobalOptionService _globalOptions;

public override string DisplayName => nameof(FindBaseSymbolsCommandHandler);

[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public FindBaseSymbolsCommandHandler(
[ImportMany] IEnumerable<Lazy<IStreamingFindUsagesPresenter>> streamingPresenters,
IAsynchronousOperationListenerProvider listenerProvider,
IGlobalOptionService globalOptions)
IAsynchronousOperationListenerProvider listenerProvider)
: base(streamingPresenters)
{
Contract.ThrowIfNull(listenerProvider);

_asyncListener = listenerProvider.GetListener(FeatureAttribute.FindReferences);
_globalOptions = globalOptions;
}

protected override bool TryExecuteCommand(int caretPosition, Document document, CommandExecutionContext context)
Expand Down Expand Up @@ -87,7 +83,7 @@ private async Task StreamingFindBaseSymbolsAsync(
return;
}

var definitionItem = overriddenSymbol.ToNonClassifiedDefinitionItem(document.Project.Solution, includeHiddenLocations: true);
var definitionItem = overriddenSymbol.ToNonClassifiedDefinitionItem(document.Project.Solution, true);
await context.OnDefinitionFoundAsync(definitionItem, cancellationToken).ConfigureAwait(false);

// try getting the next one
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
// See the LICENSE file in the project root for more information.

using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Editor.Host;
using Microsoft.CodeAnalysis.ErrorReporting;
using Microsoft.CodeAnalysis.FindSymbols;
using Microsoft.CodeAnalysis.FindUsages;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Internal.Log;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Shared.TestHooks;
using Microsoft.VisualStudio.Commanding;
using Microsoft.VisualStudio.Text.Editor.Commanding.Commands.Navigation;
using Microsoft.VisualStudio.Utilities;
using Roslyn.Utilities;
using VSCommanding = Microsoft.VisualStudio.Commanding;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.FindUsages;

namespace Microsoft.CodeAnalysis.Editor.Implementation.NavigationCommandHandlers
{
Expand Down Expand Up @@ -105,7 +105,7 @@ private async Task FindDerivedSymbolsAsync(

foreach (var candidate in candidates)
{
var definitionItem = candidate.ToNonClassifiedDefinitionItem(document.Project.Solution, includeHiddenLocations: true);
var definitionItem = candidate.ToNonClassifiedDefinitionItem(document.Project.Solution, true);
await context.OnDefinitionFoundAsync(definitionItem, cancellationToken).ConfigureAwait(false);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
using Microsoft.CodeAnalysis.FindUsages;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Internal.Log;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Shared.TestHooks;
using Microsoft.VisualStudio.Commanding;
Expand All @@ -33,22 +32,19 @@ internal sealed class FindExtensionMethodsCommandHandler :
AbstractNavigationCommandHandler<FindExtensionMethodsCommandArgs>
{
private readonly IAsynchronousOperationListener _asyncListener;
private readonly IGlobalOptionService _globalOptions;

public override string DisplayName => nameof(FindExtensionMethodsCommandHandler);

[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public FindExtensionMethodsCommandHandler(
[ImportMany] IEnumerable<Lazy<IStreamingFindUsagesPresenter>> streamingPresenters,
IAsynchronousOperationListenerProvider listenerProvider,
IGlobalOptionService globalOptions)
IAsynchronousOperationListenerProvider listenerProvider)
: base(streamingPresenters)
{
Contract.ThrowIfNull(listenerProvider);

_asyncListener = listenerProvider.GetListener(FeatureAttribute.FindReferences);
_globalOptions = globalOptions;
}

protected override bool TryExecuteCommand(int caretPosition, Document document, CommandExecutionContext context)
Expand Down Expand Up @@ -113,7 +109,7 @@ private async Task FindExtensionMethodsAsync(
{
var originatingProject = solution.GetProject(sourceDefinition.ContainingAssembly, cancellationToken);

var definitionItem = reducedMethod.ToNonClassifiedDefinitionItem(solution, includeHiddenLocations: true);
var definitionItem = reducedMethod.ToNonClassifiedDefinitionItem(solution, true);

await context.OnDefinitionFoundAsync(definitionItem, cancellationToken).ConfigureAwait(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
using Microsoft.CodeAnalysis.FindUsages;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Internal.Log;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Shared.TestHooks;
using Microsoft.VisualStudio.Commanding;
using Microsoft.VisualStudio.Text.Editor.Commanding.Commands.Navigation;
Expand All @@ -31,22 +30,19 @@ internal sealed class FindImplementingMembersCommandHandler :
AbstractNavigationCommandHandler<FindImplementingMembersCommandArgs>
{
private readonly IAsynchronousOperationListener _asyncListener;
private readonly IGlobalOptionService _globalOptions;

public override string DisplayName => nameof(FindImplementingMembersCommandHandler);

[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public FindImplementingMembersCommandHandler(
[ImportMany] IEnumerable<Lazy<IStreamingFindUsagesPresenter>> streamingPresenters,
IAsynchronousOperationListenerProvider listenerProvider,
IGlobalOptionService globalOptions)
IAsynchronousOperationListenerProvider listenerProvider)
: base(streamingPresenters)
{
Contract.ThrowIfNull(listenerProvider);

_asyncListener = listenerProvider.GetListener(FeatureAttribute.FindReferences);
_globalOptions = globalOptions;
}

protected override bool TryExecuteCommand(int caretPosition, Document document, CommandExecutionContext context)
Expand Down Expand Up @@ -146,7 +142,7 @@ private static async Task InspectInterfaceAsync(
if (impl == null)
continue;

var definitionItem = impl.ToNonClassifiedDefinitionItem(project.Solution, includeHiddenLocations: true);
var definitionItem = impl.ToNonClassifiedDefinitionItem(project.Solution, true);
await context.OnDefinitionFoundAsync(definitionItem, cancellationToken).ConfigureAwait(false);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,22 @@
// See the LICENSE file in the project root for more information.

using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Editor.Host;
using Microsoft.CodeAnalysis.ErrorReporting;
using Microsoft.CodeAnalysis.FindUsages;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Internal.Log;
using Microsoft.CodeAnalysis.Shared.TestHooks;
using Microsoft.VisualStudio.Commanding;
using Microsoft.VisualStudio.Text.Editor.Commanding.Commands.Navigation;
using Microsoft.VisualStudio.Utilities;
using Roslyn.Utilities;
using VSCommanding = Microsoft.VisualStudio.Commanding;
using Microsoft.CodeAnalysis.Host.Mef;
using System.Threading;
using Microsoft.CodeAnalysis.FindUsages;

namespace Microsoft.CodeAnalysis.Editor.Implementation.NavigationCommandHandlers
{
Expand Down
7 changes: 4 additions & 3 deletions src/EditorFeatures/Core.Wpf/InlineHints/InlineHintsTag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using Microsoft.CodeAnalysis.Classification;
using Microsoft.CodeAnalysis.Editor.Host;
using Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.QuickInfo;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.Elfie.Diagnostics;
using Microsoft.CodeAnalysis.InlineHints;
using Microsoft.CodeAnalysis.Internal.Log;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Text;
using Microsoft.CodeAnalysis.Text.Shared.Extensions;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Adornments;
using Microsoft.VisualStudio.Text.Classification;
Expand All @@ -33,7 +35,7 @@ namespace Microsoft.CodeAnalysis.Editor.InlineHints
/// This is the tag which implements the IntraTextAdornmentTag and is meant to create the UIElements that get shown
/// in the editor
/// </summary>
internal sealed class InlineHintsTag : IntraTextAdornmentTag
internal class InlineHintsTag : IntraTextAdornmentTag
{
public const string TagId = "inline hints";

Expand Down Expand Up @@ -99,7 +101,6 @@ public async Task<IReadOnlyCollection<object>> CreateDescriptionAsync(Cancellati
{
var context = new IntellisenseQuickInfoBuilderContext(
document,
_taggerProvider.GlobalOptions.GetClassificationOptions(document.Project.Language),
_taggerProvider.ThreadingContext,
_taggerProvider.OperationExecutor,
_taggerProvider.AsynchronousOperationListener,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
// See the LICENSE file in the project root for more information.

using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Classification;
using System;

namespace Microsoft.CodeAnalysis.FindUsages
{
internal static class FindUsagesOptionsStorage
{
#pragma warning disable IDE0060 // Remove unused parameter -- TODO
public static FindUsagesOptions GetFindUsagesOptions(this IGlobalOptionService globalOptions, string language)
=> new(ClassificationOptions: globalOptions.GetClassificationOptions(language));
=> throw new NotImplementedException();
#pragma warning restore IDE0060 // Remove unused parameter
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
using Microsoft.CodeAnalysis.GoToDefinition;
using Microsoft.CodeAnalysis.LanguageServices;
using Microsoft.CodeAnalysis.Navigation;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Roslyn.Utilities;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.GoToDefinition;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Options;

namespace Microsoft.CodeAnalysis.Editor.GoToDefinition
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
using Microsoft.CodeAnalysis.FindUsages;
using Microsoft.CodeAnalysis.GoToDefinition;
using Microsoft.CodeAnalysis.Navigation;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Roslyn.Utilities;
Expand Down
Loading

0 comments on commit 407eb1c

Please sign in to comment.