How to Catch or Listen for Code Cleanup dialog Run/Cancel Buttons

I'm writing a plugin. I'd like to catch the Code Cleanup dialog Run and Cancel button clicks. Can you point me in the right direction? Thanks.

1 comment
Comment actions Permalink

// helpful links:
// https://confluence.jetbrains.com/display/NETCOM/Code+Cleanup
// https://github.com/StyleCop/StyleCop.ReSharper

[CodeCleanupModule]
public class MyCodeCleanupModule : ICodeCleanupModule {
public void SetDefaultSetting(
CodeCleanupProfile profile,
CodeCleanup.DefaultProfileType profileType) { }

public bool IsAvailable(IPsiSourceFile sourceFile) =>
sourceFile.GetDominantPsiFile<CSharpLanguage>() != null;

public void Process(
IPsiSourceFile projectFile,
IRangeMarker rangeMarker,
CodeCleanupProfile profile,
IProgressIndicator progressIndicator) {

var solution = projectFile.GetSolution();
var services = solution.GetPsiServices();
services.Transactions.Execute("My code cleanup", () =>
{ Lifetimes.Using(lifetime => { /* do stuff here */ }); });
}

public PsiLanguageType LanguageType => CSharpLanguage.Instance;

public ICollection<CodeCleanupOptionDescriptor> Descriptors =>
new List<CodeCleanupOptionDescriptor>();

public bool IsAvailableOnSelection => false;
}

0

Please sign in to leave a comment.