Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Revert "Make solution options global"" #59567

Merged
merged 1 commit into from
Feb 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 class CSharpGoToBaseService : AbstractGoToBaseService
internal sealed 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,6 +8,7 @@
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,11 +7,12 @@
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 class CSharpGoToSymbolService : AbstractGoToSymbolService
internal sealed class CSharpGoToSymbolService : AbstractGoToSymbolService
{
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ public async Task TestGetTagsOnBufferTagger()
using var workspace = TestWorkspace.CreateCSharp("class C { C c; }");
var document = workspace.Documents.First();

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

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

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,8 +193,7 @@ private static async Task<QuickInfoItem> GetQuickinfo(TestWorkspace workspace, D
{
var diagnosticAnalyzerService = workspace.ExportProvider.GetExportedValue<IDiagnosticAnalyzerService>();
var provider = new CSharpDiagnosticAnalyzerQuickInfoProvider(diagnosticAnalyzerService);
var options = SymbolDescriptionOptions.From(document.Project);
var info = await provider.GetQuickInfoAsync(new QuickInfoContext(document, position, options, CancellationToken.None));
var info = await provider.GetQuickInfoAsync(new QuickInfoContext(document, position, SymbolDescriptionOptions.Default, CancellationToken.None));
return info;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
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 @@ -568,8 +569,7 @@ protected override async Task AssertNoContentAsync(
int position)
{
var provider = CreateProvider();
var options = SymbolDescriptionOptions.From(document.Project);
Assert.Null(await provider.GetQuickInfoAsync(new QuickInfoContext(document, position, options, CancellationToken.None)));
Assert.Null(await provider.GetQuickInfoAsync(new QuickInfoContext(document, position, SymbolDescriptionOptions.Default, CancellationToken.None)));
}

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

Expand All @@ -591,7 +590,7 @@ protected override async Task AssertContentIsAsync(
var streamingPresenter = workspace.ExportProvider.GetExport<IStreamingFindUsagesPresenter>();
var quickInfoItem = await IntellisenseQuickInfoBuilder.BuildItemAsync(
trackingSpan.Object, info, document,
threadingContext, operationExecutor,
ClassificationOptions.Default, 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,6 +11,7 @@
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 @@ -28,19 +29,22 @@ 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)
IAsynchronousOperationListenerProvider listenerProvider,
IGlobalOptionService globalOptions)
: 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 @@ -83,7 +87,7 @@ private async Task StreamingFindBaseSymbolsAsync(
return;
}

var definitionItem = overriddenSymbol.ToNonClassifiedDefinitionItem(document.Project.Solution, true);
var definitionItem = overriddenSymbol.ToNonClassifiedDefinitionItem(document.Project.Solution, includeHiddenLocations: 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, true);
var definitionItem = candidate.ToNonClassifiedDefinitionItem(document.Project.Solution, includeHiddenLocations: true);
await context.OnDefinitionFoundAsync(definitionItem, cancellationToken).ConfigureAwait(false);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
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 @@ -32,19 +33,22 @@ 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)
IAsynchronousOperationListenerProvider listenerProvider,
IGlobalOptionService globalOptions)
: 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 @@ -109,7 +113,7 @@ private async Task FindExtensionMethodsAsync(
{
var originatingProject = solution.GetProject(sourceDefinition.ContainingAssembly, cancellationToken);

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

await context.OnDefinitionFoundAsync(definitionItem, cancellationToken).ConfigureAwait(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
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 @@ -30,19 +31,22 @@ 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)
IAsynchronousOperationListenerProvider listenerProvider,
IGlobalOptionService globalOptions)
: 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 @@ -142,7 +146,7 @@ private static async Task InspectInterfaceAsync(
if (impl == null)
continue;

var definitionItem = impl.ToNonClassifiedDefinitionItem(project.Solution, true);
var definitionItem = impl.ToNonClassifiedDefinitionItem(project.Solution, includeHiddenLocations: true);
await context.OnDefinitionFoundAsync(definitionItem, cancellationToken).ConfigureAwait(false);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,21 @@
// 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: 3 additions & 4 deletions src/EditorFeatures/Core.Wpf/InlineHints/InlineHintsTag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using Microsoft.CodeAnalysis.Editor.Host;
using Microsoft.CodeAnalysis.Classification;
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 @@ -35,7 +33,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 class InlineHintsTag : IntraTextAdornmentTag
internal sealed class InlineHintsTag : IntraTextAdornmentTag
{
public const string TagId = "inline hints";

Expand Down Expand Up @@ -101,6 +99,7 @@ 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,15 +3,13 @@
// See the LICENSE file in the project root for more information.

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

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)
=> throw new NotImplementedException();
#pragma warning restore IDE0060 // Remove unused parameter
=> new(ClassificationOptions: globalOptions.GetClassificationOptions(language));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
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,6 +6,7 @@
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,6 +16,7 @@
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