Example #1
0
        public async Task TestSynchronousOutlining()
        {
            using (var workspace = await TestWorkspace.CreateCSharpAsync("class Program {\r\n\r\n}"))
            {
                WpfTestCase.RequireWpfFact($"{nameof(AsynchronousTaggerTests)}.{nameof(TestSynchronousOutlining)} creates asynchronous taggers");

                var tagProvider = new OutliningTaggerProvider(
                    workspace.GetService <IForegroundNotificationService>(),
                    workspace.GetService <ITextEditorFactoryService>(),
                    workspace.GetService <IEditorOptionsFactoryService>(),
                    workspace.GetService <IProjectionBufferFactoryService>(),
                    workspace.ExportProvider.GetExports <IAsynchronousOperationListener, FeatureMetadata>());

                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 void TestSynchronousOutlining()
        {
            using (var workspace = CSharpWorkspaceFactory.CreateWorkspaceFromFile("class Program {\r\n\r\n}"))
            {
                var tagProvider = new OutliningTaggerProvider(
                    workspace.GetService <IForegroundNotificationService>(),
                    workspace.GetService <ITextEditorFactoryService>(),
                    workspace.GetService <IEditorOptionsFactoryService>(),
                    workspace.GetService <IProjectionBufferFactoryService>(),
                    (IEnumerable <Lazy <IAsynchronousOperationListener, FeatureMetadata> >)workspace.ExportProvider.GetExports <IAsynchronousOperationListener, FeatureMetadata>());

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

                using (var disposable = (IDisposable)tagger)
                {
                    ProducerPopulatedTagSource <IOutliningRegionTag> tagSource = null;
                    tagProvider.TryRetrieveTagSource(null, textBuffer, out tagSource);
                    tagSource.ComputeTagsSynchronouslyIfNoAsynchronousComputationHasCompleted = true;

                    // The very first all to get tags should return the single outlining span.
                    var tags = tagger.GetTags(new NormalizedSnapshotSpanCollection(textBuffer.CurrentSnapshot.GetFullSpan()));
                    Assert.Equal(1, tags.Count());
                }
            }
        }
Example #3
0
        internal BraceMatchingTagger(ITextView view, ITextBuffer sourceBuffer)
        {
            this.View         = view;
            this.SourceBuffer = sourceBuffer;
            this.CurrentChar  = null;

            // Share the RegionParser
            this.outliningTagger = OutliningTaggerProvider.GetOrCreateOutliningTagger(sourceBuffer);

            this.View.Caret.PositionChanged += CaretPositionChanged;
            this.View.LayoutChanged         += ViewLayoutChanged;
        }
        public VisualStudioSymbolNavigationService(
            SVsServiceProvider serviceProvider,
            OutliningTaggerProvider 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>();
        }
        public VisualStudioSymbolNavigationService(
            SVsServiceProvider serviceProvider,
            OutliningTaggerProvider outliningTaggerProvider)
        {
            _serviceProvider         = serviceProvider;
            _outliningTaggerProvider = outliningTaggerProvider;

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

            _editorAdaptersFactory       = componentModel.GetService <IVsEditorAdaptersFactoryService>();
            _textEditorFactoryService    = componentModel.GetService <ITextEditorFactoryService>();
            _textDocumentFactoryService  = componentModel.GetService <ITextDocumentFactoryService>();
            _metadataAsSourceFileService = componentModel.GetService <IMetadataAsSourceFileService>();
        }
        private static List<IOutliningRegionTag> GetTagsFromWorkspace(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 OutliningTaggerProvider(
                workspace.ExportProvider.GetExportedValue<IForegroundNotificationService>(),
                textService, editorService, projectionService,
                AggregateAsynchronousOperationListener.EmptyListeners);

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

            return context.tagSpans.Select(x => x.Tag).ToList();
        }
Example #7
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 OutliningTaggerProvider(
                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();
        }
 private VisualStudioSymbolNavigationServiceFactory(
     SVsServiceProvider serviceProvider,
     [Import] OutliningTaggerProvider outliningTaggerProvider)
 {
     _singleton = new VisualStudioSymbolNavigationService(serviceProvider, outliningTaggerProvider);
 }