Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tmat committed Jul 9, 2024
1 parent cd328ca commit 5a029f2
Show file tree
Hide file tree
Showing 100 changed files with 241 additions and 410 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
return;

var action = await ConvertToRecordEngine.GetCodeActionAsync(
document, typeDeclaration, context.GetOptionsProvider(), cancellationToken).ConfigureAwait(false);
document, typeDeclaration, cancellationToken).ConfigureAwait(false);

if (action != null)
context.RegisterCodeFix(action, context.Diagnostics);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ internal static class ConvertToRecordEngine
SyntaxRemoveOptions.AddElasticMarker;

public static async Task<CodeAction?> GetCodeActionAsync(
Document document, TypeDeclarationSyntax typeDeclaration, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken)
Document document, TypeDeclarationSyntax typeDeclaration, CancellationToken cancellationToken)
{
// any type declared partial requires complex movement, don't offer refactoring
if (typeDeclaration.Modifiers.Any(SyntaxKind.PartialKeyword))
Expand Down Expand Up @@ -70,7 +70,6 @@ internal static class ConvertToRecordEngine
type,
positionalParameterInfos,
typeDeclaration,
fallbackOptions,
cancellationToken),
nameof(CSharpCodeFixesResources.Convert_to_positional_record));
// note: when adding nested actions, use string.Format(CSharpFeaturesResources.Convert_0_to_record, type.Name) as title string
Expand All @@ -82,7 +81,6 @@ private static async Task<Solution> ConvertToPositionalRecordAsync(
INamedTypeSymbol type,
ImmutableArray<PositionalParameterInfo> positionalParameterInfos,
TypeDeclarationSyntax typeDeclaration,
CodeActionOptionsProvider fallbackOptions,
CancellationToken cancellationToken)
{
var semanticModel = await document.GetRequiredSemanticModelAsync(cancellationToken).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ private class CustomFixAllProvider : FixAllProvider
fixAllContext.Project.Solution,
diagnostics,
fixAllContext.Progress,
#if CODE_STYLE
CodeActionOptions.DefaultProvider,
#else
fixAllContext.State.CodeActionOptionsProvider,
#endif
cancellationToken),
title);

Expand All @@ -71,7 +66,6 @@ private static async Task<Solution> FixAllByDocumentAsync(
Solution solution,
ImmutableArray<Diagnostic> diagnostics,
IProgress<CodeAnalysisProgress> progressTracker,
CodeActionOptionsProvider options,
CancellationToken cancellationToken)
{
// Use documentId instead of tree here because the
Expand All @@ -94,7 +88,7 @@ private static async Task<Solution> FixAllByDocumentAsync(
var document = newSolution.GetRequiredDocument(documentId);
using var _ = progressTracker.ItemCompletedScope(document.Name);

newSolution = await FixAllInDocumentAsync(document, diagnosticsInTree, options, cancellationToken).ConfigureAwait(false);
newSolution = await FixAllInDocumentAsync(document, diagnosticsInTree, cancellationToken).ConfigureAwait(false);
}

return newSolution;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
CodeAction.Create(
AnalyzersResources.Change_namespace_to_match_folder_structure,
cancellationToken => FixAllInDocumentAsync(context.Document, context.Diagnostics,
context.GetOptionsProvider(),
cancellationToken),
nameof(AnalyzersResources.Change_namespace_to_match_folder_structure)),
context.Diagnostics);
Expand All @@ -40,7 +39,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
return Task.CompletedTask;
}

private static async Task<Solution> FixAllInDocumentAsync(Document document, ImmutableArray<Diagnostic> diagnostics, CodeActionOptionsProvider options, CancellationToken cancellationToken)
private static async Task<Solution> FixAllInDocumentAsync(Document document, ImmutableArray<Diagnostic> diagnostics, CancellationToken cancellationToken)
{
// All the target namespaces should be the same for a given document
Debug.Assert(diagnostics.Select(diagnostic => diagnostic.Properties[MatchFolderAndNamespaceConstants.TargetNamespace]).Distinct().Count() == 1);
Expand All @@ -57,9 +56,6 @@ private static async Task<Solution> FixAllInDocumentAsync(Document document, Imm
var renameActionSet = await Renamer.RenameDocumentAsync(
documentWithInvalidFolders,
new DocumentRenameOptions(),
#if !CODE_STYLE
options,
#endif
documentWithInvalidFolders.Name,
newDocumentFolders: targetFolders,
cancellationToken: cancellationToken).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ namespace Microsoft.CodeAnalysis.Editor.CSharp.ChangeSignature;
[Name(PredefinedCommandHandlerNames.ChangeSignature)]
[method: ImportingConstructor]
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
internal sealed class CSharpChangeSignatureCommandHandler(IThreadingContext threadingContext, IGlobalOptionService globalOptions) : AbstractChangeSignatureCommandHandler(threadingContext, globalOptions)
internal sealed class CSharpChangeSignatureCommandHandler(IThreadingContext threadingContext) : AbstractChangeSignatureCommandHandler(threadingContext)
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@ namespace Microsoft.CodeAnalysis.Editor.CSharp.EventHookup;
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
internal sealed partial class EventHookupSessionManager(
IThreadingContext threadingContext,
IToolTipService toolTipService,
IGlobalOptionService globalOptions)
IToolTipService toolTipService)
{
public readonly IThreadingContext ThreadingContext = threadingContext;
private readonly IToolTipService _toolTipService = toolTipService;
private readonly IGlobalOptionService _globalOptions = globalOptions;

private IToolTipPresenter _toolTipPresenter;

Expand Down Expand Up @@ -113,7 +111,7 @@ internal void BeginSession(
Mutex testSessionHookupMutex)
{
CurrentSession = new EventHookupSession(
this, eventHookupCommandHandler, textView, subjectBuffer, position, document, asyncListener, _globalOptions, testSessionHookupMutex);
this, eventHookupCommandHandler, textView, subjectBuffer, position, document, asyncListener, testSessionHookupMutex);
}

public void DismissExistingSessions()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ internal class EventHookupSession
private readonly ITrackingSpan _trackingSpan;
private readonly ITextView _textView;
private readonly ITextBuffer _subjectBuffer;
private readonly IGlobalOptionService _globalOptions;

public event Action Dismissed = () => { };

Expand Down Expand Up @@ -90,7 +89,6 @@ public EventHookupSession(
int position,
Document document,
IAsynchronousOperationListener asyncListener,
IGlobalOptionService globalOptions,
Mutex testSessionHookupMutex)
{
_threadingContext = eventHookupSessionManager.ThreadingContext;
Expand All @@ -100,7 +98,6 @@ public EventHookupSession(
var cancellationToken = _cancellationTokenSource.Token;
_textView = textView;
_subjectBuffer = subjectBuffer;
_globalOptions = globalOptions;
this.TESTSessionHookupMutex = testSessionHookupMutex;

// If the caret is at the end of the document we just create an empty span
Expand Down Expand Up @@ -179,7 +176,6 @@ public EventHookupSession(
new SymbolKindOrTypeKind(MethodKind.Ordinary),
new DeclarationModifiers(isStatic: plusEqualsToken.Value.GetRequiredParent().IsInStaticContext()),
Accessibility.Private,
_globalOptions.CreateProvider(),
cancellationToken).ConfigureAwait(false);

return GetEventHandlerName(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@ internal abstract class AbstractChangeSignatureCommandHandler : ICommandHandler<
ICommandHandler<RemoveParametersCommandArgs>
{
private readonly IThreadingContext _threadingContext;
private readonly IGlobalOptionService _globalOptions;

protected AbstractChangeSignatureCommandHandler(IThreadingContext threadingContext, IGlobalOptionService globalOptions)
protected AbstractChangeSignatureCommandHandler(IThreadingContext threadingContext)
{
_threadingContext = threadingContext;
_globalOptions = globalOptions;
}

public string DisplayName => EditorFeaturesResources.Change_Signature;
Expand Down
Loading

0 comments on commit 5a029f2

Please sign in to comment.