예제 #1
0
        protected override void CollectBlockSpans(
            SyntaxToken previousToken,
            AnonymousMethodExpressionSyntax anonymousMethod,
            ref TemporaryArray <BlockSpan> spans,
            BlockStructureOptionProvider optionProvider,
            CancellationToken cancellationToken)
        {
            // fault tolerance
            if (anonymousMethod.Block.IsMissing ||
                anonymousMethod.Block.OpenBraceToken.IsMissing ||
                anonymousMethod.Block.CloseBraceToken.IsMissing)
            {
                return;
            }

            var lastToken = CSharpStructureHelpers.GetLastInlineMethodBlockToken(anonymousMethod);

            if (lastToken.Kind() == SyntaxKind.None)
            {
                return;
            }

            var startToken = anonymousMethod.ParameterList != null
                ? anonymousMethod.ParameterList.GetLastToken(includeZeroWidth : true)
                : anonymousMethod.DelegateKeyword;

            spans.AddIfNotNull(CSharpStructureHelpers.CreateBlockSpan(
                                   anonymousMethod,
                                   startToken,
                                   lastToken,
                                   compressEmptyLines: false,
                                   autoCollapse: false,
                                   type: BlockTypes.Expression,
                                   isCollapsible: true));
        }
예제 #2
0
        protected override void CollectBlockSpans(
            SimpleLambdaExpressionSyntax lambdaExpression,
            ImmutableArray <BlockSpan> .Builder spans,
            CancellationToken cancellationToken)
        {
            // fault tolerance
            if (lambdaExpression.Body.IsMissing)
            {
                return;
            }

            var lambdaBlock = lambdaExpression.Body as BlockSyntax;

            if (lambdaBlock == null ||
                lambdaBlock.OpenBraceToken.IsMissing ||
                lambdaBlock.CloseBraceToken.IsMissing)
            {
                return;
            }

            var lastToken = CSharpStructureHelpers.GetLastInlineMethodBlockToken(lambdaExpression);

            if (lastToken.Kind() == SyntaxKind.None)
            {
                return;
            }

            spans.Add(CSharpStructureHelpers.CreateBlockSpan(
                          lambdaExpression,
                          lambdaExpression.ArrowToken,
                          lastToken,
                          autoCollapse: false,
                          type: BlockTypes.AnonymousMethod,
                          isCollapsible: true));
        }
예제 #3
0
        protected override void CollectBlockSpans(
            ParenthesizedLambdaExpressionSyntax lambdaExpression,
            ref TemporaryArray <BlockSpan> spans,
            BlockStructureOptionProvider optionProvider,
            CancellationToken cancellationToken)
        {
            // fault tolerance
            if (lambdaExpression.Body.IsMissing)
            {
                return;
            }

            if (!(lambdaExpression.Body is BlockSyntax lambdaBlock) ||
                lambdaBlock.OpenBraceToken.IsMissing ||
                lambdaBlock.CloseBraceToken.IsMissing)
            {
                return;
            }

            var lastToken = CSharpStructureHelpers.GetLastInlineMethodBlockToken(lambdaExpression);

            if (lastToken.Kind() == SyntaxKind.None)
            {
                return;
            }

            spans.AddIfNotNull(CSharpStructureHelpers.CreateBlockSpan(
                                   lambdaExpression,
                                   lambdaExpression.ArrowToken,
                                   lastToken,
                                   compressEmptyLines: false,
                                   autoCollapse: false,
                                   type: BlockTypes.Expression,
                                   isCollapsible: true));
        }
        protected override void CollectBlockSpans(
            SimpleLambdaExpressionSyntax lambdaExpression,
            ArrayBuilder <BlockSpan> spans,
            OptionSet options,
            CancellationToken cancellationToken)
        {
            // fault tolerance
            if (lambdaExpression.Body.IsMissing)
            {
                return;
            }

            if (!(lambdaExpression.Body is BlockSyntax lambdaBlock) ||
                lambdaBlock.OpenBraceToken.IsMissing ||
                lambdaBlock.CloseBraceToken.IsMissing)
            {
                return;
            }

            var lastToken = CSharpStructureHelpers.GetLastInlineMethodBlockToken(lambdaExpression);

            if (lastToken.Kind() == SyntaxKind.None)
            {
                return;
            }

            spans.AddIfNotNull(CSharpStructureHelpers.CreateBlockSpan(
                                   lambdaExpression,
                                   lambdaExpression.ArrowToken,
                                   lastToken,
                                   autoCollapse: false,
                                   type: BlockTypes.Expression,
                                   isCollapsible: true));
        }
예제 #5
0
        protected override void CollectBlockSpans(
            AnonymousMethodExpressionSyntax anonymousMethod,
            ArrayBuilder <BlockSpan> spans,
            CancellationToken cancellationToken)
        {
            // fault tolerance
            if (anonymousMethod.Block.IsMissing ||
                anonymousMethod.Block.OpenBraceToken.IsMissing ||
                anonymousMethod.Block.CloseBraceToken.IsMissing)
            {
                return;
            }

            var lastToken = CSharpStructureHelpers.GetLastInlineMethodBlockToken(anonymousMethod);

            if (lastToken.Kind() == SyntaxKind.None)
            {
                return;
            }

            var startToken = anonymousMethod.ParameterList != null
                ? anonymousMethod.ParameterList.GetLastToken(includeZeroWidth : true)
                : anonymousMethod.DelegateKeyword;

            spans.Add(CSharpStructureHelpers.CreateBlockSpan(
                          anonymousMethod,
                          startToken,
                          lastToken,
                          autoCollapse: false,
                          type: BlockTypes.AnonymousMethod,
                          isCollapsible: true));
        }