Skip to content

Instantly share code, notes, and snippets.

@controlflow
Created April 30, 2023 19:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save controlflow/9f313dbcdda779e8ad8ba518caf4c7d8 to your computer and use it in GitHub Desktop.
Save controlflow/9f313dbcdda779e8ad8ba518caf4c7d8 to your computer and use it in GitHub Desktop.
#nullable enable
using System;
using JetBrains.Application.Progress;
using JetBrains.DocumentManagers.Transactions;
using JetBrains.ProjectModel;
using JetBrains.ReSharper.Feature.Services.Bulbs;
using JetBrains.ReSharper.Feature.Services.Daemon;
using JetBrains.ReSharper.Feature.Services.Intentions.Scoped.Scopes;
using JetBrains.TextControl;
namespace JetBrains.ReSharper.Feature.Services.QuickFixes.Scoped.Popups;
public sealed class FileScopedPopupAction : BulbActionBase
{
private readonly IScopedPopupBulbAction myScopedPopup;
private readonly IBulbAction myBulbAction;
private readonly IProjectFile myProjectFile;
private readonly IHighlighting myHighlighting;
public FileScopedPopupAction(IScopedPopupBulbAction scopedPopup, IBulbAction bulbAction, IProjectFile projectFile, IHighlighting highlighting)
{
myScopedPopup = scopedPopup;
myBulbAction = bulbAction;
myProjectFile = projectFile;
myHighlighting = highlighting;
}
public override /*Localized*/ string Text => myScopedPopup.GetScopedPopupText(myBulbAction);
protected override Action<ITextControl>? ExecutePsiTransaction(ISolution solution, IProgressIndicator progress) => null;
protected override Action<ITextControl>? ExecuteAfterPsiTransaction(
ISolution solution, IProjectModelTransactionCookie cookie, IProgressIndicator progress)
{
var fileScope = new ProjectFileScope(myProjectFile);
return myScopedPopup.ExecuteAction(solution, fileScope, myHighlighting, progress);
}
}
#nullable enable
using System;
using JetBrains.Application.Progress;
using JetBrains.DocumentManagers.Transactions;
using JetBrains.ProjectModel;
using JetBrains.ReSharper.Feature.Services.Bulbs;
using JetBrains.ReSharper.Feature.Services.Daemon;
using JetBrains.ReSharper.Feature.Services.Intentions.Scoped.Scopes;
using JetBrains.TextControl;
namespace JetBrains.ReSharper.Feature.Services.QuickFixes.Scoped.Popups;
public sealed class FileScopedPopupAction(
IScopedPopupBulbAction scopedPopup, IBulbAction bulbAction, IProjectFile projectFile, IHighlighting highlighting)
: BulbActionBase
{
public override /*Localized*/ string Text => scopedPopup.GetScopedPopupText(bulbAction);
protected override Action<ITextControl>? ExecutePsiTransaction(ISolution solution, IProgressIndicator progress) => null;
protected override Action<ITextControl>? ExecuteAfterPsiTransaction(
ISolution solution, IProjectModelTransactionCookie cookie, IProgressIndicator progress)
{
var fileScope = new ProjectFileScope(projectFile);
return myScopedPopup.ExecuteAction(solution, fileScope, highlighting, progress);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment