示例#1
0
        protected sealed override async Task ProduceTagsAsync(
            TaggerContext <TRegionTag> context, DocumentSnapshotSpan documentSnapshotSpan, int?caretPosition)
        {
            try
            {
                // Let LSP handle producing tags in the cloud scenario
                if (documentSnapshotSpan.Document.IsInCloudEnvironmentClientContext())
                {
                    return;
                }

                var outliningService = AbstractStructureTaggerProvider <TRegionTag> .TryGetService(context, documentSnapshotSpan);

                if (outliningService != null)
                {
                    var blockStructure = await outliningService.GetBlockStructureAsync(
                        documentSnapshotSpan.Document, context.CancellationToken).ConfigureAwait(false);

                    ProcessSpans(
                        context, documentSnapshotSpan.SnapshotSpan, outliningService,
                        blockStructure.Spans);
                }
            }
            catch (Exception e) when(FatalError.ReportAndPropagateUnlessCanceled(e))
            {
                throw ExceptionUtilities.Unreachable;
            }
        }
示例#2
0
        protected sealed override void ProduceTagsSynchronously(
            TaggerContext <TRegionTag> context, DocumentSnapshotSpan documentSnapshotSpan, int?caretPosition)
        {
            try
            {
                // Let LSP handle producing tags in the cloud scenario
                if (documentSnapshotSpan.Document.IsInCloudEnvironmentClientContext())
                {
                    return;
                }

                var outliningService = AbstractStructureTaggerProvider <TRegionTag> .TryGetService(context, documentSnapshotSpan);

                if (outliningService != null)
                {
                    var document          = documentSnapshotSpan.Document;
                    var cancellationToken = context.CancellationToken;

                    // Try to call through the synchronous service if possible. Otherwise, fallback
                    // and make a blocking call against the async service.

                    var blockStructure = outliningService.GetBlockStructure(document, cancellationToken);

                    ProcessSpans(
                        context, documentSnapshotSpan.SnapshotSpan, outliningService,
                        blockStructure.Spans);
                }
            }
            catch (Exception e) when(FatalError.ReportAndPropagateUnlessCanceled(e))
            {
                throw ExceptionUtilities.Unreachable;
            }
        }