public void WhenTaskIsMoved_FiresTaskMoveEvent() { var task = new Task() { Title = "Title" }; var task2 = new Task() { Title = "Title2" }; var root = new Task() { SubTasks = new ObservableCollection <Task>() { task, task2 } }; task.Parent = root; task2.Parent = root; _repositoryMock.Setup(mock => mock.GetOpenTasks()).Returns(root.SubTasks); _repositoryMock.Setup(mock => mock.MoveTaskTo(task.Id, task2.Id, It.IsAny <int>())); LifetimeDefinition lifetimeDefinition = Lifetimes.Define("Test.lifetime"); var viewModel = new TaskViewModel(_repositoryMock.Object, lifetimeDefinition.Lifetime, _settingsRepoMock.Object); viewModel.TaskChange += OnReceiveEvent; viewModel.MoveSubtask(task2, task); Assert.AreEqual(TaskAction.Move, _eventArgs.Action); }
protected override Action <ITextControl> ExecutePsiTransaction(ISolution solution, IProgressIndicator progress) { var projectFile = (IProjectFile)_highlight.OffendingProjectItem; using (var cookie = solution.CreateTransactionCookie(DefaultAction.Rollback, this.GetType().Name, progress)) { IProjectFolder newFolder = (IProjectFolder)_highlight.TargetProject.FindProjectItemByLocation(_highlight.TargetFolder) ?? _highlight.TargetProject.GetOrCreateProjectFolder(_highlight.TargetFolder, cookie); var workflow = new MoveToFolderWorkflow(solution, "ManualMoveToFolderQuickFix"); IProjectFolder targetFolder = newFolder ?? _highlight.TargetProject; var dataProvider = new MoveToFolderDataProvider(true, false, targetFolder, new List <string>(), new List <string>()); workflow.SetDataProvider(dataProvider); Lifetimes.Using( (lifetime => WorkflowExecuter.ExecuteWithCustomHost( Shell.Instance.GetComponent <IActionManager>() .DataContexts.CreateWithoutDataRules(lifetime , DataRules.AddRule(DataRules.AddRule("ManualMoveToFolderQuickFix" , JetBrains.ProjectModel.DataContext.ProjectModelDataConstants.PROJECT_MODEL_ELEMENTS, new IProjectModelElement[] { projectFile }) , "ManualMoveToFolderQuickFix" , JetBrains.ProjectModel.DataContext.ProjectModelDataConstants.SOLUTION, solution)) , workflow, new SimpleWorkflowHost()))); cookie.Commit(progress); } return(null); }
private void AddFile([NotNull] IProjectFile projectFile, [NotNull] PsiModuleChangeBuilder changeBuilder) { ISolution solution = projectFile.GetSolution(); // creates a new T4PsiModule for the file LifetimeDefinition lifetimeDefinition = Lifetimes.Define(_lifetime, "[T4]" + projectFile.Name); var psiModule = new T4PsiModule( lifetimeDefinition.Lifetime, solution.GetComponent <PsiModuleManager>(), solution.GetComponent <DocumentManager>(), _changeManager, solution.GetComponent <IAssemblyFactory>(), _shellLocks, projectFile, solution.GetComponent <T4FileDataCache>(), _t4Environment, solution.GetComponent <OutputAssembliesCache>()); _modules[projectFile] = new ModuleWrapper(psiModule, lifetimeDefinition); changeBuilder.AddModuleChange(psiModule, PsiModuleChange.ChangeType.ADDED); changeBuilder.AddFileChange(psiModule.SourceFile, PsiModuleChange.ChangeType.ADDED); // Invalidate files that had this specific files as an include, // and whose IPsiSourceFile was previously managed by T4OutsideSolutionSourceFileManager. // Those files will be reparsed with the new source file. var fileManager = solution.GetComponent <T4OutsideSolutionSourceFileManager>(); FileSystemPath location = projectFile.Location; if (fileManager.HasSourceFile(location)) { fileManager.DeleteSourceFile(location); InvalidateFilesHavingInclude(location, solution.GetPsiServices()); } }
public UnitTestAnimations(Lifetime lifetime, IUnitTestSessionConductor sessionConductor, IUnitTestResultManager resultsManager, Agent agent, IThreading threading) { this.resultsManager = resultsManager; this.agent = agent; this.threading = threading; var testSessionLifetimes = new Dictionary <IUnitTestSessionTreeViewModel, LifetimeDefinition>(); sessionConductor.SessionOpened.Advise(lifetime, sessionView => { var sessionLifetimeDefinition = Lifetimes.Define(lifetime, "Clippy::TestSession"); testSessionLifetimes.Add(sessionView, sessionLifetimeDefinition); SubscribeToSessionLaunch(sessionLifetimeDefinition.Lifetime, sessionView.Session); }); sessionConductor.SessionClosed.Advise(lifetime, sessionView => { LifetimeDefinition sessionLifetimeDefinition; if (testSessionLifetimes.TryGetValue(sessionView, out sessionLifetimeDefinition)) { sessionLifetimeDefinition.Terminate(); testSessionLifetimes.Remove(sessionView); } }); }
public void WhenRepositoryIsRestarted_ShouldCreateNewIntervalOnActiveTask() { var task = new Task { IsActive = true }; task.Intervals.Add(new Interval()); var tasks = new ObservableCollection <Task> { task }; _repositoryMock.Setup(mock => mock.GetOpenTasks()).Returns(tasks); LifetimeDefinition lifetimeDefinition = Lifetimes.Define("Test.lifetime"); var viewModel = new TaskViewModel(_repositoryMock.Object, lifetimeDefinition.Lifetime, _settingsRepoMock.Object); viewModel.AddTask(task); viewModel.ActivateTask(task); lifetimeDefinition.Terminate(); Assert.AreEqual(1, task.Intervals.Count); var viewModel2 = new TaskViewModel(_repositoryMock.Object, Lifetimes.Define("Test.lifetime").Lifetime, _settingsRepoMock.Object); var activeTask = viewModel2.ActiveTask; Assert.AreEqual(2, activeTask.Intervals.Count); Assert.IsTrue(activeTask.Intervals[1].IsActive); }
public void CreateNew(Lifetime clientLifetime, Action <Lifetime> init) { balloonLifetimes.Next(balloonLifetime => { balloonWindow = new BalloonWindow(); balloonWindow.ButtonClicked += OnButtonClicked; balloonWindow.OptionClicked += OnBalloonOptionClicked; host = new BalloonWindowHost(balloonWindow); // If the client wants to hide the balloon, they can terminate clientLifetime // If another client calls CreateNew, balloonLifetimes.Next terminates // balloonLifetime. Whichever lifetime terminates first will cause // combinedLifetime to terminate, closing the window. var combinedLifetime = Lifetimes.CreateIntersection2(clientLifetime, balloonLifetime).Lifetime; combinedLifetime.AddAction(() => { if (host != null) { host.Close(); host = null; balloonWindow = null; } }); init(combinedLifetime); }); }
Task IUnitTestRunStrategy.Run(IUnitTestRun run) { var key = run.Launch.GetData(ourLaunchedInUnityKey); if (key != null) { return(Task.FromResult(false)); } var tcs = new TaskCompletionSource <bool>(); run.Launch.PutData(ourLaunchedInUnityKey, "smth"); run.PutData(ourCompletionSourceKey, tcs); mySolution.Locks.ExecuteOrQueueEx(mySolution.GetLifetime(), "ExecuteRunUT", () => { if (myUnityEditorProtocol.UnityModel.Value == null) { return; } var currentConnectionLifetime = Lifetimes.Define(mySolution.GetLifetime()); myUnityEditorProtocol.UnityModel.Change.Advise_NoAcknowledgement(currentConnectionLifetime.Lifetime, (args) => { if (args.HasNew && args.New == null) { currentConnectionLifetime.Terminate(); } }); RunInternal(run, currentConnectionLifetime.Lifetime, myUnityEditorProtocol.UnityModel.Value, tcs); }); return(tcs.Task); }
private string CreateXaml(ResourceNavigationUtil.ResourceNavigationData data) { try { using (var ms = new MemoryStream()) { Lifetimes.Using( lt => { using (var sourceStream = data.ReaderFactory(lt)) sourceStream.CopyTo(ms); }); ms.Position = 0; var bamlTranslator = new BamlTranslator(ms); return(bamlTranslator.ToString()); } } catch (Exception e) { Logger.LogException(string.Format("Error while decoding {0} from {1}", data.Moniker, data.Assembly.FullAssemblyName), e); } return(null); }
public void Execute(IDataContext context, DelegateExecute nextExecute) { var actionGroup = GetMenuActionGroup(); if (actionGroup == null) { return; } var lifetimeDefinition = Lifetimes.Define(lifetime); var options = new List <BalloonOption>(); foreach (var action in GetAvailableActions(actionGroup, context, actionManager)) { var text = GetCaption(action, context, actionManager); options.Add(new BalloonOption(text, action)); } agent.ShowBalloon(lifetimeDefinition.Lifetime, "Inspect This", string.Empty, options, new [] { "Done" }, true, balloonLifetime => { agent.BalloonOptionClicked.Advise(balloonLifetime, o => { lifetimeDefinition.Terminate(); var action = o as IActionDefWithId; threading.ExecuteOrQueue("InspectThisItem", () => action.EvaluateAndExecute(actionManager)); }); agent.ButtonClicked.Advise(balloonLifetime, _ => lifetimeDefinition.Terminate()); }); }
public UnityEventCollector() { if (!PluginSettings.LogEventsCollectorEnabled) { return; } var eventInfo = typeof(Application).GetEvent("logMessageReceivedThreaded", BindingFlags.Static | BindingFlags.Public); // Unity 2017.x+ if (eventInfo == null) { eventInfo = typeof(Application).GetEvent("logMessageReceived", BindingFlags.Static | BindingFlags.Public); } var domainLifetime = Lifetimes.Define(); if (eventInfo != null) { var handler = new Application.LogCallback(ApplicationOnLogMessageReceived); eventInfo.AddEventHandler(null, handler); AppDomain.CurrentDomain.DomainUnload += (EventHandler)((_, __) => { eventInfo.RemoveEventHandler(null, handler); domainLifetime.Terminate(); }); } else { #pragma warning disable 612, 618 Application.RegisterLogCallback(ApplicationOnLogMessageReceived); #pragma warning restore 612, 618 } }
protected virtual void DumperShortCutAction(IProjectFile projectFile, TextWriter textwriter) { Lifetimes.Using((lifetime => { var textControl = OpenTextControl(projectFile); try { var jumpToTestFileAction = GetShortcutAction(textwriter); if (jumpToTestFileAction == null) { return; } IDataContext context = DataContextOfTestTextControl.Create(lifetime, textControl, _loadedTestSolution); Func <Lifetime, DataContexts, IDataContext> dataContext = textControl.ToDataContext(); if ((jumpToTestFileAction).Update(context, new ActionPresentation(), null)) { (jumpToTestFileAction).Execute(context, null); } } finally { CloseTextControl(textControl); } })); }
public void Lifetime_Dispose() { ILifetimeFactory lf; IInstanceFactory inf; var c = Application.Current.GetChildContainer(); lf = Lifetimes.GetLifetimeFactory(Instancing.InstancePerThread); inf = lf.GetInstanceFactory(c, typeof(DisposableResource3), typeof(DisposableResource3), null); inf.Create <DisposableResource3>(); inf.Dispose(); inf.Dispose(); lf = Lifetimes.GetLifetimeFactory(Instancing.SingletonInstance); inf = lf.GetInstanceFactory(c, typeof(DisposableResource3), typeof(DisposableResource3), null); inf.Create <DisposableResource3>(); inf.Dispose(); inf.Dispose(); lf = Lifetimes.GetLifetimeFactory(Instancing.MultiInstance); inf = lf.GetInstanceFactory(c, typeof(DisposableResource3), typeof(DisposableResource3), null); inf.Create <DisposableResource3>(); inf.Dispose(); inf.Dispose(); lf = Lifetimes.GetLifetimeFactory(Instancing.PooledInstance); inf = lf.GetInstanceFactory(c, typeof(DisposableResource3), typeof(DisposableResource3), null); inf.Create <DisposableResource3>(); inf.Dispose(); inf.Dispose(); }
protected void ShowLocations(IList <FileLocationInfo> locations, FileLocationInfo currentLocation, string caption, bool bindToPsi) { var lifetimeDefinition = Lifetimes.Define(lifetime); if (!Enumerable.Any(locations)) { agent.ShowBalloon(lifetimeDefinition.Lifetime, caption, string.Format("There are no {0}.", caption.ToLowerInvariant()), null, new[] { "OK" }, false, balloonLifetime => { agent.ButtonClicked.Advise(balloonLifetime, _ => lifetimeDefinition.Terminate()); }); return; } var options = new List <BalloonOption>(); foreach (var locationInfo in locations.Distinct().Where(l => l.ProjectFile.IsValid() || l.FileSystemPath != null)) { var descriptor = new SimpleMenuItem(); var occurence = GetOccurence(locationInfo, bindToPsi); if (occurence != null) { presentationManager.DescribeOccurence(descriptor, occurence, null); var enabled = locationInfo != currentLocation; options.Add(new BalloonOption(descriptor.Text + string.Format(" ({0})", descriptor.ShortcutText), false, enabled, locationInfo)); } } agent.ShowBalloon(lifetimeDefinition.Lifetime, caption, string.Empty, options, new[] { "Done" }, true, balloonLifetime => { agent.BalloonOptionClicked.Advise(balloonLifetime, o => { lifetimeDefinition.Terminate(); var locationInfo = o as FileLocationInfo; if (locationInfo == null) { return; } shellLocks.ExecuteOrQueueReadLock("GotoRecentFiles", () => { using (ReadLockCookie.Create()) { PsiFiles.CommitAllDocuments(); var occurence = GetOccurence(locationInfo, bindToPsi); if (occurence != null) { occurence.Navigate(solution, popupWindowContext.Source, true); } } }); }); agent.ButtonClicked.Advise(balloonLifetime, _ => lifetimeDefinition.Terminate()); }); }
public void Execute(IDataContext context, DelegateExecute nextExecute) { ISolution solution = context.GetData(ProjectModelDataConstants.SOLUTION); IShellLocks locks = context.GetComponent <IShellLocks>(); PopupWindowContextSource popupWindowContextSource = context.GetData(UIDataConstants.PopupWindowContextSource); Debug.Assert(popupWindowContextSource != null, "popupWindowContextSource != null"); Debug.Assert(solution != null, "solution != null"); void Atomic(LifetimeDefinition lifetimeDefinition, Lifetime lifetime) { var controller = new GotoGeneratorController( lifetime, solution, locks, context, Shell.Instance.GetComponent <IMainWindowPopupWindowContext>(), false /* enableMulticore */ ); GotoByNameMenu menu = new GotoByNameMenu( context.GetComponent <GotoByNameMenuComponent>(), lifetimeDefinition, controller.Model, context.GetComponent <UIApplication>().MainWindow.TryGetActiveWindow(), solution.GetComponent <GotoByNameModelManager>().GetSearchTextData(context, controller), popupWindowContextSource.Create(lifetime) ); MakeBusyIconVisibleOnEmptyFilter(menu, controller.Model, lifetime); } Lifetimes.Define(solution.GetLifetime(), null /* id */, Atomic); }
private static IReadOnlyCollection <IIssue> RunInspections(ISolution solution, ICollection <IPsiSourceFile> sourceFiles) { var issues = new List <IIssue>(); #if RESHARPER92 || RESHARPER100 Assert.IsTrue( CollectInspectionResults.Do( solution, sourceFiles, SimpleTaskExecutor.Instance, x => { lock (issues) issues.Add(x); })); #else using (var lifetime = Lifetimes.Define(solution.GetLifetime())) { var collectInspectionResults = new CollectInspectionResults(solution, lifetime, A.Dummy <IProgressIndicator>()); collectInspectionResults.RunLocalInspections(new Stack <IPsiSourceFile>(sourceFiles), issuePointers => issues.AddRange(issuePointers)); } #endif return(issues); }
public void DoRenameTest(string testFile, int typeSequenceInFile = 1, params string[] expectedRenamedTests) { ExecuteWithinSettingsTransaction((settingsStore => { this.RunGuarded((Action)(() => Lifetimes.Using((Action <Lifetime>)(lifetime => { ConfigureForTestCopStrategy(settingsStore); settingsStore.SetValue <TestFileAnalysisSettings, bool>(s => s.SupportRenameRefactor, true); ISolution solution; using (Locks.UsingWriteLock()) { var solutionFolder = this.CopyTestDataDirectoryToTemp(lifetime, @"..\..\" + RelativeTestDataPath); solution = (ISolution)this.SolutionManager.OpenExistingSolution(FileSystemPath.Parse(solutionFolder).Combine(SolutionName)); } lifetime.AddAction(() => SolutionManager.CloseSolution(solution)); var findFirstTypeInFile = FindTypeInFile(solution, testFile, typeSequenceInFile); var fileRenames = new RenameTestFilesTooRefactoring().GetFileRenames(findFirstTypeInFile, "NewClass"); var filesToRename = fileRenames.Select(f => f.ProjectItem.GetPresentableProjectPath() + "->" + f.NewName).ToList(); Assert.AreEqual(expectedRenamedTests.Length, filesToRename.Count); expectedRenamedTests.ForEach(expectation => CollectionAssert.Contains(filesToRename, expectation)); })))); })); }
public void UnityLogRegisterCallBack() { var eventInfo = typeof(Application).GetEvent("logMessageReceived", BindingFlags.Static | BindingFlags.Public); var domainLifetime = Lifetimes.Define(); if (eventInfo != null) { eventInfo.AddEventHandler(null, new Application.LogCallback(ApplicationOnLogMessageReceived)); AppDomain.CurrentDomain.DomainUnload += (EventHandler)((_, __) => { eventInfo.RemoveEventHandler(null, new Application.LogCallback(ApplicationOnLogMessageReceived)); domainLifetime.Terminate(); }); } else { #pragma warning disable 612, 618 Application.RegisterLogCallback(ApplicationOnLogMessageReceived); #pragma warning restore 612, 618 } myModel.AdviseNotNull(domainLifetime.Lifetime, model => { myDelayedLogEvents.ForEach(evt => SendLogEvent(model, evt)); myDelayedLogEvents.Clear(); }); }
public void Test(string testName) { const string altRegEx = "^(.*?)\\.?(Integration)*Tests$"; ExecuteWithinSettingsTransaction((settingsStore => { RunGuarded( () => { ClearRegExSettingsPriorToRun(settingsStore); settingsStore.SetValue <TestFileAnalysisSettings, bool>( s => s.FindOrphanedProjectFiles, true); settingsStore.SetValue <TestFileAnalysisSettings, string>( s => s.TestProjectToCodeProjectNameSpaceRegEx, altRegEx); settingsStore.SetValue <TestFileAnalysisSettings, string>( s => s.TestProjectToCodeProjectNameSpaceRegExReplace, "$1"); } ); DoTestFiles(testName); Lifetimes.Using(lifetime => { using (var cookie = LoadedTestSolution.CreateTransactionCookie(DefaultAction.Rollback, this.GetType().Name, new ProgressIndicator(lifetime))) { ResharperHelper.ProtectActionFromReEntry(lifetime, "X", actionToRun); } }); })); }
public static Lifetime StartNukeTempFileWatcher(FileSystemPath tempFilePath, Lifetime parentLifetime = null) { var lifetime = parentLifetime == null ? Lifetimes.Define(nameof(StartNukeTempFileWatcher)) : Lifetimes.Define(parentLifetime, nameof(StartNukeTempFileWatcher)); var watcher = new FileSystemWatcher(tempFilePath.Directory.FullPath, tempFilePath.Name) { EnableRaisingEvents = true }; watcher.Deleted += DeletedEventHandler; lifetime.Lifetime.AddAction(() => { watcher.Deleted -= DeletedEventHandler; watcher.EnableRaisingEvents = false; watcher.Dispose(); watcher = null; }); return(lifetime.Lifetime); void DeletedEventHandler(object sender, FileSystemEventArgs args) { lifetime.Terminate(); } }
/// <summary> /// The execute. /// </summary> /// <param name="committer"> /// The committer. /// </param> public void Execute(Action <DaemonStageResult> committer) { StyleCopTrace.In(); try { if (this.daemonProcess == null) { return; } if (this.daemonProcess.InterruptFlag) { return; } DaemonData daemonData; bool shouldProcessNow; // TODO: Lock proper object. But what? lock (this.file) { daemonData = this.file.UserData.GetOrCreateData( DaemonDataKey, () => new DaemonData(this.lifetime, this.threading, this.daemon, this.daemonProcess.Document)); shouldProcessNow = daemonData.OnDaemonCalled(); } if (shouldProcessNow) { Lifetimes.Using( apiLifetime => { var runner = this.apiPool.GetInstance(apiLifetime).Runner; runner.Execute( this.daemonProcess.SourceFile.ToProjectFile(), this.daemonProcess.Document, this.file); // TODO: Why is this a copy? // Uh-oh. Looks like StyleCopRunnerInt shouldn't be shared. Need to check history List <HighlightingInfo> violations = (from info in runner.ViolationHighlights select new HighlightingInfo(info.Range, info.Highlighting)).ToList(); committer(new DaemonStageResult(violations)); }); } else { // NOTE: This wouldn't be necessary if the StyleCop analysis were more lightweight, // e.g. by using ReSharper's ASTs rather than re-parsing the file on each change daemonData.ScheduleReHighlight(); } } catch (JetBrains.Application.Progress.ProcessCancelledException) { } StyleCopTrace.Out(); }
protected override void DoTest(IProject project) { var swea = SolutionAnalysisService.GetInstance(Solution); #if RIDER using (TestPresentationMap.Cookie()) #else using (new TestPresentationMap()) #endif using (TestPsiConfigurationSettings.Instance.PersistCachesCookie()) using (swea.RunAnalysisCookie()) { Lifetimes.Using(lifetime => { ChangeSettingsTemporarily(lifetime).BoundStore.SetValue(HighlightingSettingsAccessor.AnalysisEnabled, AnalysisScope.SOLUTION); var files = swea.GetFilesToAnalyze().OrderBy(f => f.Name).ToList(); foreach (var file in files) { swea.AnalyzeInvisibleFile(file); } ExecuteWithGold(writer => { var highlightingSettingsManager = HighlightingSettingsManager.Instance; foreach (var file in files) { if (file.LanguageType.IsNullOrUnknown()) { continue; } var pf = file.ToProjectFile(); if (pf == null) { continue; } if (!pf.Location.Name.EndsWith(".cs")) { continue; } var process = new TestHighlightingDumper(file, writer, DaemonStageManager.GetInstance(Solution).Stages, (highlighting, settingsStore) => { var attribute = highlightingSettingsManager.GetHighlightingAttribute(highlighting); return(highlightingSettingsManager.GetSeverity(highlighting, settingsStore) != Severity.INFO || attribute.OverlapResolve != OverlapResolveKind.NONE); }, CSharpLanguage.Instance); process.DoHighlighting(DaemonProcessKind.VISIBLE_DOCUMENT); process.DoHighlighting(DaemonProcessKind.GLOBAL_WARNINGS); process.Dump(); writer.WriteLine(); } }); }); } }
private static void Init() { var projectDirectory = Directory.GetParent(Application.dataPath).FullName; var projectName = Path.GetFileName(projectDirectory); SlnFile = Path.GetFullPath($"{projectName}.sln"); InitializeEditorInstanceJson(); // for the case when files were changed and user just alt+tab to unity to make update, we want to fire CsprojAssetPostprocessor.OnGeneratedCSProjectFiles(); Log.DefaultFactory = new RiderLoggerFactory(); var lifetimeDefinition = Lifetimes.Define(EternalLifetime.Instance); var lifetime = lifetimeDefinition.Lifetime; AppDomain.CurrentDomain.DomainUnload += (EventHandler)((_, __) => { ourLogger.Verbose("lifetimeDefinition.Terminate"); lifetimeDefinition.Terminate(); }); Debug.Log($"Rider plugin initialized. Logs are in: {LogPath}. Current Logging Level {PluginSettings.SelectedLoggingLevel}. Change it in Unity Preferences -> Rider."); try { var riderProtocolController = new RiderProtocolController(MainThreadDispatcher.Instance, lifetime); var serializers = new Serializers(); var identities = new Identities(IdKind.Server); MainThreadDispatcher.AssertThread(); riderProtocolController.Wire.Connected.View(lifetime, (lt, connected) => { if (connected) { var protocol = new Protocol(serializers, identities, MainThreadDispatcher.Instance, riderProtocolController.Wire); ourLogger.Log(LoggingLevel.VERBOSE, "Create UnityModel and advise for new sessions..."); ourModel.Value = CreateModel(protocol, lt); } else { ourModel.Value = null; } }); } catch (Exception ex) { ourLogger.Error("Init Rider Plugin " + ex); } ourAssetHandler = new OnOpenAssetHandler(ourModel, ourRiderPathLocator, ourPluginSettings, SlnFile); ourInitialized = true; }
public void PerformChecks(TutorialStepPresenter stepPresenter) { _processingLifetime = Lifetimes.Define(stepPresenter.Lifetime); var checker = new Checker(_processingLifetime.Lifetime, this, stepPresenter.Solution, stepPresenter.PsiFiles, stepPresenter.TextControlManager, stepPresenter.ShellLocks, stepPresenter.EditorManager, stepPresenter.DocumentManager, stepPresenter.ActionManager, stepPresenter.Environment); checker.PerformStepChecks(); }
public void Add <T>(Func <T> getter, Lifetimes lifetime = Lifetimes.OnRequest) where T : class { if (_factories.ContainsKey(typeof(T))) { throw new Exception($"Type {typeof(T).ToString()} has already been added."); } _factories.Add(typeof(T), new Factory <T>(getter, lifetime)); }
void ExecuteRenameStep() { Lifetimes.Using(Lifetime => RefactoringActionUtil.ExecuteRefactoring ( Shell.Instance.Components.ActionManager().DataContexts.Create(Lifetime, Rules), new RenameStepWorkflow(Solution, null) )); }
public IFile ParseFile() { return(Lifetimes.Using(lifetime => { var builder = CreateTreeBuilder(lifetime); builder.ParseFile(); return (IFile)builder.GetTree(); })); }
public IFile ParseFile() { using (var lifetimeDefinition = Lifetimes.Define()) { var builder = CreateTreeBuilder(lifetimeDefinition.Lifetime); builder.ParseFile(); return((IFile)builder.GetTree()); } }
/// <summary> /// The execute. /// </summary> /// <param name="committer"> /// The committer. /// </param> public void Execute(Action <DaemonStageResult> committer) { StyleCopTrace.In(); try { if (this.daemonProcess == null) { return; } if (this.daemonProcess.InterruptFlag) { return; } DaemonData daemonData; bool shouldProcessNow; daemonData = this.file.UserData.GetOrCreateDataUnderLock( DaemonDataKey, () => new DaemonData(this.lifetime, this.threading, this.daemon, this.daemonProcess.Document)); shouldProcessNow = daemonData.OnDaemonCalled(); if (shouldProcessNow) { Lifetimes.Using( apiLifetime => { var runner = this.apiPool.GetInstance(apiLifetime).Runner; runner.Execute( this.daemonProcess.SourceFile.ToProjectFile(), this.daemonProcess.Document, this.file); // This filters the highlights, based on "ReSharper disable" comments, etc. var filteringConsumer = new FilteringHighlightingConsumer(this, this.settings, this.file); foreach (var highlightingInfo in runner.ViolationHighlights) { filteringConsumer.ConsumeHighlighting(highlightingInfo); } committer(new DaemonStageResult(filteringConsumer.Highlightings)); }); } else { // NOTE: This wouldn't be necessary if the StyleCop analysis were more lightweight, // e.g. by using ReSharper's ASTs rather than re-parsing the file on each change daemonData.ScheduleReHighlight(); } } catch (JetBrains.Application.Progress.ProcessCancelledException) { } StyleCopTrace.Out(); }
public IDocumentBody ParseDocumentBody() { return(Lifetimes.Using(lifetime => { var builder = CreateTreeBuilder(lifetime); builder.ParseDocumentBody(); return (IDocumentBody)builder.GetTree(); })); }
public LoggingLifetimeScope(string lifetime) { Preconditions.CheckIsNotNullEmptyOrWhitespace(nameof(lifetime), lifetime); _lifetime = lifetime; _previousLifetimeFactory = Lifetimes.GetLifetimeFactory(lifetime); var loggingLifetimeFactory = new LoggingLifetimeFactory(lifetime, _previousLifetimeFactory, null); Lifetimes.RegisterLifetimeFactory(lifetime, loggingLifetimeFactory); }