コード例 #1
0
        public PhpProjectionBuffer(
            IContentTypeRegistryService contentRegistry,
            IProjectionBufferFactoryService bufferFactory,
            IBufferTagAggregatorFactoryService bufferTagAggregatorFactory,
            ITextBuffer diskBuffer,
            IBufferGraphFactoryService bufferGraphFactory,
            IContentType contentType)
        {
            _diskBuffer      = diskBuffer;
            _contentRegistry = contentRegistry;
            _contentType     = contentType;

            _projBuffer     = CreateProjectionBuffer(bufferFactory);
            _htmlBuffer     = CreateHtmlBuffer(bufferFactory);
            _templateBuffer = CreateTemplateBuffer(bufferFactory);

            _bufferGraph = bufferGraphFactory.CreateBufferGraph(_projBuffer);

            _contentTypeTagger              = bufferTagAggregatorFactory.CreateTagAggregator <ContentTypeTag>(_diskBuffer);
            _contentTypeTagger.TagsChanged += HandleContentTypeTagsChanged;

            IVsTextBuffer buffer;

            if (_diskBuffer.Properties.TryGetProperty <IVsTextBuffer>(typeof(IVsTextBuffer), out buffer))
            {
                // keep the Venus HTML classifier happy - it wants to find a site via IVsTextBuffer
                _htmlBuffer.Properties.AddProperty(typeof(IVsTextBuffer), buffer);
            }

            HandleContentTypeTagsChanged();
        }
コード例 #2
0
 internal static void SetBufferGraphFactory(IBufferGraphFactoryService BufferGraphFactory)
 {
     lock (_staticMemberLock)
     {
         _bufferGraphFactory = BufferGraphFactory;
     }
 }
コード例 #3
0
 protected AbstractDebuggerIntelliSenseContext(
     IWpfTextView wpfTextView,
     IVsTextView vsTextView,
     IVsTextLines vsDebuggerTextLines,
     ITextBuffer contextBuffer,
     TextManager.Interop.TextSpan[] currentStatementSpan,
     IComponentModel componentModel,
     IServiceProvider serviceProvider,
     IContentType contentType
     )
 {
     _textView                           = wpfTextView;
     _debuggerTextLines                  = vsDebuggerTextLines;
     this.ContextBuffer                  = contextBuffer;
     this.CurrentStatementSpan           = currentStatementSpan[0];
     _contentType                        = contentType;
     _originalContentType                = _textView.TextBuffer.ContentType;
     this.ProjectionBufferFactoryService =
         componentModel.GetService <IProjectionBufferFactoryService>();
     _bufferGraphFactoryService = componentModel.GetService <IBufferGraphFactoryService>();
     _isImmediateWindow         = IsImmediateWindow(
         (IVsUIShell)serviceProvider.GetService(typeof(SVsUIShell)),
         vsTextView
         );
 }
        public DefaultVisualStudioWorkspaceAccessor(
            IBufferGraphFactoryService bufferGraphService,
            TextBufferProjectService projectService,
            [Import(typeof(VisualStudioWorkspace))] Workspace defaultWorkspace,
            [Import(typeof(LiveShareWorkspaceProvider), AllowDefault = true)] LiveShareWorkspaceProvider liveShareWorkspaceProvider)
        {
            if (bufferGraphService == null)
            {
                throw new ArgumentNullException(nameof(bufferGraphService));
            }

            if (projectService == null)
            {
                throw new ArgumentNullException(nameof(projectService));
            }

            if (defaultWorkspace == null)
            {
                throw new ArgumentNullException(nameof(defaultWorkspace));
            }

            _bufferGraphService         = bufferGraphService;
            _projectService             = projectService;
            _defaultWorkspace           = defaultWorkspace;
            _liveShareWorkspaceProvider = liveShareWorkspaceProvider;
        }
コード例 #5
0
 TextEditorFactoryService(ITextBufferFactoryService textBufferFactoryService, IEditorOptionsFactoryService editorOptionsFactoryService, ICommandService commandService, ISmartIndentationService smartIndentationService, [ImportMany] IEnumerable <Lazy <IWpfTextViewCreationListener, IDeferrableContentTypeAndTextViewRoleMetadata> > wpfTextViewCreationListeners, [ImportMany] IEnumerable <Lazy <ITextViewCreationListener, IDeferrableContentTypeAndTextViewRoleMetadata> > textViewCreationListeners, IFormattedTextSourceFactoryService formattedTextSourceFactoryService, IViewClassifierAggregatorService viewClassifierAggregatorService, ITextAndAdornmentSequencerFactoryService textAndAdornmentSequencerFactoryService, IClassificationFormatMapService classificationFormatMapService, IEditorFormatMapService editorFormatMapService, IAdornmentLayerDefinitionService adornmentLayerDefinitionService, ILineTransformProviderService lineTransformProviderService, IWpfTextViewMarginProviderCollectionProvider wpfTextViewMarginProviderCollectionProvider, IMenuService menuService, IEditorOperationsFactoryService editorOperationsFactoryService, ISpaceReservationStackProvider spaceReservationStackProvider, IWpfTextViewConnectionListenerServiceProvider wpfTextViewConnectionListenerServiceProvider, IBufferGraphFactoryService bufferGraphFactoryService, [ImportMany] IEnumerable <Lazy <ITextViewModelProvider, IContentTypeAndTextViewRoleMetadata> > textViewModelProviders, IContentTypeRegistryService contentTypeRegistryService, IThemeService themeService, Lazy <ITextViewUndoManagerProvider> textViewUndoManagerProvider)
 {
     this.textBufferFactoryService    = textBufferFactoryService;
     this.editorOptionsFactoryService = editorOptionsFactoryService;
     this.commandService                              = commandService;
     this.smartIndentationService                     = smartIndentationService;
     this.wpfTextViewCreationListeners                = wpfTextViewCreationListeners.ToArray();
     this.textViewCreationListeners                   = textViewCreationListeners.ToArray();
     this.formattedTextSourceFactoryService           = formattedTextSourceFactoryService;
     this.viewClassifierAggregatorService             = viewClassifierAggregatorService;
     this.textAndAdornmentSequencerFactoryService     = textAndAdornmentSequencerFactoryService;
     this.classificationFormatMapService              = classificationFormatMapService;
     this.editorFormatMapService                      = editorFormatMapService;
     this.adornmentLayerDefinitionService             = adornmentLayerDefinitionService;
     this.lineTransformProviderService                = lineTransformProviderService;
     this.wpfTextViewMarginProviderCollectionProvider = wpfTextViewMarginProviderCollectionProvider;
     this.menuService = menuService;
     this.editorOperationsFactoryService = editorOperationsFactoryService;
     this.spaceReservationStackProvider  = spaceReservationStackProvider;
     this.wpfTextViewConnectionListenerServiceProvider = wpfTextViewConnectionListenerServiceProvider;
     this.bufferGraphFactoryService  = bufferGraphFactoryService;
     this.textViewModelProviders     = textViewModelProviders.ToArray();
     this.contentTypeRegistryService = contentTypeRegistryService;
     this.themeService = themeService;
     this.textViewUndoManagerProvider = textViewUndoManagerProvider;
 }
コード例 #6
0
        public DefaultTextBufferProvider(IBufferGraphFactoryService bufferGraphService)
        {
            if (bufferGraphService == null)
            {
                throw new ArgumentNullException(nameof(bufferGraphService));
            }

            _bufferGraphService = bufferGraphService;
        }
コード例 #7
0
 public NavigateToItemProvider(
     IBufferGraphFactoryService bufferGraphFactoryService,
     NavigateToItemProviderFactory navigateToItemProviderFactory,
     DispatcherGlyphService glyphService,
     IServiceProvider serviceProvider)
 {
     _bufferGraphFactoryService     = bufferGraphFactoryService;
     _navigateToItemProviderFactory = navigateToItemProviderFactory;
     _glyphService    = glyphService;
     _serviceProvider = serviceProvider;
 }
コード例 #8
0
 public NavigateToItemProvider(
     IBufferGraphFactoryService bufferGraphFactoryService, 
     NavigateToItemProviderFactory navigateToItemProviderFactory, 
     DispatcherGlyphService glyphService,
     IServiceProvider serviceProvider)
 {
     _bufferGraphFactoryService = bufferGraphFactoryService;
     _navigateToItemProviderFactory = navigateToItemProviderFactory;
     _glyphService = glyphService;
     _serviceProvider = serviceProvider;
 }
コード例 #9
0
        private static SnapshotSpan MapTo(IBufferGraphFactoryService bufferGraphFactoryService, SnapshotSpan span, ITextSnapshot snapshot, SpanTrackingMode spanTrackingMode)
        {
            if (span.Snapshot.TextBuffer == snapshot.TextBuffer)
                return span.TranslateTo(snapshot, spanTrackingMode);

            var graph = bufferGraphFactoryService.CreateBufferGraph(snapshot.TextBuffer);
            var mappingSpan = graph.CreateMappingSpan(span, spanTrackingMode);
            var mapped = mappingSpan.GetSpans(snapshot);
            if (mapped.Count == 1)
                return mapped[0];

            return new SnapshotSpan(mapped[0].Start, mapped[mapped.Count - 1].End);
        }
コード例 #10
0
        public static void NavigateTo(this IWpfTextView textView, IBufferGraphFactoryService bufferGraphFactoryService, SnapshotSpan targetSpan, SnapshotSpan targetSeek)
        {
            // show the span, then adjust if necessary to make sure the seek portion is visible
            var span = MapTo(bufferGraphFactoryService, targetSpan, textView.TextSnapshot, SpanTrackingMode.EdgeInclusive);
            textView.ViewScroller.EnsureSpanVisible(span, EnsureSpanVisibleOptions.AlwaysCenter | EnsureSpanVisibleOptions.ShowStart);

            var seek = targetSeek.Snapshot == null ? targetSpan : targetSeek;
            seek = MapTo(bufferGraphFactoryService, seek, textView.TextSnapshot, SpanTrackingMode.EdgeInclusive);
            textView.Caret.MoveTo(seek.Start);
            textView.Selection.Select(seek, false);
            textView.ViewScroller.EnsureSpanVisible(seek, EnsureSpanVisibleOptions.MinimumScroll | EnsureSpanVisibleOptions.ShowStart);
            Keyboard.Focus(textView.VisualElement);
        }
コード例 #11
0
 public NavigateToItemProvider(
     IBufferGraphFactoryService bufferGraphFactoryService, 
     NavigateToItemProviderFactory navigateToItemProviderFactory, 
     DispatcherGlyphService glyphService,
     IServiceProvider serviceProvider,
     VisualStudioSourceTextFactory sourceTextFactory)
 {
     _bufferGraphFactoryService = bufferGraphFactoryService;
     _navigateToItemProviderFactory = navigateToItemProviderFactory;
     _glyphService = glyphService;
     _serviceProvider = serviceProvider;
     _sourceTextFactory = sourceTextFactory;
 }
コード例 #12
0
 // Constructor for testing
 protected AbstractDebuggerIntelliSenseContext(IWpfTextView wpfTextView,
     ITextBuffer contextBuffer,
     Microsoft.VisualStudio.TextManager.Interop.TextSpan[] currentStatementSpan,
     IComponentModel componentModel,
     IContentType contentType,
     bool isImmediateWindow)
 {
     _textView = wpfTextView;
     this.ContextBuffer = contextBuffer;
     this.CurrentStatementSpan = currentStatementSpan[0];
     _contentType = contentType;
     this.ProjectionBufferFactoryService = componentModel.GetService<IProjectionBufferFactoryService>();
     _bufferGraphFactoryService = componentModel.GetService<IBufferGraphFactoryService>();
     _isImmediateWindow = isImmediateWindow;
 }
コード例 #13
0
        public static void NavigateTo(this IWpfTextView textView, IBufferGraphFactoryService bufferGraphFactoryService, SnapshotSpan targetSpan, SnapshotSpan targetSeek)
        {
            // show the span, then adjust if necessary to make sure the seek portion is visible
            var span = MapTo(bufferGraphFactoryService, targetSpan, textView.TextSnapshot, SpanTrackingMode.EdgeInclusive);

            textView.ViewScroller.EnsureSpanVisible(span, EnsureSpanVisibleOptions.AlwaysCenter | EnsureSpanVisibleOptions.ShowStart);

            var seek = targetSeek.Snapshot == null ? targetSpan : targetSeek;

            seek = MapTo(bufferGraphFactoryService, seek, textView.TextSnapshot, SpanTrackingMode.EdgeInclusive);
            textView.Caret.MoveTo(seek.Start);
            textView.Selection.Select(seek, false);
            textView.ViewScroller.EnsureSpanVisible(seek, EnsureSpanVisibleOptions.MinimumScroll | EnsureSpanVisibleOptions.ShowStart);
            Keyboard.Focus(textView.VisualElement);
        }
コード例 #14
0
 // Constructor for testing
 protected AbstractDebuggerIntelliSenseContext(IWpfTextView wpfTextView,
                                               ITextBuffer contextBuffer,
                                               Microsoft.VisualStudio.TextManager.Interop.TextSpan[] currentStatementSpan,
                                               IComponentModel componentModel,
                                               IContentType contentType,
                                               bool isImmediateWindow)
 {
     _textView                           = wpfTextView;
     this.ContextBuffer                  = contextBuffer;
     this.CurrentStatementSpan           = currentStatementSpan[0];
     _contentType                        = contentType;
     this.ProjectionBufferFactoryService = componentModel.GetService <IProjectionBufferFactoryService>();
     _bufferGraphFactoryService          = componentModel.GetService <IBufferGraphFactoryService>();
     _isImmediateWindow                  = isImmediateWindow;
 }
コード例 #15
0
 public NavigateToVisitor(
     string searchValue,
     ITextSnapshot snapshot, IWpfTextView textView,
     INavigateToCallback callback,
     IBufferGraphFactoryService bufferGraphFactoryService,
     INavigateToItemDisplayFactory displayFactory,
     DispatcherGlyphService glyphService,
     CancellationToken cancellationToken)
 {
     _searchValue = searchValue;
     _snapshot    = snapshot;
     _textView    = textView;
     _callback    = callback;
     _bufferGraphFactoryService = bufferGraphFactoryService;
     _displayFactory            = displayFactory;
     _glyphService      = glyphService;
     _cancellationToken = cancellationToken;
 }
コード例 #16
0
        private static SnapshotSpan MapTo(IBufferGraphFactoryService bufferGraphFactoryService, SnapshotSpan span, ITextSnapshot snapshot, SpanTrackingMode spanTrackingMode)
        {
            if (span.Snapshot.TextBuffer == snapshot.TextBuffer)
            {
                return(span.TranslateTo(snapshot, spanTrackingMode));
            }

            var graph       = bufferGraphFactoryService.CreateBufferGraph(snapshot.TextBuffer);
            var mappingSpan = graph.CreateMappingSpan(span, spanTrackingMode);
            var mapped      = mappingSpan.GetSpans(snapshot);

            if (mapped.Count == 1)
            {
                return(mapped[0]);
            }

            return(new SnapshotSpan(mapped[0].Start, mapped[mapped.Count - 1].End));
        }
コード例 #17
0
 public NavigateToVisitor(
     string searchValue, 
     ITextSnapshot snapshot, IWpfTextView textView,
     INavigateToCallback callback, 
     IBufferGraphFactoryService bufferGraphFactoryService,
     INavigateToItemDisplayFactory displayFactory, 
     DispatcherGlyphService glyphService,
     CancellationToken cancellationToken)
 {
     _searchValue = searchValue;
     _snapshot = snapshot;
     _textView = textView;
     _callback = callback;
     _bufferGraphFactoryService = bufferGraphFactoryService;
     _displayFactory = displayFactory;
     _glyphService = glyphService;
     _cancellationToken = cancellationToken;
 }
コード例 #18
0
        public EditorNavigationDropdownBarClient(IVsCodeWindow codeWindow, IVsEditorAdaptersFactoryService editorAdaptersFactory, EditorNavigationSource source, IBufferGraphFactoryService bufferGraphFactoryService)
        {
            _codeWindow            = codeWindow;
            _editorAdaptersFactory = editorAdaptersFactory;
            _source = source;
            _bufferGraphFactoryService = bufferGraphFactoryService;
            _currentTextView           = editorAdaptersFactory.GetWpfTextView(codeWindow.GetLastActiveView());
            _dispatcher = _currentTextView.VisualElement.Dispatcher;
            _imageList  = new ImageList
            {
                ColorDepth = ColorDepth.Depth32Bit
            };

            var connectionPointContainer = codeWindow as IConnectionPointContainer;

            if (connectionPointContainer != null)
            {
                var textViewEventsGuid = typeof(IVsCodeWindowEvents).GUID;
                IConnectionPoint connectionPoint;
                connectionPointContainer.FindConnectionPoint(ref textViewEventsGuid, out connectionPoint);
                connectionPoint?.Advise(this, out _codeWindowEventsCookie);
            }

            var primaryView = codeWindow.GetPrimaryView();

            if (primaryView != null)
            {
                ((IVsCodeWindowEvents)this).OnNewView(primaryView);
            }

            var secondaryView = codeWindow.GetSecondaryView();

            if (secondaryView != null)
            {
                ((IVsCodeWindowEvents)this).OnNewView(secondaryView);
            }

            _navigationItems = new List <EditorTypeNavigationTarget>();

            source.NavigationTargetsChanged += OnNavigationTargetsChanged;
            UpdateNavigationTargets();

            _currentTextView.Caret.PositionChanged += OnCaretPositionChanged;
        }
コード例 #19
0
 protected AbstractDebuggerIntelliSenseContext(
     IWpfTextView wpfTextView,
     IVsTextView vsTextView,
     IVsTextLines vsDebuggerTextLines,
     ITextBuffer contextBuffer,
     Microsoft.VisualStudio.TextManager.Interop.TextSpan[] currentStatementSpan,
     IComponentModel componentModel,
     IServiceProvider serviceProvider,
     IContentType contentType)
 {
     _textView = wpfTextView;
     _debuggerTextLines = vsDebuggerTextLines;
     this.ContextBuffer = contextBuffer;
     this.CurrentStatementSpan = currentStatementSpan[0];
     _contentType = contentType;
     this.ProjectionBufferFactoryService = componentModel.GetService<IProjectionBufferFactoryService>();
     _bufferGraphFactoryService = componentModel.GetService<IBufferGraphFactoryService>();
     _isImmediateWindow = IsImmediateWindow((IVsUIShell)serviceProvider.GetService(typeof(SVsUIShell)), vsTextView);
 }
コード例 #20
0
        public EditorNavigationDropdownBarClient(IVsCodeWindow codeWindow, IVsEditorAdaptersFactoryService editorAdaptersFactory, EditorNavigationSource source, IBufferGraphFactoryService bufferGraphFactoryService)
        {
            _codeWindow = codeWindow;
            _editorAdaptersFactory = editorAdaptersFactory;
            _source = source;
            _bufferGraphFactoryService = bufferGraphFactoryService;
            _currentTextView = editorAdaptersFactory.GetWpfTextView(codeWindow.GetLastActiveView());
            _dispatcher = _currentTextView.VisualElement.Dispatcher;
            _imageList = new ImageList
            {
                ColorDepth = ColorDepth.Depth32Bit
            };

            var connectionPointContainer = codeWindow as IConnectionPointContainer;
            if (connectionPointContainer != null)
            {
                var textViewEventsGuid = typeof(IVsCodeWindowEvents).GUID;
                IConnectionPoint connectionPoint;
                connectionPointContainer.FindConnectionPoint(ref textViewEventsGuid, out connectionPoint);
                connectionPoint?.Advise(this, out _codeWindowEventsCookie);
            }

            var primaryView = codeWindow.GetPrimaryView();
            if (primaryView != null)
                ((IVsCodeWindowEvents)this).OnNewView(primaryView);

            var secondaryView = codeWindow.GetSecondaryView();
            if (secondaryView != null)
                ((IVsCodeWindowEvents)this).OnNewView(secondaryView);

            _navigationItems = new List<EditorTypeNavigationTarget>();

            source.NavigationTargetsChanged += OnNavigationTargetsChanged;
            UpdateNavigationTargets();

            _currentTextView.Caret.PositionChanged += OnCaretPositionChanged;
        }
コード例 #21
0
        public DefaultVisualStudioWorkspaceAccessor(
            IBufferGraphFactoryService bufferGraphService,
            TextBufferProjectService projectService,
            [Import(typeof(VisualStudioWorkspace))] Workspace defaultWorkspace)
        {
            if (bufferGraphService is null)
            {
                throw new ArgumentNullException(nameof(bufferGraphService));
            }

            if (projectService is null)
            {
                throw new ArgumentNullException(nameof(projectService));
            }

            if (defaultWorkspace is null)
            {
                throw new ArgumentNullException(nameof(defaultWorkspace));
            }

            _bufferGraphService = bufferGraphService;
            _projectService     = projectService;
            _defaultWorkspace   = defaultWorkspace;
        }
コード例 #22
0
        public EditorNavigationDropdownBar(IVsCodeWindow codeWindow, IVsEditorAdaptersFactoryService editorAdaptersFactory, IEnumerable <IEditorNavigationSource> sources, IBufferGraphFactoryService bufferGraphFactoryService, IEditorNavigationTypeRegistryService editorNavigationTypeRegistryService)
        {
            Contract.Requires <ArgumentNullException>(codeWindow != null, "codeWindow");
            Contract.Requires <ArgumentNullException>(editorAdaptersFactory != null, "editorAdaptersFactory");
            Contract.Requires <ArgumentNullException>(sources != null, "sources");
            Contract.Requires <ArgumentNullException>(bufferGraphFactoryService != null, "bufferGraphFactoryService");
            Contract.Requires <ArgumentNullException>(editorNavigationTypeRegistryService != null, "editorNavigationTypeRegistryService");

            this._codeWindow            = codeWindow;
            this._editorAdaptersFactory = editorAdaptersFactory;
            this._sources = sources;
            this._bufferGraphFactoryService           = bufferGraphFactoryService;
            this._editorNavigationTypeRegistryService = editorNavigationTypeRegistryService;
            this._currentTextView = editorAdaptersFactory.GetWpfTextView(codeWindow.GetLastActiveView());
            this._dispatcher      = this._currentTextView.VisualElement.Dispatcher;
            this._imageList       = new ImageList()
            {
                ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit
            };

            _navigationControls =
                this._sources
                .SelectMany(source => source.GetNavigationTypes())
                .Distinct()
                //.OrderBy(...)
                .Select(type => Tuple.Create(type, new List <IEditorNavigationTarget>()))
                .ToArray();

            _selectedItem = new IEditorNavigationTarget[_navigationControls.Length];

            if (this._navigationControls.Length == 0)
            {
                return;
            }

            IConnectionPointContainer connectionPointContainer = codeWindow as IConnectionPointContainer;

            if (connectionPointContainer != null)
            {
                Guid             textViewEventsGuid = typeof(IVsCodeWindowEvents).GUID;
                IConnectionPoint connectionPoint;
                connectionPointContainer.FindConnectionPoint(ref textViewEventsGuid, out connectionPoint);
                if (connectionPoint != null)
                {
                    connectionPoint.Advise(this, out _codeWindowEventsCookie);
                }
            }

            IVsTextView primaryView = codeWindow.GetPrimaryView();

            if (primaryView != null)
            {
                ((IVsCodeWindowEvents)this).OnNewView(primaryView);
            }

            IVsTextView secondaryView = codeWindow.GetSecondaryView();

            if (secondaryView != null)
            {
                ((IVsCodeWindowEvents)this).OnNewView(secondaryView);
            }

            foreach (var source in this._sources)
            {
                source.NavigationTargetsChanged += WeakEvents.AsWeak(OnNavigationTargetsChanged, eh => source.NavigationTargetsChanged -= eh);
                UpdateNavigationTargets(source);
            }

            _currentTextView.Caret.PositionChanged += OnCaretPositionChanged;
        }
コード例 #23
0
 public ReplAggregateClassifier(IBufferGraphFactoryService bufferGraphFactory, ITextBuffer buffer)
 {
     _primaryBuffer = buffer;
     _bufGraphFact  = bufferGraphFactory;
     _bufferGraph   = bufferGraphFactory.CreateBufferGraph(buffer);
 }
コード例 #24
0
		TextEditorFactoryService(ITextBufferFactoryService textBufferFactoryService, IEditorOptionsFactoryService editorOptionsFactoryService, ICommandService commandService, ISmartIndentationService smartIndentationService, [ImportMany] IEnumerable<Lazy<IWpfTextViewCreationListener, IDeferrableContentTypeAndTextViewRoleMetadata>> wpfTextViewCreationListeners, IFormattedTextSourceFactoryService formattedTextSourceFactoryService, IViewClassifierAggregatorService viewClassifierAggregatorService, ITextAndAdornmentSequencerFactoryService textAndAdornmentSequencerFactoryService, IClassificationFormatMapService classificationFormatMapService, IEditorFormatMapService editorFormatMapService, IAdornmentLayerDefinitionService adornmentLayerDefinitionService, ILineTransformProviderService lineTransformProviderService, IWpfTextViewMarginProviderCollectionProvider wpfTextViewMarginProviderCollectionProvider, IMenuService menuService, IEditorOperationsFactoryService editorOperationsFactoryService, ISpaceReservationStackProvider spaceReservationStackProvider, IWpfTextViewConnectionListenerServiceProvider wpfTextViewConnectionListenerServiceProvider, IBufferGraphFactoryService bufferGraphFactoryService, [ImportMany] IEnumerable<Lazy<ITextViewModelProvider, IContentTypeAndTextViewRoleMetadata>> textViewModelProviders, IContentTypeRegistryService contentTypeRegistryService, Lazy<ITextViewUndoManagerProvider> textViewUndoManagerProvider) {
			this.textBufferFactoryService = textBufferFactoryService;
			this.editorOptionsFactoryService = editorOptionsFactoryService;
			this.commandService = commandService;
			this.smartIndentationService = smartIndentationService;
			this.wpfTextViewCreationListeners = wpfTextViewCreationListeners.ToArray();
			this.formattedTextSourceFactoryService = formattedTextSourceFactoryService;
			this.viewClassifierAggregatorService = viewClassifierAggregatorService;
			this.textAndAdornmentSequencerFactoryService = textAndAdornmentSequencerFactoryService;
			this.classificationFormatMapService = classificationFormatMapService;
			this.editorFormatMapService = editorFormatMapService;
			this.adornmentLayerDefinitionService = adornmentLayerDefinitionService;
			this.lineTransformProviderService = lineTransformProviderService;
			this.wpfTextViewMarginProviderCollectionProvider = wpfTextViewMarginProviderCollectionProvider;
			this.menuService = menuService;
			this.editorOperationsFactoryService = editorOperationsFactoryService;
			this.spaceReservationStackProvider = spaceReservationStackProvider;
			this.wpfTextViewConnectionListenerServiceProvider = wpfTextViewConnectionListenerServiceProvider;
			this.bufferGraphFactoryService = bufferGraphFactoryService;
			this.textViewModelProviders = textViewModelProviders.ToArray();
			this.contentTypeRegistryService = contentTypeRegistryService;
			this.textViewUndoManagerProvider = textViewUndoManagerProvider;
		}
コード例 #25
0
        public TemplateProjectionBuffer(IContentTypeRegistryService contentRegistry, IProjectionBufferFactoryService bufferFactory, ITextBuffer diskBuffer, IBufferGraphFactoryService bufferGraphFactory, IContentType contentType)
        {
            _diskBuffer      = diskBuffer;
            _contentRegistry = contentRegistry;
            _contentType     = contentType;

            _projBuffer = bufferFactory.CreateProjectionBuffer(
                this,
                new object[0],
                ProjectionBufferOptions.None
                );
            _projBuffer.Properties.AddProperty(typeof(TemplateProjectionBuffer), this);

            _bufferGraph = bufferGraphFactory.CreateBufferGraph(_projBuffer);

            _htmlBuffer     = CreateHtmlBuffer(bufferFactory);
            _templateBuffer = CreateTemplateBuffer(bufferFactory);

            IVsTextBuffer buffer;

            if (_diskBuffer.Properties.TryGetProperty <IVsTextBuffer>(typeof(IVsTextBuffer), out buffer))
            {
                // keep the Venus HTML classifier happy - it wants to find a site via IVsTextBuffer
                _htmlBuffer.Properties.AddProperty(typeof(IVsTextBuffer), buffer);
            }

            var reader = new SnapshotSpanSourceCodeReader(new SnapshotSpan(diskBuffer.CurrentSnapshot, new Span(0, diskBuffer.CurrentSnapshot.Length)));

            UpdateTemplateSpans(reader);
        }
コード例 #26
0
        public EditorNavigationDropdownBar(IVsCodeWindow codeWindow, IVsEditorAdaptersFactoryService editorAdaptersFactory, IEnumerable<IEditorNavigationSource> sources, IBufferGraphFactoryService bufferGraphFactoryService, IJavaEditorNavigationTypeRegistryService editorNavigationTypeRegistryService)
        {
            Contract.Requires<ArgumentNullException>(codeWindow != null, "codeWindow");
            Contract.Requires<ArgumentNullException>(editorAdaptersFactory != null, "editorAdaptersFactory");
            Contract.Requires<ArgumentNullException>(sources != null, "sources");
            Contract.Requires<ArgumentNullException>(bufferGraphFactoryService != null, "bufferGraphFactoryService");
            Contract.Requires<ArgumentNullException>(editorNavigationTypeRegistryService != null, "editorNavigationTypeRegistryService");

            this._codeWindow = codeWindow;
            this._editorAdaptersFactory = editorAdaptersFactory;
            this._sources = sources;
            this._bufferGraphFactoryService = bufferGraphFactoryService;
            this._editorNavigationTypeRegistryService = editorNavigationTypeRegistryService;
            this._currentTextView = editorAdaptersFactory.GetWpfTextView(codeWindow.GetLastActiveView());
            this._dispatcher = this._currentTextView.VisualElement.Dispatcher;
            this._imageList = new ImageList()
                {
                    ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit
                };

            _navigationControls =
                this._sources
                .SelectMany(source => source.GetNavigationTypes())
                .Distinct()
                //.OrderBy(...)
                .Select(type => Tuple.Create(type, new List<IEditorNavigationTarget>()))
                .ToArray();

            _selectedItem = new IEditorNavigationTarget[_navigationControls.Length];

            if (this._navigationControls.Length == 0)
            {
                return;
            }

            IConnectionPointContainer connectionPointContainer = codeWindow as IConnectionPointContainer;
            if (connectionPointContainer != null)
            {
                Guid textViewEventsGuid = typeof(IVsCodeWindowEvents).GUID;
                IConnectionPoint connectionPoint;
                connectionPointContainer.FindConnectionPoint(ref textViewEventsGuid, out connectionPoint);
                if (connectionPoint != null)
                    connectionPoint.Advise(this, out _codeWindowEventsCookie);
            }

            IVsTextView primaryView = codeWindow.GetPrimaryView();
            if (primaryView != null)
                ((IVsCodeWindowEvents)this).OnNewView(primaryView);

            IVsTextView secondaryView = codeWindow.GetSecondaryView();
            if (secondaryView != null)
                ((IVsCodeWindowEvents)this).OnNewView(secondaryView);

            foreach (var source in this._sources)
            {
                source.NavigationTargetsChanged += WeakEvents.AsWeak(OnNavigationTargetsChanged, eh => source.NavigationTargetsChanged -= eh);
                UpdateNavigationTargets(source);
            }

            _currentTextView.Caret.PositionChanged += OnCaretPositionChanged;
        }
コード例 #27
0
 BufferTagAggregatorFactoryService(ITaggerFactory taggerFactory, IBufferGraphFactoryService bufferGraphFactoryService)
 {
     this.taggerFactory             = taggerFactory;
     this.bufferGraphFactoryService = bufferGraphFactoryService;
 }
コード例 #28
0
 public ReplAggregateClassifier(IBufferGraphFactoryService bufferGraphFactory, ITextBuffer buffer) {            
     _primaryBuffer = buffer;
     _bufGraphFact = bufferGraphFactory;
     _bufferGraph = bufferGraphFactory.CreateBufferGraph(buffer);
 }
コード例 #29
0
 public static void Initialize()
 {
     GuardedOperations         = CreateObject <object>("Microsoft.VisualStudio.Text.Utilities.GuardedOperations, Microsoft.VisualStudio.Platform.VSEditor");
     BufferGraphFactoryService = CreateObject <IBufferGraphFactoryService>("Microsoft.VisualStudio.Text.Projection.Implementation.BufferGraphFactoryService, Microsoft.VisualStudio.Platform.VSEditor");
     SetField(BufferGraphFactoryService, nameof(GuardedOperations), GuardedOperations);
 }
コード例 #30
0
ファイル: WpfTextView.cs プロジェクト: manojdjoshi/dnSpy
#pragma warning restore 0169

		public WpfTextView(ITextViewModel textViewModel, ITextViewRoleSet roles, IEditorOptions parentOptions, IEditorOptionsFactoryService editorOptionsFactoryService, ICommandService commandService, ISmartIndentationService smartIndentationService, IFormattedTextSourceFactoryService formattedTextSourceFactoryService, IViewClassifierAggregatorService viewClassifierAggregatorService, ITextAndAdornmentSequencerFactoryService textAndAdornmentSequencerFactoryService, IClassificationFormatMapService classificationFormatMapService, IEditorFormatMapService editorFormatMapService, IAdornmentLayerDefinitionService adornmentLayerDefinitionService, ILineTransformProviderService lineTransformProviderService, ISpaceReservationStackProvider spaceReservationStackProvider, IWpfTextViewConnectionListenerServiceProvider wpfTextViewConnectionListenerServiceProvider, IBufferGraphFactoryService bufferGraphFactoryService, Lazy<IWpfTextViewCreationListener, IDeferrableContentTypeAndTextViewRoleMetadata>[] wpfTextViewCreationListeners) {
			if (textViewModel == null)
				throw new ArgumentNullException(nameof(textViewModel));
			if (roles == null)
				throw new ArgumentNullException(nameof(roles));
			if (parentOptions == null)
				throw new ArgumentNullException(nameof(parentOptions));
			if (editorOptionsFactoryService == null)
				throw new ArgumentNullException(nameof(editorOptionsFactoryService));
			if (commandService == null)
				throw new ArgumentNullException(nameof(commandService));
			if (smartIndentationService == null)
				throw new ArgumentNullException(nameof(smartIndentationService));
			if (formattedTextSourceFactoryService == null)
				throw new ArgumentNullException(nameof(formattedTextSourceFactoryService));
			if (viewClassifierAggregatorService == null)
				throw new ArgumentNullException(nameof(viewClassifierAggregatorService));
			if (textAndAdornmentSequencerFactoryService == null)
				throw new ArgumentNullException(nameof(textAndAdornmentSequencerFactoryService));
			if (classificationFormatMapService == null)
				throw new ArgumentNullException(nameof(classificationFormatMapService));
			if (editorFormatMapService == null)
				throw new ArgumentNullException(nameof(editorFormatMapService));
			if (adornmentLayerDefinitionService == null)
				throw new ArgumentNullException(nameof(adornmentLayerDefinitionService));
			if (lineTransformProviderService == null)
				throw new ArgumentNullException(nameof(lineTransformProviderService));
			if (spaceReservationStackProvider == null)
				throw new ArgumentNullException(nameof(spaceReservationStackProvider));
			if (wpfTextViewCreationListeners == null)
				throw new ArgumentNullException(nameof(wpfTextViewCreationListeners));
			if (wpfTextViewConnectionListenerServiceProvider == null)
				throw new ArgumentNullException(nameof(wpfTextViewConnectionListenerServiceProvider));
			if (bufferGraphFactoryService == null)
				throw new ArgumentNullException(nameof(bufferGraphFactoryService));
			mouseHoverHelper = new MouseHoverHelper(this);
			physicalLineCache = new PhysicalLineCache(32);
			visiblePhysicalLines = new List<PhysicalLine>();
			invalidatedRegions = new List<SnapshotSpan>();
			this.formattedTextSourceFactoryService = formattedTextSourceFactoryService;
			zoomLevel = ZoomConstants.DefaultZoom;
			DsImage.SetZoom(VisualElement, zoomLevel / 100);
			this.adornmentLayerDefinitionService = adornmentLayerDefinitionService;
			this.lineTransformProviderService = lineTransformProviderService;
			this.wpfTextViewCreationListeners = wpfTextViewCreationListeners.Where(a => roles.ContainsAny(a.Metadata.TextViewRoles)).ToArray();
			recreateLineTransformProvider = true;
			normalAdornmentLayerCollection = new AdornmentLayerCollection(this, LayerKind.Normal);
			overlayAdornmentLayerCollection = new AdornmentLayerCollection(this, LayerKind.Overlay);
			underlayAdornmentLayerCollection = new AdornmentLayerCollection(this, LayerKind.Underlay);
			IsVisibleChanged += WpfTextView_IsVisibleChanged;
			Properties = new PropertyCollection();
			TextViewModel = textViewModel;
			BufferGraph = bufferGraphFactoryService.CreateBufferGraph(TextViewModel.VisualBuffer);
			Roles = roles;
			Options = editorOptionsFactoryService.GetOptions(this);
			Options.Parent = parentOptions;
			ViewScroller = new ViewScroller(this);
			hasKeyboardFocus = IsKeyboardFocusWithin;
			oldViewState = new ViewState(this);
			aggregateClassifier = viewClassifierAggregatorService.GetClassifier(this);
			textAndAdornmentSequencer = textAndAdornmentSequencerFactoryService.Create(this);
			classificationFormatMap = classificationFormatMapService.GetClassificationFormatMap(this);
			editorFormatMap = editorFormatMapService.GetEditorFormatMap(this);
			spaceReservationStack = spaceReservationStackProvider.Create(this);

			textLayer = new TextLayer(GetAdornmentLayer(PredefinedAdornmentLayers.Text));
			Selection = new TextSelection(this, GetAdornmentLayer(PredefinedAdornmentLayers.Selection), editorFormatMap);
			TextCaret = new TextCaret(this, GetAdornmentLayer(PredefinedAdornmentLayers.Caret), smartIndentationService, classificationFormatMap);

			Children.Add(underlayAdornmentLayerCollection);
			Children.Add(normalAdornmentLayerCollection);
			Children.Add(overlayAdornmentLayerCollection);
			Cursor = Cursors.IBeam;
			Focusable = true;
			FocusVisualStyle = null;
			InitializeOptions();

			Options.OptionChanged += EditorOptions_OptionChanged;
			TextBuffer.ChangedLowPriority += TextBuffer_ChangedLowPriority;
			TextViewModel.DataModel.ContentTypeChanged += DataModel_ContentTypeChanged;
			aggregateClassifier.ClassificationChanged += AggregateClassifier_ClassificationChanged;
			textAndAdornmentSequencer.SequenceChanged += TextAndAdornmentSequencer_SequenceChanged;
			classificationFormatMap.ClassificationFormatMappingChanged += ClassificationFormatMap_ClassificationFormatMappingChanged;
			editorFormatMap.FormatMappingChanged += EditorFormatMap_FormatMappingChanged;
			spaceReservationStack.GotAggregateFocus += SpaceReservationStack_GotAggregateFocus;
			spaceReservationStack.LostAggregateFocus += SpaceReservationStack_LostAggregateFocus;

			UpdateBackground();
			CreateFormattedLineSource(ViewportWidth);
			InitializeZoom();
			UpdateRemoveExtraTextLineVerticalPixels();

			if (Roles.Contains(PredefinedTextViewRoles.Interactive))
				RegisteredCommandElement = commandService.Register(VisualElement, this);
			else
				RegisteredCommandElement = NullRegisteredCommandElement.Instance;

			wpfTextViewConnectionListenerServiceProvider.Create(this);
			NotifyTextViewCreated(TextViewModel.DataModel.ContentType, null);
		}