Example #1
0
        public void TestSynchronousOutlining()
        {
            using (var workspace = TestWorkspace.CreateCSharp("class Program {\r\n\r\n}"))
            {
                WpfTestRunner.RequireWpfFact($"{nameof(AsynchronousTaggerTests)}.{nameof(TestSynchronousOutlining)} creates asynchronous taggers");

                var tagProvider = new VisualStudio14StructureTaggerProvider(
                    workspace.ExportProvider.GetExportedValue <IThreadingContext>(),
                    workspace.GetService <IForegroundNotificationService>(),
                    workspace.GetService <ITextEditorFactoryService>(),
                    workspace.GetService <IEditorOptionsFactoryService>(),
                    workspace.GetService <IProjectionBufferFactoryService>(),
                    workspace.ExportProvider.GetExportedValue <IAsynchronousOperationListenerProvider>());

                var document   = workspace.Documents.First();
                var textBuffer = document.TextBuffer;
                var tagger     = tagProvider.CreateTagger <IOutliningRegionTag>(textBuffer);

                using (var disposable = (IDisposable)tagger)
                {
                    // The very first all to get tags should return the single outlining span.
                    var tags = tagger.GetAllTags(new NormalizedSnapshotSpanCollection(textBuffer.CurrentSnapshot.GetFullSpan()), CancellationToken.None);
                    Assert.Equal(1, tags.Count());
                }
            }
        }
Example #2
0
        public VisualStudioSymbolNavigationService(
            SVsServiceProvider serviceProvider,
            VisualStudio14StructureTaggerProvider outliningTaggerProvider)
            : base(outliningTaggerProvider.ThreadingContext)
        {
            _serviceProvider = serviceProvider;

            var componentModel = _serviceProvider.GetService <SComponentModel, IComponentModel>();

            _editorAdaptersFactory       = componentModel.GetService <IVsEditorAdaptersFactoryService>();
            _metadataAsSourceFileService = componentModel.GetService <IMetadataAsSourceFileService>();
        }
        public VisualStudioSymbolNavigationService(
            SVsServiceProvider serviceProvider,
            VisualStudio14StructureTaggerProvider outliningTaggerProvider)
        {
            _serviceProvider = serviceProvider;
            _outliningTaggerProvider = outliningTaggerProvider;

            var componentModel = _serviceProvider.GetService<SComponentModel, IComponentModel>();
            _editorAdaptersFactory = componentModel.GetService<IVsEditorAdaptersFactoryService>();
            _textEditorFactoryService = componentModel.GetService<ITextEditorFactoryService>();
            _textDocumentFactoryService = componentModel.GetService<ITextDocumentFactoryService>();
            _metadataAsSourceFileService = componentModel.GetService<IMetadataAsSourceFileService>();
        }
Example #4
0
        private static async Task <List <IOutliningRegionTag> > GetTagsFromWorkspaceAsync(TestWorkspace workspace)
        {
            var hostdoc           = workspace.Documents.First();
            var view              = hostdoc.GetTextView();
            var textService       = workspace.GetService <ITextEditorFactoryService>();
            var editorService     = workspace.GetService <IEditorOptionsFactoryService>();
            var projectionService = workspace.GetService <IProjectionBufferFactoryService>();

            var provider = new VisualStudio14StructureTaggerProvider(
                workspace.ExportProvider.GetExportedValue <IForegroundNotificationService>(),
                textService, editorService, projectionService,
                AggregateAsynchronousOperationListener.EmptyListeners);

            var document = workspace.CurrentSolution.GetDocument(hostdoc.Id);
            var context  = new TaggerContext <IOutliningRegionTag>(document, view.TextSnapshot);
            await provider.ProduceTagsAsync_ForTestingPurposesOnly(context);

            return(context.tagSpans.Select(x => x.Tag).ToList());
        }
 public VisualStudioSymbolNavigationServiceFactory(
     SVsServiceProvider serviceProvider,
     [Import] VisualStudio14StructureTaggerProvider outliningTaggerProvider)
 {
     _singleton = new VisualStudioSymbolNavigationService(serviceProvider, outliningTaggerProvider);
 }
        private static async Task<List<IOutliningRegionTag>> GetTagsFromWorkspaceAsync(TestWorkspace workspace)
        {
            var hostdoc = workspace.Documents.First();
            var view = hostdoc.GetTextView();
            var textService = workspace.GetService<ITextEditorFactoryService>();
            var editorService = workspace.GetService<IEditorOptionsFactoryService>();
            var projectionService = workspace.GetService<IProjectionBufferFactoryService>();

            var provider = new VisualStudio14StructureTaggerProvider(
                workspace.ExportProvider.GetExportedValue<IForegroundNotificationService>(),
                textService, editorService, projectionService,
                AggregateAsynchronousOperationListener.EmptyListeners);

            var document = workspace.CurrentSolution.GetDocument(hostdoc.Id);
            var context = new TaggerContext<IOutliningRegionTag>(document, view.TextSnapshot);
            await provider.ProduceTagsAsync_ForTestingPurposesOnly(context);

            return context.tagSpans.Select(x => x.Tag).ToList();
        }