protected override async Task CreatedAsync(IWpfTextView textView, ITextDocument document)
        {
            try
            {
                Debug.WriteLine("Steroids: TextViewCreated - entered");
                var bootstrapper = new CodeAdornmentsBootstrapper(textView);

                await SteroidsVsPackage.InitializedAwaitable;

                Debug.WriteLine("Steroids: TextViewCreated - begin bootstrap");
                bootstrapper.Run();
                if (_cleanupMap.ContainsKey(textView))
                {
                    return;
                }

                _cleanupMap.Add(textView, bootstrapper);

                Debug.WriteLine("Steroids: TextViewCreated - resolve services");
                var codeStructure   = bootstrapper.GetService(typeof(CodeStructureAdorner)) as CodeStructureAdorner;
                var diagnosticHints = bootstrapper.GetService(typeof(DiagnosticInfoAdorner)) as DiagnosticInfoAdorner;
                WeakEventManager <ITextView, EventArgs> .AddHandler(textView, nameof(ITextView.Closed), OnClosed);

                Debug.WriteLine("Steroids: TextViewCreated - done");
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                Debug.WriteLine(ex.StackTrace);
            }
        }
Exemple #2
0
        /// <summary>
        /// Instantiates a CodeStructureAdorner manager when a textView is created.
        /// </summary>
        /// <param name="textView">The <see cref="IWpfTextView"/> upon which the adornment should be placed.</param>
        public void TextViewCreated(IWpfTextView textView)
        {
            SteroidsVsPackage.EnsurePackageLoadedAsync().ContinueWith(
                t =>
            {
                var bootstrapper = new CodeAdornmentsBootstrapper(textView);
                if (_cleanupMap.ContainsKey(textView))
                {
                    return;
                }

                _cleanupMap.Add(textView, bootstrapper);

                var codeStructure   = bootstrapper.GetService(typeof(CodeStructureAdorner)) as CodeStructureAdorner;
                var diagnosticHints = bootstrapper.GetService(typeof(DiagnosticInfoAdorner)) as DiagnosticInfoAdorner;
                WeakEventManager <ITextView, EventArgs> .AddHandler(textView, nameof(ITextView.Closed), OnClosed);
            },
                CancellationToken.None,
                TaskContinuationOptions.ExecuteSynchronously,
                TaskScheduler.Default);
        }