Skip to content

Commit

Permalink
3
Browse files Browse the repository at this point in the history
  • Loading branch information
tmat committed Feb 5, 2022
1 parent 3705067 commit 4213f88
Show file tree
Hide file tree
Showing 48 changed files with 421 additions and 383 deletions.
8 changes: 4 additions & 4 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.Editor.GoToBase;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Options;

namespace Microsoft.CodeAnalysis.Editor.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()
public CSharpGoToBaseService(IGlobalOptionService options)
: base(options)
{
}
}
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 All @@ -18,8 +19,9 @@ internal class CSharpGoToDefinitionService : AbstractGoToDefinitionService
[SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")]
public CSharpGoToDefinitionService(
IThreadingContext threadingContext,
IStreamingFindUsagesPresenter streamingPresenter)
: base(threadingContext, streamingPresenter)
IStreamingFindUsagesPresenter streamingPresenter,
IGlobalOptionService globalOptions)
: base(threadingContext, streamingPresenter, globalOptions)
{
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@
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)]
public CSharpGoToSymbolService(IThreadingContext threadingContext)
: base(threadingContext)
public CSharpGoToSymbolService(IThreadingContext threadingContext, IGlobalOptionService globalOptions)
: base(threadingContext, globalOptions)
{
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -591,9 +591,9 @@ protected override async Task AssertContentIsAsync(
var streamingPresenter = workspace.ExportProvider.GetExport<IStreamingFindUsagesPresenter>();
var quickInfoItem = await IntellisenseQuickInfoBuilder.BuildItemAsync(
trackingSpan.Object, info, document,
threadingContext, operationExecutor,
workspace.GlobalOptions, threadingContext, operationExecutor,
AsynchronousOperationListenerProvider.NullListener,
streamingPresenter, CancellationToken.None);
streamingPresenter, CancellationToken.None);;
var containerElement = quickInfoItem.Item as ContainerElement;

var textElements = containerElement.Elements.OfType<ClassifiedTextElement>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Microsoft.CodeAnalysis.ErrorReporting;
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 @@ -20,6 +20,7 @@
using Roslyn.Utilities;
using VSCommanding = Microsoft.VisualStudio.Commanding;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Options;

namespace Microsoft.CodeAnalysis.Editor.Implementation.NavigationCommandHandlers
{
Expand All @@ -30,19 +31,22 @@ internal sealed class FindDerivedSymbolsCommandHandler :
AbstractNavigationCommandHandler<FindDerivedSymbolsCommandArgs>
{
private readonly IAsynchronousOperationListener _asyncListener;
private readonly IGlobalOptionService _globalOptions;

public override string DisplayName => nameof(FindDerivedSymbolsCommandHandler);

[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public FindDerivedSymbolsCommandHandler(
[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 @@ -105,7 +109,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.FindSymbols;
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 @@ -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.TestHooks;
using Microsoft.VisualStudio.Commanding;
using Microsoft.VisualStudio.Text.Editor.Commanding.Commands.Navigation;
Expand All @@ -31,19 +32,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 @@ -131,7 +135,7 @@ private async Task FindImplementingMembersAsync(
}
}

private static async Task InspectInterfaceAsync(
private async Task InspectInterfaceAsync(
IFindUsagesContext context, INamedTypeSymbol interfaceSymbol, INamedTypeSymbol namedTypeSymbol, Project project, CancellationToken cancellationToken)
{
foreach (var interfaceMember in interfaceSymbol.GetMembers())
Expand All @@ -143,7 +147,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 @@ -19,6 +19,7 @@
using VSCommanding = Microsoft.VisualStudio.Commanding;
using Microsoft.CodeAnalysis.Host.Mef;
using System.Threading;
using Microsoft.CodeAnalysis.Options;

namespace Microsoft.CodeAnalysis.Editor.Implementation.NavigationCommandHandlers
{
Expand All @@ -29,19 +30,22 @@ internal sealed class FindMemberOverloadsCommandHandler :
AbstractNavigationCommandHandler<FindMemberOverloadsCommandArgs>
{
private readonly IAsynchronousOperationListener _asyncListener;
private readonly IGlobalOptionService _globalOptions;

public override string DisplayName => nameof(FindMemberOverloadsCommandHandler);

[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public FindMemberOverloadsCommandHandler(
[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
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,
_taggerProvider.ThreadingContext,
_taggerProvider.OperationExecutor,
_taggerProvider.AsynchronousOperationListener,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,10 @@ public FindLiteralsProgressAdapter(

public async ValueTask OnReferenceFoundAsync(Document document, TextSpan span, CancellationToken cancellationToken)
{
// TODO:
// var options = await _context.GetOptionsAsync(document.Project.Language, cancellationToken).ConfigureAwait(false);
var classificationOptions = ClassificationOptions.From(document.Project);
var options = await _context.GetOptionsAsync(document.Project.Language, cancellationToken).ConfigureAwait(false);

var documentSpan = await ClassifiedSpansAndHighlightSpanFactory.GetClassifiedDocumentSpanAsync(
document, span, classificationOptions, cancellationToken).ConfigureAwait(false);
document, span, options.ClassificationOptions, cancellationToken).ConfigureAwait(false);

await _context.OnReferenceFoundAsync(
new SourceReferenceItem(_definition, documentSpan, SymbolUsageInfo.None), cancellationToken).ConfigureAwait(false);
Expand Down Expand Up @@ -105,10 +103,11 @@ private async ValueTask<DefinitionItem> GetDefinitionItemAsync(SymbolGroup group
if (!_definitionToItem.TryGetValue(group, out var definitionItem))
{
definitionItem = await group.ToClassifiedDefinitionItemAsync(
_context,
_solution,
_options,
isPrimary: _definitionToItem.Count == 0,
includeHiddenLocations: false,
_options,
cancellationToken).ConfigureAwait(false);

_definitionToItem[group] = definitionItem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ await context.SetSearchTitleAsync(
foreach (var implementation in implementations)
{
var definitionItem = await implementation.ToClassifiedDefinitionItemAsync(
solution, isPrimary: true, includeHiddenLocations: false, FindReferencesSearchOptions.Default, cancellationToken).ConfigureAwait(false);
context, solution, FindReferencesSearchOptions.Default, isPrimary: true, includeHiddenLocations: false, cancellationToken).ConfigureAwait(false);

await context.OnDefinitionFoundAsync(definitionItem, cancellationToken).ConfigureAwait(false);
}
Expand Down
Loading

0 comments on commit 4213f88

Please sign in to comment.