bool IExecutableAction.Update(IDataContext dataContext, ActionPresentation presentation, DelegateUpdate nextUpdate) { var collector = CodeCleanupFilesCollector.TryCreate(dataContext); if (collector == null) { return(false); } var psiServices = collector.Solution.GetPsiServices(); if (!psiServices.Files.AllDocumentsAreCommitted || !psiServices.CachesState.IsInitialUpdateFinished.Value) { return(false); } switch (collector.GetActionScope()) { case ActionScope.None: case ActionScope.Selection: case ActionScope.File: return(false); case ActionScope.MultipleFiles: case ActionScope.Solution: case ActionScope.Directory: return(true); } return(false); }
void IExecutableAction.Execute(IDataContext context, DelegateExecute nextExecute) { var solution = context.GetData(ProjectModelDataConstants.SOLUTION); if (solution == null || !solution.GetPsiServices().Caches.WaitForCaches("CodeCleanupActionBase.Execute")) { return; } var collector = CodeCleanupFilesCollector.TryCreate(context).NotNull("collector != null"); context.GetComponent <IShellLocks>().ExecuteOrQueueReadLock( "CodeCleanupActionBase.Execute", () => { if (!solution.GetPsiServices().Caches.WaitForCaches("CodeCleanupActionBase.Execute")) { return; } var actionScope = collector.GetActionScope(); var profile = this.GetProfile(collector); if (profile == null) { return; } if (this.SaveProfileAsRecentlyUsed) { solution.GetComponent <CodeCleanupSettingsComponent>().SetRecentlyUsedProfileName( solution.GetComponent <ISettingsStore>().BindToContextTransient(ContextRange.Smart(collector.GetContext())), profile.Name); } switch (actionScope) { case ActionScope.MultipleFiles: case ActionScope.Solution: case ActionScope.Directory: var filteredProvider = this.TryGetFilteredProvider(collector); if (filteredProvider != null) { CodeCleanupRunner.CleanupFiles(filteredProvider, profile); } return; case ActionScope.None: case ActionScope.Selection: case ActionScope.File: return; default: return; } }); }
protected override CodeCleanupProfile GetProfile(CodeCleanupFilesCollector cleanupFilesCollector) { return(cleanupFilesCollector.Solution.GetComponent <CodeCleanupProfileSelector>() .SelectProfile(cleanupFilesCollector, false)); }