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);
            }
        }
        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);
            }
        }
        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);
            }
        }
示例#4
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);
            }
        }
示例#5
0
        private void ProvideBlockStructureWorker(
            BlockStructureContext context, SyntaxNode syntaxRoot)
        {
            var spans = ArrayBuilder <BlockSpan> .GetInstance();

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

            foreach (var span in spans)
            {
                context.AddBlockSpan(span);
            }

            spans.Free();
        }
        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;
            }
        }
示例#7
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);
            }
        }
        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);
            }
        }