コード例 #1
0
        public EditorCommandHandlerServiceFactory(
            [ImportMany] IEnumerable <Lazy <ICommandHandler, ICommandHandlerMetadata> > commandHandlers,
            [ImportMany] IEnumerable <Lazy <ICommandingTextBufferResolverProvider, IContentTypeMetadata> > bufferResolvers,
            IUIThreadOperationExecutor uiThreadOperationExecutor,
            JoinableTaskContext joinableTaskContext,
            IStatusBarService statusBar,
            IContentTypeRegistryService contentTypeRegistryService,
            IGuardedOperations guardedOperations,
            ILoggingServiceInternal loggingService)
        {
            UIThreadOperationExecutor = uiThreadOperationExecutor;
            JoinableTaskContext       = joinableTaskContext;
            StatusBar         = statusBar;
            GuardedOperations = guardedOperations;
            LoggingService    = loggingService;

            _contentTypeRegistryService = contentTypeRegistryService;
            ContentTypeOrderer          = new StableContentTypeOrderer <ICommandHandler, ICommandHandlerMetadata>(_contentTypeRegistryService);
            _commandHandlers            = OrderCommandHandlers(commandHandlers);
            if (!bufferResolvers.Any())
            {
                throw new ImportCardinalityMismatchException($"Expected to import at least one {typeof(ICommandingTextBufferResolver).Name}");
            }

            _bufferResolverProviders = bufferResolvers.ToList();
        }
コード例 #2
0
        public AsyncQuickInfoSession(
            IEnumerable <Lazy <IAsyncQuickInfoSourceProvider, IOrderableContentTypeMetadata> > orderedSourceProviders,
            IGuardedOperations guardedOperations,
            JoinableTaskContext joinableTaskContext,
            IToolTipService toolTipService,
            ITextView textView,
            ITrackingPoint triggerPoint,
            QuickInfoSessionOptions options,
            PropertyCollection propertyCollection)
        {
            this.orderedSourceProviders = orderedSourceProviders ?? throw new ArgumentNullException(nameof(orderedSourceProviders));
            this.guardedOperations      = guardedOperations ?? throw new ArgumentNullException(nameof(guardedOperations));
            this.joinableTaskContext    = joinableTaskContext ?? throw new ArgumentNullException(nameof(joinableTaskContext));
            this.toolTipService         = toolTipService ?? throw new ArgumentNullException(nameof(toolTipService));
            this.TextView     = textView ?? throw new ArgumentNullException(nameof(textView));
            this.triggerPoint = triggerPoint ?? throw new ArgumentNullException(nameof(triggerPoint));
            this.Options      = options;

            // Bug #512117: Remove compatibility shims for 2nd gen. Quick Info APIs.
            // We can remove this null check once we remove the legacy APIs.
            this.Properties = propertyCollection ?? new PropertyCollection();

            // Trigger point must be a tracking point on the view's buffer.
            if (triggerPoint.TextBuffer != textView.TextBuffer)
            {
                throw new ArgumentException("The specified ITextSnapshot doesn't belong to the correct TextBuffer");
            }
        }
コード例 #3
0
        protected IIntellisensePresenter FindPresenter
            (IIntellisenseSession session,
            IList <Lazy <IIntellisensePresenterProvider, IOrderableContentTypeMetadata> > orderedPresenterProviders,
            IGuardedOperations guardedOperations)
        {
            var buffers = Helpers.GetBuffersForTriggerPoint(session);

            foreach (var presenterProviderExport in orderedPresenterProviders)
            {
                foreach (var buffer in buffers)
                {
                    foreach (var contentType in presenterProviderExport.Metadata.ContentTypes)
                    {
                        if (buffer.ContentType.IsOfType(contentType))
                        {
                            IIntellisensePresenter presenter = guardedOperations.InstantiateExtension(
                                session, presenterProviderExport,
                                factory => factory.TryCreateIntellisensePresenter(session));
                            if (presenter != null)
                            {
                                return(presenter);
                            }
                        }
                    }
                }
            }

            return(null);
        }
コード例 #4
0
        public GuardedToolTipPresenter(
            IGuardedOperations guardedOperations,
            IToolTipPresenter presenter)
        {
            this.guardedOperations = guardedOperations ?? throw new ArgumentNullException(nameof(guardedOperations));
            this.Presenter         = presenter ?? throw new ArgumentNullException(nameof(presenter));

            presenter.Dismissed += this.OnDismissed;
        }
コード例 #5
0
        public ConnectionManager(ITextView textView,
                                 ICollection <Lazy <ITextViewConnectionListener, IContentTypeAndTextViewRoleMetadata> > textViewConnectionListeners,
                                 IGuardedOperations guardedOperations)
        {
            if (textView == null)
            {
                throw new ArgumentNullException("textView");
            }
            if (textViewConnectionListeners == null)
            {
                throw new ArgumentNullException("textViewConnectionListeners");
            }
            if (guardedOperations == null)
            {
                throw new ArgumentNullException("guardedOperations");
            }

            _textView          = textView;
            _guardedOperations = guardedOperations;

            List <Lazy <ITextViewConnectionListener, IContentTypeAndTextViewRoleMetadata> > filteredListeners =
                UIExtensionSelector.SelectMatchingExtensions(textViewConnectionListeners, _textView.Roles);

            if (filteredListeners.Count > 0)
            {
                foreach (var listenerExport in filteredListeners)
                {
                    if (!allowedTextViewConnectionListeners.Contains(listenerExport.Value.ToString()))
                    {
                        continue;
                    }

                    Listener listener = new Listener(listenerExport, guardedOperations);
                    this.listeners.Add(listener);

                    Collection <ITextBuffer> subjectBuffers =
                        textView.BufferGraph.GetTextBuffers(buffer => (Match(listenerExport.Metadata, buffer.ContentType)));

                    if (subjectBuffers.Count > 0)
                    {
                        var instance = listener.Instance;
                        if (instance != null)
                        {
                            _guardedOperations.CallExtensionPoint(instance,
                                                                  () => instance.SubjectBuffersConnected(_textView, ConnectionReason.TextViewLifetime, subjectBuffers));
                        }
                    }
                }

                if (listeners.Count > 0)
                {
                    textView.BufferGraph.GraphBuffersChanged           += OnGraphBuffersChanged;
                    textView.BufferGraph.GraphBufferContentTypeChanged += OnGraphBufferContentTypeChanged;
                }
            }
        }
コード例 #6
0
        public BraceCompletionStack(ITextView textView, IBraceCompletionAdornmentServiceFactory adornmentFactory, IGuardedOperations guardedOperations)
        {
            _adornmentServiceFactory = adornmentFactory;
            _stack = new Stack <IBraceCompletionSession>();

            _textView          = textView;
            _guardedOperations = guardedOperations;

            RegisterEvents();
        }
コード例 #7
0
        internal BraceCompletionManager(ITextView textView, IBraceCompletionStack stack, IBraceCompletionAggregatorFactory sessionFactory, IGuardedOperations guardedOperations)
        {
            _textView          = textView;
            _stack             = stack;
            _sessionFactory    = sessionFactory;
            _guardedOperations = guardedOperations;
            _sessionAggregator = sessionFactory.CreateAggregator();

            GetOptions();
            RegisterEvents();
        }
コード例 #8
0
ファイル: ToolTipService.cs プロジェクト: wjohnke/CSS18
 public ToolTipService(
     [ImportMany] IEnumerable <Lazy <IToolTipPresenterFactory, IOrderable> > unorderedPresenterProviders,
     IGuardedOperations guardedOperations,
     JoinableTaskContext joinableTaskContext)
 {
     this.unorderedPresenterProviders = unorderedPresenterProviders
                                        ?? throw new ArgumentNullException(nameof(unorderedPresenterProviders));
     this.guardedOperations = guardedOperations
                              ?? throw new ArgumentNullException(nameof(guardedOperations));
     this.joinableTaskContext = joinableTaskContext
                                ?? throw new ArgumentNullException(nameof(joinableTaskContext));
 }
コード例 #9
0
        /// <summary>
        /// Given a list of extensions that provide text view roles and content types, return the
        /// instantiated extension which best matches the given content type and matches at least one of the roles.
        /// </summary>
        public static TExtensionInstance InvokeBestMatchingFactory <TExtensionInstance, TExtensionFactory, TMetadataView>
            (IEnumerable <Lazy <TExtensionFactory, TMetadataView> > providerHandles,
            IContentType dataContentType,
            ITextViewRoleSet viewRoles,
            Func <TExtensionFactory, TExtensionInstance> getter,
            IContentTypeRegistryService contentTypeRegistryService,
            IGuardedOperations guardedOperations,
            object errorSource)
            where TMetadataView : IContentTypeAndTextViewRoleMetadata          // both content type and text view role are required
            where TExtensionFactory : class
            where TExtensionInstance : class
        {
            var roleMatchingProviderHandles = SelectMatchingExtensions(providerHandles, viewRoles);

            return(guardedOperations.InvokeBestMatchingFactory(roleMatchingProviderHandles, dataContentType, getter, contentTypeRegistryService, errorSource));
        }
        public AsyncQuickInfoBroker(
            [ImportMany] IEnumerable <Lazy <IAsyncQuickInfoSourceProvider, IOrderableContentTypeMetadata> > unorderedSourceProviders,
            IGuardedOperations guardedOperations,
            IToolTipService toolTipService,
            JoinableTaskContext joinableTaskContext)
        {
            // Bug #512117: Remove compatibility shims for 2nd gen. Quick Info APIs.
            // Combines new + legacy providers into a single series for relative ordering.
            var combinedProviders = unorderedSourceProviders ?? throw new ArgumentNullException(nameof(unorderedSourceProviders));

            this.unorderedSourceProviders = combinedProviders;
#pragma warning restore 618
            this.guardedOperations   = guardedOperations ?? throw new ArgumentNullException(nameof(guardedOperations));
            this.joinableTaskContext = joinableTaskContext ?? throw new ArgumentNullException(nameof(joinableTaskContext));
            this.toolTipService      = toolTipService;
        }
コード例 #11
0
 public BraceCompletionAggregatorFactory(
     [ImportMany(typeof(IBraceCompletionSessionProvider))] IEnumerable <Lazy <IBraceCompletionSessionProvider, IBraceCompletionMetadata> > sessionProviders,
     [ImportMany(typeof(IBraceCompletionContextProvider))] IEnumerable <Lazy <IBraceCompletionContextProvider, IBraceCompletionMetadata> > contextProviders,
     [ImportMany(typeof(IBraceCompletionDefaultProvider))] IEnumerable <Lazy <IBraceCompletionDefaultProvider, IBraceCompletionMetadata> > defaultProviders,
     IContentTypeRegistryService contentTypeRegistryService,
     ITextBufferUndoManagerProvider undoManager,
     IEditorOperationsFactoryService editorOperationsFactoryService,
     IGuardedOperations guardedOperations)
 {
     SessionProviders           = sessionProviders;
     ContextProviders           = contextProviders;
     DefaultProviders           = defaultProviders;
     ContentTypeRegistryService = contentTypeRegistryService;
     UndoManager = undoManager;
     EditorOperationsFactoryService = editorOperationsFactoryService;
     GuardedOperations = guardedOperations;
 }
コード例 #12
0
ファイル: Helpers.cs プロジェクト: noah1510/dotdevelop
        internal static IEnumerable <TStyle> GetMatchingPresenterStyles <TSession, TStyle>
            (TSession session,
            IList <Lazy <TStyle, IOrderableContentTypeMetadata> > orderedPresenterStyles,
            IGuardedOperations guardedOperations)
            where TSession : IIntellisenseSession
        {
            List <TStyle> styles = new List <TStyle>();

            ITextView     textView           = session.TextView;
            SnapshotPoint?surfaceBufferPoint = session.GetTriggerPoint(textView.TextSnapshot);

            if (surfaceBufferPoint == null)
            {
                return(styles);
            }

            var buffers = Helpers.GetBuffersForTriggerPoint(session).ToList();

            foreach (var styleExport in orderedPresenterStyles)
            {
                bool usedThisProviderAlready = false;
                foreach (var buffer in buffers)
                {
                    foreach (string contentType in styleExport.Metadata.ContentTypes)
                    {
                        if (buffer.ContentType.IsOfType(contentType))
                        {
                            var style = guardedOperations.InstantiateExtension(styleExport, styleExport);
                            if (!Object.Equals(style, default(TStyle)))
                            {
                                styles.Add(style);
                            }
                            usedThisProviderAlready = true;
                            break;
                        }
                    }
                    if (usedThisProviderAlready)
                    {
                        break;
                    }
                }
            }

            return(styles);
        }
コード例 #13
0
        /// <summary>
        /// Creates an instance of <see cref="ModelComputation{TModel}"/>
        /// and enqueues an task that will generate the initial state of the <typeparamref name="TModel"/>
        /// </summary>
#pragma warning disable CA1068 // CancellationToken should be the last parameter
        public ModelComputation(
            TaskScheduler computationTaskScheduler,
            JoinableTaskContext joinableTaskContext,
            Func <TModel, CancellationToken, Task <TModel> > initialTransformation,
            CancellationToken token,
            IGuardedOperations guardedOperations,
            IModelComputationCallbackHandler <TModel> callbacks)
#pragma warning restore CA1068
        {
            _joinableTaskFactory      = joinableTaskContext.Factory;
            _computationTaskScheduler = computationTaskScheduler;
            _token             = token;
            _guardedOperations = guardedOperations;
            _callbacks         = callbacks;

            // Start dummy tasks so that we don't need to check for null on first Enqueue
            _lastJoinableTask = _joinableTaskFactory.RunAsync(() => Task.FromResult(default(TModel)));
            _uiCancellation   = new CancellationTokenSource();

            // Immediately run the first transformation, to operate on proper TModel.
            Enqueue(initialTransformation, updateUi: false);
        }
コード例 #14
0
 public Listener(Lazy <ITextViewConnectionListener, IContentTypeAndTextViewRoleMetadata> importInfo, IGuardedOperations guardedOperations)
 {
     this.importInfo        = importInfo;
     this.guardedOperations = guardedOperations;
 }