Exemplo n.º 1
0
        protected BasePopupWindow(LifetimeDefinition lifetimeDefinition, IPopupWindowContext context,
                                  PopupWindowMutex mutex, HideFlags hideFlags)
        {
            this.lifetimeDefinition = lifetimeDefinition;
            lifetime = lifetimeDefinition.Lifetime;
            Context  = context;
            Mutex    = mutex;

            HideMethod = FormHideMethod.Visibility;

            this.hideFlags = hideFlags;

            lifetime.AddAction(() =>
            {
                if (!Visible)
                {
                    CloseWindowCore();
                    return;
                }

                EventHandler handle = null;
                handle = (sender, args) =>
                {
                    CloseWindowCore();
                    Closed -= handle;
                };
                Closed += handle;
                HideWindow();
            });
        }
Exemplo n.º 2
0
        public virtual void SetUp()
        {
            myDisposable = Log.UsingLogFactory(TestLogger.Factory);

            LifetimeDefinition = Lifetime.Define(Lifetime.Eternal);
            TestLifetime       = LifetimeDefinition.Lifetime;
        }
Exemplo n.º 3
0
            public UnderMutexCookie(LifetimeDefinition def, LifetimeStatus statusUpperBound)
            {
                myDef = def;

                while (true)
                {
                    var s = myDef.myState;
                    if (ourStatusSlice[s] > statusUpperBound)
                    {
                        Success = false;
                        return;
                    }

                    if (ourMutexSlice[s])
                    {
                        continue;
                    }

                    if (Interlocked.CompareExchange(ref def.myState, ourMutexSlice.Updated(s, true), s) == s)
                    {
                        break;
                    }
                }

                Success = true;
            }
Exemplo n.º 4
0
        protected BasePopupWindow(LifetimeDefinition lifetimeDefinition, IPopupWindowContext context,
                                  PopupWindowMutex mutex, HideFlags hideFlags)
        {
            this.lifetimeDefinition = lifetimeDefinition;
            lifetime = lifetimeDefinition.Lifetime;
            Context  = context;
            Mutex    = mutex;

            HideMethod = FormHideMethod.Visibility;

            this.hideFlags = hideFlags;

            lifetime.OnTermination(() =>
            {
                if (!Visible)
                {
                    CloseWindowCore();
                    return;
                }

                void Handle(object sender, EventArgs args)
                {
                    CloseWindowCore();
                    Closed -= Handle;
                }

                Closed += Handle;
                HideWindow();
            });
        }
Exemplo n.º 5
0
        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());
            }
        }
Exemplo n.º 6
0
        public void TestBackgroundThreadActor()
        {
            var log   = new List <int>();
            var def   = new LifetimeDefinition();
            var actor = new Actor <int>("TestActor", def.Lifetime, async x =>
            {
                log.Add(x);
                await Task.Yield();
                log.Add(-x);
            });

            Assert.True(actor.IsEmpty);
            actor.SendBlocking(1);
            actor.SendBlocking(2);
            actor.SendBlocking(3);
            actor.WaitForEmpty();
            Assert.True(actor.IsEmpty);

            var expected = new List <int> {
                1, -1, 2, -2, 3, -3
            };

            Assert.AreEqual(expected, log);
            def.Terminate();

            Assert.True(actor.SendAsync(4).IsCanceled);
            Assert.AreEqual(expected, log);
        }
Exemplo n.º 7
0
        public void TestEmpty()
        {
            var def = new LifetimeDefinition();

            int sum   = 0;
            var e     = new AutoResetEvent(false);
            var actor = new Actor <int>("TestActor", def.Lifetime, x =>
            {
                e.WaitOne(); //will deadlock if continuations are not async
                sum += 1;
            }, maxQueueSize: 0);

            for (int i = 0; i < 10; i++)
            {
                actor.SendBlocking(i);
                Assert.False(actor.IsEmpty);
                e.Set();
            }
            actor.WaitForEmpty();
            Assert.AreEqual(10, sum);

            def.Terminate();
            Assert.Throws <AggregateException>(() => actor.SendBlocking(0));
            Assert.True(actor.IsEmpty);
        }
Exemplo n.º 8
0
        public void TestOceOnTerminatedLifetime()
        {
            var  n        = 100_000_000L;
            long expected = n * (n - 1) / 2;

            bool flag = false;
            var  lazy = new ProactiveLazy <long>(Lifetime.Eternal, () =>
            {
                SpinWaitEx.SpinUntil(() => flag);
                return(42);
            });

            try
            {
                //canceled before wait started
                Assert.That(() => lazy.GetOrWait(Lifetime.Terminated), Throws.InstanceOf <OperationCanceledException>());

                //canceled after wait started
                var ld = new LifetimeDefinition();
                ThreadPool.QueueUserWorkItem(_ =>
                {
                    Thread.Sleep(100);
                    ld.Terminate();
                });
                Assert.That(() => lazy.GetOrWait(Lifetime.Terminated), Throws.InstanceOf <OperationCanceledException>());
            }
            finally
            {
                flag = true;
            }
        }
Exemplo n.º 9
0
        public void SimpleOnTerminationStressTest()
        {
            for (int i = 0; i < 100; i++)
            {
                using var lifetimeDefinition = new LifetimeDefinition();
                var       lifetime     = lifetimeDefinition.Lifetime;
                int       count        = 0;
                const int threadsCount = 10;
                const int iterations   = 1000;
                Task.Factory.StartNew(() =>
                {
                    for (int j = 0; j < threadsCount; j++)
                    {
                        Task.Factory.StartNew(() =>
                        {
                            for (int k = 0; k < iterations; k++)
                            {
                                lifetime.OnTermination(() => count++);
                            }
                        }, TaskCreationOptions.AttachedToParent | TaskCreationOptions.LongRunning);
                    }
                }).Wait();

                lifetimeDefinition.Terminate();
                Assert.AreEqual(threadsCount * iterations, count);
            }
        }
        private void RunBackgroundActivity()
        {
            myShellLocks.Dispatcher.AssertAccess();

            using (ReadLockCookie.Create())
            {
                Assertion.Assert(myCurrentBackgroundActivityLifetime.IsAlive, "myCurrentBackgroundActivityLifetime.IsAlive");
                if (HasDirtyFiles())
                {
                    var filesToDelete = new SynchronizedList <IPsiSourceFile>(myDeferredHelperCache.FilesToDrop.Take(BATCH_SIZE));
                    var filesToAdd    = new SynchronizedList <IPsiSourceFile>(myDeferredHelperCache.FilesToProcess.Take(BATCH_SIZE));

                    var calculatedData = new ConcurrentDictionary <IPsiSourceFile, (long, Dictionary <IDeferredCache, object>)>();
                    ScheduleBackgroundProcess(filesToDelete, filesToAdd, calculatedData);
                }
                else
                {
                    myCurrentBackgroundActivityLifetimeDefinition.Terminate();
                    myCurrentBackgroundActivityLifetimeDefinition = null;
                    myCompletedOnce.Value = true;
                    myIsProcessing        = false;
                    myLogger.Verbose("Finish processing files in deferred caches");

                    mySolution.GetComponent <IDaemon>().Invalidate();
                }
            }
        }
Exemplo n.º 11
0
            internal ExecuteIfAliveCookie([NotNull] LifetimeDefinition def, bool allowTerminationUnderExecuting, bool disableIncrementThreadLocalExecuting)
            {
                myDef = def;
                myAllowTerminationUnderExecuting       = allowTerminationUnderExecuting;
                myDisableIncrementThreadLocalExecuting = disableIncrementThreadLocalExecuting;

                while (true)
                {
                    var s = myDef.myState;
                    if (ourStatusSlice[s] != LifetimeStatus.Alive)
                    {
                        Succeed = false;
                        return;
                    }

                    if (Interlocked.CompareExchange(ref myDef.myState, s + 1, s) == s)
                    {
                        break;
                    }
                }

                Succeed = true;

                if (!myDisableIncrementThreadLocalExecuting)
                {
                    myDef.ThreadLocalExecuting(+1);
                }

                if (myAllowTerminationUnderExecuting)
                {
                    ourAllowTerminationUnderExecutionThreadStatic++;
                }
            }
Exemplo n.º 12
0
        public void ReentrancyPriorityAdviceTest()
        {
            using var lifetimeDefinition = new LifetimeDefinition();
            var lifetime = lifetimeDefinition.Lifetime;

            var priorityAdvice = 0;
            var advice1        = 0;
            var advice2        = 0;

            var signal    = new Signal <Unit>();
            var lifetimes = new SequentialLifetimes(TestLifetime);

            signal.Advise(lifetime, _ =>
            {
                advice1++;
                using (Signal.PriorityAdviseCookie.Create())
                {
                    signal.Advise(lifetimes.Next(), _ => priorityAdvice++);
                }
            });

            signal.Advise(lifetime, _ => advice2++);

            for (int i = 0; i < 1000; i++)
            {
                signal.Fire();

                Assert.AreEqual(i + 1, advice1);
                Assert.AreEqual(i + 1, advice2);
                Assert.AreEqual(i, priorityAdvice);
            }
        }
Exemplo n.º 13
0
        public async Task PrepareForRun(IUnitTestRun run)
        {
            // ToDo Replace this LifetimeDefinition with LifetimeDefinition from PrepareForRun (When it will be updated. It need to cancel PrepareForRun)
            var lifetimeDef = new LifetimeDefinition();

            await myInnerHostController.PrepareForRun(run).ConfigureAwait(false);

            if (!myUnityController.IsUnityEditorUnitTestRunStrategy(run.RunStrategy))
            {
                return;
            }

            lock (myStartUnitySync)
            {
                myStartUnityTask = myStartUnityTask.ContinueWith(_ =>
                {
                    var unityEditorProcessId = myUnityController.TryGetUnityProcessId();
                    return(unityEditorProcessId.HasValue
                        ? Task.CompletedTask
                        : myShellLocks.Tasks.StartNew(lifetimeDef.Lifetime, Scheduling.FreeThreaded, StartUnityIfNeed));
                }, lifetimeDef.Lifetime, TaskContinuationOptions.None, myShellLocks.Tasks.GuardedMainThreadScheduler).Unwrap();
            }

            await myStartUnityTask.ConfigureAwait(false);
        }
Exemplo n.º 14
0
        public void TestSignalStress()
        {
            var sig = new Signal <bool>();

            using (var run = new LifetimeDefinition())
            {
                var lt       = run.Lifetime;
                var fireTask = Task.Factory.StartNew(() =>
                {
                    while (lt.IsAlive)
                    {
                        sig.Fire(true);
                    }
                }, lt);

                Parallel.For(0, 100000, i =>
                {
                    using (var ld = new LifetimeDefinition())
                        sig.Advise(ld.Lifetime, x => { });
                });

                run.Terminate();
                fireTask.Wait(TimeSpan.FromSeconds(1));
                Assert.AreEqual(TaskStatus.RanToCompletion, fireTask.Status);
            }
        }
Exemplo n.º 15
0
        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);
        }
Exemplo n.º 16
0
        public TutorialStep(int li, string text, string file, string projectName, string typeName, string methodName,
                            string textToFind, int textToFindOccurrence, string action, string check, string goToNextStep, bool strkieOnDone)
        {
            Id                   = li;
            Text                 = text;
            FileName             = file;
            TypeName             = typeName;
            Action               = action;
            TextToFindOccurrence = textToFindOccurrence;
            ProjectName          = projectName;
            MethodName           = methodName;
            TextToFind           = textToFind;
            Check                = check;
            StrikeOnDone         = strkieOnDone;
            _processingLifetime  = null;

            if (goToNextStep != null && goToNextStep.ToLower() == "auto")
            {
                GoToNextStep = GoToNextStep.Auto;
            }
            else
            {
                GoToNextStep = GoToNextStep.Manual;
            }
        }
Exemplo n.º 17
0
        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);
        }
Exemplo n.º 18
0
            public Endpoint(Lifetime bindLifetime, RdCall <TReq, TRes> call, RdId rdId, IScheduler wireScheduler) : base(call, rdId, wireScheduler)
            {
                myDef = bindLifetime.CreateNested();

                myCall.Wire.Advise(Lifetime, this);
                Lifetime.TryOnTermination(() => ResultInternal.SetIfEmpty(RdTaskResult <TRes> .Cancelled()));

                Result.AdviseOnce(Lifetime.Eternal, taskResult =>
                {
                    var potentiallyBindable = taskResult.Result;
                    if (potentiallyBindable.IsBindable())
                    {
                        potentiallyBindable.IdentifyPolymorphic(myCall.Proto.Identities, myCall.RdId.Mix(RdId.ToString()));
                        potentiallyBindable.BindPolymorphic(Lifetime, myCall, RdId.ToString());
                    }
                    else
                    {
                        myDef.Terminate();
                    }

                    Trace(RdReactiveBase.ourLogSend, "send response", taskResult);
                    myWire.Send(RdId,
                                writer =>
                    {
                        RdTaskResult <TRes> .Write(myCall.WriteResponseDelegate, myCall.SerializationContext, writer, taskResult);
                    });
                });
            }
Exemplo n.º 19
0
        public void ConcurrentWriteAndAdviseTest()
        {
            const int threadsCount = 10;

            for (int i = 0; i < 200; i++)
            {
                using var def = new LifetimeDefinition();
                var lifetime = def.Lifetime;

                var prop = new WriteOnceProperty <int>();

                var value1 = new AtomicValue();
                var count  = 0;

                var tasks = Enumerable.Range(0, threadsCount).Select(j => Task.Factory.StartNew(() =>
                {
                    Interlocked.Increment(ref count);
                    SpinWait.SpinUntil(() => Memory.VolatileRead(ref count) == threadsCount); // sync threads

                    if (!prop.SetIfEmpty(j))
                    {
                        return;
                    }

                    if (!value1.SetIfDefault(j))
                    {
                        Assert.Fail("Value must be written once");
                    }
                }, lifetime)).ToArray();

                var values = Enumerable.Range(0, i).Select(j =>
                {
                    var localValue = new AtomicValue();

                    prop.Advise(lifetime, v =>
                    {
                        if (!localValue.SetIfDefault(v))
                        {
                            Assert.Fail("Handled must not be called twice");
                        }
                    });
                    return(localValue);
                }).ToArray();

                Assert.IsTrue(Task.WaitAll(tasks, TimeSpan.FromMinutes(1)), "Task.WaitAll(tasks, TimeSpan.FromMinutes(1))");

                value1.AssertNonDefault();

                if (values.Length != 0)
                {
                    var value = values.Select(x => x.Value).Distinct().Single();
                    Assert.AreEqual(value, value1.Value);
                }

                Assert.AreEqual(value1.Value, prop.Value);

                prop.fireInternal(10000);
            }
        }
Exemplo n.º 20
0
 public T4EnvDTEHost(
     [NotNull] LifetimeDefinition lifetimeDefinition,
     ISolution solution
     )
 {
     LifetimeDefinition = lifetimeDefinition;
     ConnectionManager  = new ConnectionManager(lifetimeDefinition.Lifetime, solution);
 }
Exemplo n.º 21
0
        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();
        }
Exemplo n.º 22
0
        // todo: rewrite
        private static void SetShowInFindResultsAction(
            [NotNull] GotoWordIndexController controller, [NotNull] LifetimeDefinition definition,
            [NotNull] IShellLocks shellLocks, [NotNull] UITaskExecutor taskExecutor)
        {
            controller.FuncEtcItemExecute.Value = () =>
                                                  shellLocks.ExecuteOrQueueReadLock("ShowInFindResults", () =>
            {
                var filterString = controller.Model.FilterText.Value;
                if (string.IsNullOrEmpty(filterString))
                {
                    return;
                }

                definition.Terminate();

                GotoWordBrowserDescriptor descriptor = null;
                if (taskExecutor.FreeThreaded.ExecuteTask(
                        "Show Files In Find Results", TaskCancelable.Yes, progress =>
                {
                    progress.TaskName = "Collecting words matching '" + filterString + "'";
                    progress.Start(1);

                    var occurrences = new List <IOccurence>();
                    using (ReadLockCookie.Create())
                    {
                        controller.ConsumePresentableItems(
                            filterString, -1, itemsConsumer: (items, behavior) =>
                        {
                            foreach (var item in items)
                            {
                                occurrences.Add(item.Occurence);
                            }
                        });
                    }

                    if (occurrences.Count > 0 && !progress.IsCanceled)
                    {
                        descriptor = new GotoWordBrowserDescriptor(
                            controller.Solution, filterString, occurrences);
                    }

                    progress.Stop();
                }))
                {
                    if (descriptor != null)
                    {
                        FindResultsBrowser.ShowResults(descriptor);
                    }
                }
                else
                {
                    if (descriptor != null)
                    {
                        descriptor.LifetimeDefinition.Terminate();
                    }
                }
            });
        }
Exemplo n.º 23
0
        public WiredLifetime(LifetimeDefinition definition, RdId rdId, IRdReactive parent, IWire wire)
        {
            myDefinition  = definition;
            myParent      = parent;
            RdId          = rdId;
            WireScheduler = parent.WireScheduler; //maybe cancellation better to do synchronous

            wire.Advise(definition.Lifetime, this);
        }
Exemplo n.º 24
0
 public FadingWpfPopupWindow(LifetimeDefinition lifetimeDefinition, IPopupWindowContext context,
                             PopupWindowMutex mutex, PopupWindowManager popupWindowManager,
                             Window window, double opacity, HideFlags hideFlags = HideFlags.None)
     : base(lifetimeDefinition, context, mutex, popupWindowManager, window, hideFlags)
 {
     this.window  = window;
     this.opacity = opacity;
     window.AllowsTransparency = true;
 }
Exemplo n.º 25
0
        public void TestReentrancyInEnumeration()
        {
            var lst = new LifetimedList <Action>();
            var l1  = new LifetimeDefinition {
                Id = "l1"
            };
            var l2 = new LifetimeDefinition {
                Id = "l2"
            };

            l2.Lifetime.OnTermination(() => lst.ClearValuesIfNotAlive());

            var log = new List <int>();

            lst.Add(l1.Lifetime, () =>
            {
                log.Add(1);
                lst.Add(l1.Lifetime, () =>
                {
                    log.Add(2);
                });
                l2.Terminate();
            });

            lst.Add(l2.Lifetime, () => { log.Add(3); });

            void Enumerate()
            {
                foreach (var(lf, action) in lst)
                {
                    if (lf.IsNotAlive)
                    {
                        continue;
                    }
                    action.Invoke();
                }
            }

            Enumerate();
            Assert.AreEqual(new List <int> {
                1
            }, log);
            log.Clear();

            Enumerate();
            Assert.AreEqual(new List <int> {
                1, 2
            }, log);
            log.Clear();


            Enumerate();
            Assert.AreEqual(new List <int> {
                1, 2, 2
            }, log);
        }
        protected WpfPopupWindow(LifetimeDefinition lifetimeDefinition, IPopupWindowContext context,
                                 PopupWindowMutex mutex, PopupWindowManager popupWindowManager,
                                 Window window, HideFlags hideFlags = HideFlags.None)
            : base(lifetimeDefinition, context, mutex, hideFlags)
        {
            this.window = window;

            UpdatePopupLayout();
            AttachEvents(popupWindowManager);
        }
Exemplo n.º 27
0
        private void ProcessCurrentStep()
        {
            ShowText(CurrentStep);
            _codeNavigator.Navigate(CurrentStep);
            _stepView.UpdateProgress();

            CurrentStep.StepIsDone += StepOnStepIsDone;
            _checksLifetime         = Lifetimes.Define(_lifetime);
            CurrentStep.PerformChecks(_checksLifetime.Lifetime, this);
        }
Exemplo n.º 28
0
        protected override IJetPopupMenuOverlordView CreateView(LifetimeDefinition defShowView, JetPopupMenu menu, IJetPopupMenuOverlordView parentView = null)
        {
            var result = base.CreateView(defShowView, menu, parentView);

            if (result is JetPopupMenuOverlordView overlordView)
            {
                ContextMenuSectionNavigationConfigurator.ConfigureMenuView(overlordView.MenuView);
            }

            return(result);
        }
 public UnityUsagesAsyncFinderCallback(LifetimeDefinition lifetimeDef, UnityUsagesFinderConsumer consumer, UnityHost unityHost, IShellLocks shellLocks,
                                       string displayName, FindUsageResultElement selected, bool focusUnity)
 {
     myLifetimeDef = lifetimeDef;
     myConsumer    = consumer;
     myUnityHost   = unityHost;
     myShellLocks  = shellLocks;
     myDisplayName = displayName;
     mySelected    = selected;
     myFocusUnity  = focusUnity;
 }
        private void DeferHideBalloon()
        {
            deferredRemovalLifetimeDefinition = Lifetimes.Define(lifetime);

            threading.ReentrancyGuard.ExecuteOrQueue(deferredRemovalLifetimeDefinition.Lifetime,
                                                     "Clippy::InplaceRefactoringHandler::DeferredHideBalloon",
                                                     () =>
            {
                sequentialLifetimes.TerminateCurrent();
                currentHighlighter = null;
            });
        }
 private void EnableShowInFindResults(LocateFileController controller, LifetimeDefinition definition)
 {
     var itemsToPresent = new List<PresentableGotoItem>();
     controller.FuncEtcItemExecute.Value = delegate
     {
         Shell.Instance.Locks.ExecuteOrQueueReadLock("ShowInFindResults", delegate
         {
             string filterString = controller.Model.FilterText.Value;
             if (string.IsNullOrEmpty(filterString))
             {
                 return;
             }
             filterString = filterString.Replace("*.", ".").Replace(".", "*.");
             definition.Terminate();
             GotoFileBrowserDescriptor descriptor = null;
             if (!Shell.Instance.GetComponent<UITaskExecutor>().FreeThreaded.ExecuteTask("Show Files In Find Results", TaskCancelable.Yes, delegate(IProgressIndicator indicator)
             {
                 indicator.TaskName = string.Format("Collecting symbols matching '{0}'", filterString);
                 indicator.Start(1);
                 ConsumeOccurences(controller, filterString, itemsToPresent);
                 if (itemsToPresent.Any() && !indicator.IsCanceled)
                 {
                     descriptor = CreateGotoFileBrowserDescriptor(controller.Solution, filterString,
                         from item in itemsToPresent
                         select item.Occurence, delegate
                         {
                             itemsToPresent.Clear();
                             ConsumeOccurences(controller, filterString, itemsToPresent);
                             return itemsToPresent.Select(item => item.Occurence);
                         });
                 }
                 indicator.Stop();
             }))
             {
                 if (descriptor != null)
                 {
                     descriptor.LifetimeDefinition.Terminate();
                 }
                 return;
             }
             if (descriptor != null)
             {
                 FindResultsBrowser.ShowResults(descriptor);
             }
         });
     };
 }
Exemplo n.º 32
0
    public static void Initialise(IVsOleServiceProvider vsServiceProvider, ReSharperApiImplementationCallback callback)
    {
        // TODO: Is the guard strictly necessary?
        // dotCover uses it, but we always seem to get executed immediately
        ReentrancyGuard.Current.ExecuteOrQueue("Register VSIX extension provider",
          () =>
          {
        var jetEnvironment = JetVisualStudioHost.GetOrCreateHost(vsServiceProvider).Environment;
        var catalogue = PartsCatalogueFactory.Create(typeof(Bootstrap).Assembly);
        lifetimeDefinition = Lifetimes.Define(EternalLifetime.Instance, "VsixExtensionProvider");
        jetEnvironment.FullPartCatalogSet.Add(lifetimeDefinition.Lifetime, catalogue);

        var extensionProvider = jetEnvironment.Container.GetComponent<VsixExtensionProvider>();

        callback(new ReSharperApiImplementation(extensionProvider));
          });
    }
        private static void Execute(IDataContext context, ISolution solution, LifetimeDefinition definition, Lifetime lifetime)
        {
            var locks = Shell.Instance.GetComponent<IShellLocks>();
            var actionManager = Shell.Instance.Components.ActionManager();
            var shortcutManager = Shell.Instance.GetComponent<IShortcutManager>();
            var globalSettingsTable = Shell.Instance.GetComponent<SettingsStore>();
            var fontsManager = Shell.Instance.GetComponent<FontsManager>();
            var tooltipMananger = Shell.Instance.Components.Tooltips();
            var dataContexts = Shell.Instance.GetComponent<DataContexts>();
            var threading = Shell.Instance.GetComponent<IThreading>();
            var mainWindow = Shell.Instance.GetComponent<UIApplication>().MainWindow;
            var popupWindowManager = Shell.Instance.GetComponent<PopupWindowManager>();
            var windowsMessageHookManager = Shell.Instance.GetComponent<WindowsMessageHookManager>();
            var mainWindowPopupWindowContext = Shell.Instance.GetComponent<MainWindowPopupWindowContext>();

            var controller = new FindUsagesOfSymbolController(lifetime, solution, LibrariesFlag.SolutionOnly, locks,
                                                              dataContexts, threading);

            new GotoByNameMenu(definition, controller.Model, locks, globalSettingsTable, fontsManager, tooltipMananger,
                               mainWindow, popupWindowManager, windowsMessageHookManager, mainWindowPopupWindowContext,
                               context.GetData(GotoByNameDataConstants.CurrentSearchText),
                               actionManager, shortcutManager);
        }
 public ZenCodingWrapForm(Lifetime lifetime, IThemedIconManager iconManager)
 {
   myIconManager = iconManager;
   myLifetimeDefinition = Lifetimes.Define(lifetime, "ZenCodingWrapForm");
   InitControls();
 }
Exemplo n.º 35
0
 internal ModuleWrapper([NotNull] T4PsiModule module, [NotNull] LifetimeDefinition lifetimeDefinition)
 {
     Module = module;
     LifetimeDefinition = lifetimeDefinition;
 }