private static BlockStructure CreateBlockStructure(BlockStructureContext context)
        {
            var language = context.SyntaxTree.Options.Language;

            var showIndentGuidesForCodeLevelConstructs            = context.OptionProvider.GetOption(BlockStructureOptions.ShowBlockStructureGuidesForCodeLevelConstructs, language);
            var showIndentGuidesForDeclarationLevelConstructs     = context.OptionProvider.GetOption(BlockStructureOptions.ShowBlockStructureGuidesForDeclarationLevelConstructs, language);
            var showIndentGuidesForCommentsAndPreprocessorRegions = context.OptionProvider.GetOption(BlockStructureOptions.ShowBlockStructureGuidesForCommentsAndPreprocessorRegions, language);
            var showOutliningForCodeLevelConstructs            = context.OptionProvider.GetOption(BlockStructureOptions.ShowOutliningForCodeLevelConstructs, language);
            var showOutliningForDeclarationLevelConstructs     = context.OptionProvider.GetOption(BlockStructureOptions.ShowOutliningForDeclarationLevelConstructs, language);
            var showOutliningForCommentsAndPreprocessorRegions = context.OptionProvider.GetOption(BlockStructureOptions.ShowOutliningForCommentsAndPreprocessorRegions, language);

            using var _ = ArrayBuilder <BlockSpan> .GetInstance(out var updatedSpans);

            foreach (var span in context.Spans)
            {
                var updatedSpan = UpdateBlockSpan(span,
                                                  showIndentGuidesForCodeLevelConstructs,
                                                  showIndentGuidesForDeclarationLevelConstructs,
                                                  showIndentGuidesForCommentsAndPreprocessorRegions,
                                                  showOutliningForCodeLevelConstructs,
                                                  showOutliningForDeclarationLevelConstructs,
                                                  showOutliningForCommentsAndPreprocessorRegions);
                updatedSpans.Add(updatedSpan);
            }

            return(new BlockStructure(updatedSpans.ToImmutable()));
        }
Beispiel #2
0
        private static BlockStructure CreateBlockStructure(Document document, BlockStructureContext context)
        {
            var options  = context.Document.Project.Solution.Workspace.Options;
            var language = context.Document.Project.Language;

            var showIndentGuidesForCodeLevelConstructs            = options.GetOption(BlockStructureOptions.ShowBlockStructureGuidesForCodeLevelConstructs, language);
            var showIndentGuidesForDeclarationLevelConstructs     = options.GetOption(BlockStructureOptions.ShowBlockStructureGuidesForDeclarationLevelConstructs, language);
            var showIndentGuidesForCommentsAndPreprocessorRegions = options.GetOption(BlockStructureOptions.ShowBlockStructureGuidesForCommentsAndPreprocessorRegions, language);
            var showOutliningForCodeLevelConstructs            = options.GetOption(BlockStructureOptions.ShowOutliningForCodeLevelConstructs, language);
            var showOutliningForDeclarationLevelConstructs     = options.GetOption(BlockStructureOptions.ShowOutliningForDeclarationLevelConstructs, language);
            var showOutliningForCommentsAndPreprocessorRegions = options.GetOption(BlockStructureOptions.ShowOutliningForCommentsAndPreprocessorRegions, language);

            var updatedSpans = ArrayBuilder <BlockSpan> .GetInstance();

            foreach (var span in context.Spans)
            {
                var updatedSpan = UpdateBlockSpan(span,
                                                  showIndentGuidesForCodeLevelConstructs,
                                                  showIndentGuidesForDeclarationLevelConstructs,
                                                  showIndentGuidesForCommentsAndPreprocessorRegions,
                                                  showOutliningForCodeLevelConstructs,
                                                  showOutliningForDeclarationLevelConstructs,
                                                  showOutliningForCommentsAndPreprocessorRegions);
                updatedSpans.Add(updatedSpan);
            }

            return(new BlockStructure(updatedSpans.ToImmutableAndFree()));
        }
        public override async Task<BlockStructure> GetBlockStructureAsync(
            Document document, CancellationToken cancellationToken)
        {
            var context = new BlockStructureContext(document, cancellationToken);
            foreach (var provider in _providers)
            {
                await provider.ProvideBlockStructureAsync(context).ConfigureAwait(false);
            }

            return new BlockStructure(context.Spans);
        }
        private static async Task <BlockStructure> GetBlockStructureAsync(
            BlockStructureContext context,
            ImmutableArray <BlockStructureProvider> providers)
        {
            foreach (var provider in providers)
            {
                await provider.ProvideBlockStructureAsync(context).ConfigureAwait(false);
            }

            return(CreateBlockStructure(context));
        }
        private static BlockStructure GetBlockStructure(
            BlockStructureContext context,
            ImmutableArray <BlockStructureProvider> providers)
        {
            foreach (var provider in providers)
            {
                provider.ProvideBlockStructure(context);
            }

            return(CreateBlockStructure(context));
        }
        private void ProvideBlockStructureWorker(
            BlockStructureContext context, SyntaxNode syntaxRoot)
        {
            var spans = ArrayBuilder<BlockSpan>.GetInstance();
            BlockSpanCollector.CollectBlockSpans(
                context.Document, syntaxRoot, _nodeProviderMap, _triviaProviderMap, spans, context.CancellationToken);

            UpdateAndAddSpans(context, spans);

            spans.Free();
        }
        public override BlockStructure GetBlockStructure(
            Document document, CancellationToken cancellationToken)
        {
            var context = new BlockStructureContext(document, cancellationToken);
            foreach (var provider in _providers)
            {
                provider.ProvideBlockStructure(context);
            }

            return new BlockStructure(context.Spans);
        }
Beispiel #8
0
        private void ProvideBlockStructureWorker(
            BlockStructureContext context, SyntaxNode syntaxRoot)
        {
            var spans = ArrayBuilder <BlockSpan> .GetInstance();

            BlockSpanCollector.CollectBlockSpans(
                context.Document, syntaxRoot, _nodeProviderMap, _triviaProviderMap, spans, context.CancellationToken);

            UpdateAndAddSpans(context, spans);

            spans.Free();
        }
Beispiel #9
0
        public override async Task <BlockStructure> GetBlockStructureAsync(
            Document document, CancellationToken cancellationToken)
        {
            var context = new BlockStructureContext(document, cancellationToken);

            foreach (var provider in _providers)
            {
                await provider.ProvideBlockStructureAsync(context).ConfigureAwait(false);
            }

            return(CreateBlockStructure(document, context));
        }
 /// <summary>
 /// Keep in sync with <see cref="ProvideBlockStructureAsync"/>
 /// </summary>
 public override void ProvideBlockStructure(BlockStructureContext context)
 {
     try
     {
         var syntaxRoot = context.Document.GetSyntaxRootSynchronously(context.CancellationToken);
         ProvideBlockStructureWorker(context, syntaxRoot);
     }
     catch (Exception e) when (FatalError.ReportUnlessCanceled(e))
     {
         throw ExceptionUtilities.Unreachable;
     }
 }
Beispiel #11
0
        public override BlockStructure GetBlockStructure(
            Document document, CancellationToken cancellationToken)
        {
            var context = new BlockStructureContext(document, cancellationToken);

            foreach (var provider in _providers)
            {
                provider.ProvideBlockStructure(context);
            }

            return(CreateBlockStructure(document, context));
        }
        private void ProvideBlockStructureWorker(
            BlockStructureContext context, SyntaxNode syntaxRoot)
        {
            using var spans = TemporaryArray <BlockSpan> .Empty;
            BlockSpanCollector.CollectBlockSpans(
                syntaxRoot, context.OptionProvider, _nodeProviderMap, _triviaProviderMap, ref spans.AsRef(), context.CancellationToken);

            foreach (var span in spans)
            {
                context.AddBlockSpan(span);
            }
        }
 /// <summary>
 /// Keep in sync with <see cref="ProvideBlockStructureAsync"/>
 /// </summary>
 public override void ProvideBlockStructure(BlockStructureContext context)
 {
     try
     {
         var syntaxRoot = context.Document.GetSyntaxRootSynchronously(context.CancellationToken);
         ProvideBlockStructureWorker(context, syntaxRoot);
     }
     catch (Exception e) when(FatalError.ReportUnlessCanceled(e))
     {
         throw ExceptionUtilities.Unreachable;
     }
 }
        private void ProvideBlockStructureWorker(
            BlockStructureContext context, SyntaxNode syntaxRoot)
        {
            var spans = ImmutableArray.CreateBuilder<BlockSpan>();
            BlockSpanCollector.CollectBlockSpans(
                context.Document, syntaxRoot, _nodeProviderMap, _triviaProviderMap, spans, context.CancellationToken);

            foreach (var region in spans)
            {
                context.AddBlockSpan(region);
            }
        }
 /// <summary>
 /// Keep in sync with <see cref="ProvideBlockStructure"/>
 /// </summary>
 public override async Task ProvideBlockStructureAsync(BlockStructureContext context)
 {
     try
     {
         var syntaxRoot = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false);
         ProvideBlockStructureWorker(context, syntaxRoot);
     }
     catch (Exception e) when (FatalError.ReportUnlessCanceled(e))
     {
         throw ExceptionUtilities.Unreachable;
     }
 }
Beispiel #16
0
        private void ProvideBlockStructureWorker(
            BlockStructureContext context, SyntaxNode syntaxRoot)
        {
            using var _ = ArrayBuilder <BlockSpan> .GetInstance(out var spans);

            BlockSpanCollector.CollectBlockSpans(
                syntaxRoot, context.OptionProvider, _nodeProviderMap, _triviaProviderMap, spans, context.CancellationToken);

            foreach (var span in spans)
            {
                context.AddBlockSpan(span);
            }
        }
        /// <summary>
        /// Keep in sync with <see cref="ProvideBlockStructure"/>
        /// </summary>
        public override async Task ProvideBlockStructureAsync(BlockStructureContext context)
        {
            try
            {
                var syntaxRoot = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false);

                ProvideBlockStructureWorker(context, syntaxRoot);
            }
            catch (Exception e) when(FatalError.ReportUnlessCanceled(e))
            {
                throw ExceptionUtilities.Unreachable;
            }
        }
Beispiel #18
0
        public override void ProvideBlockStructure(BlockStructureContext context)
        {
            try
            {
                var syntaxRoot = context.SyntaxTree.GetRoot(context.CancellationToken);

                ProvideBlockStructureWorker(context, syntaxRoot);
            }
            catch (Exception e) when(FatalError.ReportAndPropagateUnlessCanceled(e))
            {
                throw ExceptionUtilities.Unreachable;
            }
        }
        private void ProvideBlockStructureWorker(
            BlockStructureContext context, SyntaxNode syntaxRoot)
        {
            var spans = ImmutableArray.CreateBuilder <BlockSpan>();

            BlockSpanCollector.CollectBlockSpans(
                context.Document, syntaxRoot, _nodeProviderMap, _triviaProviderMap, spans, context.CancellationToken);

            foreach (var region in spans)
            {
                context.AddBlockSpan(region);
            }
        }
        public override void ProvideBlockStructure(BlockStructureContext context)
        {
            try
            {
                var syntaxRoot = context.SyntaxTree.GetRoot(context.CancellationToken);
                using var spans = TemporaryArray <BlockSpan> .Empty;
                BlockSpanCollector.CollectBlockSpans(
                    syntaxRoot, context.Options, _nodeProviderMap, _triviaProviderMap, ref spans.AsRef(), context.CancellationToken);

                foreach (var span in spans)
                {
                    context.AddBlockSpan(span);
                }
            }
            catch (Exception e) when(FatalError.ReportAndPropagateUnlessCanceled(e))
            {
                throw ExceptionUtilities.Unreachable;
            }
        }
        internal static void UpdateAndAddSpans(BlockStructureContext context, ArrayBuilder<BlockSpan> spans)
        {
            var options = context.Document.Project.Solution.Workspace.Options;
            var language = context.Document.Project.Language;

            var showIndentGuidesForCodeLevelConstructs = options.GetOption(BlockStructureOptions.ShowBlockStructureGuidesForCodeLevelConstructs, language);
            var showIndentGuidesForDeclarationLevelConstructs = options.GetOption(BlockStructureOptions.ShowBlockStructureGuidesForDeclarationLevelConstructs, language);
            var showIndentGuidesForCommentsAndPreprocessorRegions = options.GetOption(BlockStructureOptions.ShowBlockStructureGuidesForCommentsAndPreprocessorRegions, language);
            var showOutliningForCodeLevelConstructs = options.GetOption(BlockStructureOptions.ShowOutliningForCodeLevelConstructs, language);
            var showOutliningForDeclarationLevelConstructs = options.GetOption(BlockStructureOptions.ShowOutliningForDeclarationLevelConstructs, language);
            var showOutliningForCommentsAndPreprocessorRegions = options.GetOption(BlockStructureOptions.ShowOutliningForCommentsAndPreprocessorRegions, language);

            foreach (var span in spans)
            {
                var updatedSpan = UpdateBlockSpan(span,
                        showIndentGuidesForCodeLevelConstructs,
                        showIndentGuidesForDeclarationLevelConstructs,
                        showIndentGuidesForCommentsAndPreprocessorRegions,
                        showOutliningForCodeLevelConstructs,
                        showOutliningForDeclarationLevelConstructs,
                        showOutliningForCommentsAndPreprocessorRegions);
                context.AddBlockSpan(updatedSpan);
            }
        }
Beispiel #22
0
        internal static void UpdateAndAddSpans(BlockStructureContext context, ArrayBuilder <BlockSpan> spans)
        {
            var options  = context.Document.Project.Solution.Workspace.Options;
            var language = context.Document.Project.Language;

            var showIndentGuidesForCodeLevelConstructs            = options.GetOption(BlockStructureOptions.ShowBlockStructureGuidesForCodeLevelConstructs, language);
            var showIndentGuidesForDeclarationLevelConstructs     = options.GetOption(BlockStructureOptions.ShowBlockStructureGuidesForDeclarationLevelConstructs, language);
            var showIndentGuidesForCommentsAndPreprocessorRegions = options.GetOption(BlockStructureOptions.ShowBlockStructureGuidesForCommentsAndPreprocessorRegions, language);
            var showOutliningForCodeLevelConstructs            = options.GetOption(BlockStructureOptions.ShowOutliningForCodeLevelConstructs, language);
            var showOutliningForDeclarationLevelConstructs     = options.GetOption(BlockStructureOptions.ShowOutliningForDeclarationLevelConstructs, language);
            var showOutliningForCommentsAndPreprocessorRegions = options.GetOption(BlockStructureOptions.ShowOutliningForCommentsAndPreprocessorRegions, language);

            foreach (var span in spans)
            {
                var updatedSpan = UpdateBlockSpan(span,
                                                  showIndentGuidesForCodeLevelConstructs,
                                                  showIndentGuidesForDeclarationLevelConstructs,
                                                  showIndentGuidesForCommentsAndPreprocessorRegions,
                                                  showOutliningForCodeLevelConstructs,
                                                  showOutliningForDeclarationLevelConstructs,
                                                  showOutliningForCommentsAndPreprocessorRegions);
                context.AddBlockSpan(updatedSpan);
            }
        }
 public virtual void ProvideBlockStructure(BlockStructureContext context)
 {
     ProvideBlockStructureAsync(context).Wait(context.CancellationToken);
 }
Beispiel #24
0
 public virtual void ProvideBlockStructure(BlockStructureContext context)
 => ProvideBlockStructureAsync(context).Wait(context.CancellationToken);
Beispiel #25
0
 public abstract Task ProvideBlockStructureAsync(BlockStructureContext context);
 public BlockStructure GetBlockStructure(BlockStructureContext context)
 => GetBlockStructure(context, _providers);
 public abstract Task ProvideBlockStructureAsync(BlockStructureContext context);
 public async Task <BlockStructure> GetBlockStructureAsync(BlockStructureContext context)
 => await GetBlockStructureAsync(context, _providers).ConfigureAwait(false);