public override void AddIndentBlockOperations(List <IndentBlockOperation> list, SyntaxNode node, OptionSet optionSet, NextAction <IndentBlockOperation> nextOperation)
        {
            nextOperation.Invoke(list);

            var queryExpression = node as QueryExpressionSyntax;

            if (queryExpression != null)
            {
                var firstToken = queryExpression.FromClause.Expression.GetFirstToken(includeZeroWidth: true);
                var lastToken  = queryExpression.FromClause.Expression.GetLastToken(includeZeroWidth: true);
                AddIndentBlockOperation(list, queryExpression.FromClause.FromKeyword, firstToken, lastToken);

                for (int i = 0; i < queryExpression.Body.Clauses.Count; i++)
                {
                    // if it is nested query expression
                    var fromClause = queryExpression.Body.Clauses[i] as FromClauseSyntax;
                    if (fromClause != null)
                    {
                        firstToken = fromClause.Expression.GetFirstToken(includeZeroWidth: true);
                        lastToken  = fromClause.Expression.GetLastToken(includeZeroWidth: true);
                        AddIndentBlockOperation(list, fromClause.FromKeyword, firstToken, lastToken);
                    }
                }

                // set alignment line for query expression
                var baseToken = queryExpression.GetFirstToken(includeZeroWidth: true);
                var endToken  = queryExpression.GetLastToken(includeZeroWidth: true);
                if (!baseToken.IsMissing && !baseToken.Equals(endToken))
                {
                    var startToken = baseToken.GetNextToken(includeZeroWidth: true);
                    SetAlignmentBlockOperation(list, baseToken, startToken, endToken);
                }
            }
        }
Exemple #2
0
            public override void AddIndentBlockOperations(List <IndentBlockOperation> list, SyntaxNode node, OptionSet optionSet, NextAction <IndentBlockOperation> nextOperation)
            {
                // these nodes should be from syntax tree from ITextSnapshot.
                Contract.Requires(node.SyntaxTree != null);
                Contract.Requires(node.SyntaxTree.GetText() != null);

                nextOperation.Invoke(list);

                ReplaceCaseIndentationRules(list, node);

                if (node is BaseParameterListSyntax ||
                    node is TypeArgumentListSyntax ||
                    node is TypeParameterListSyntax ||
                    node.IsKind(SyntaxKind.Interpolation))
                {
                    AddIndentBlockOperations(list, node);
                    return;
                }

                var argument = node as BaseArgumentListSyntax;

                if (argument != null &&
                    argument.Parent.Kind() != SyntaxKind.ThisConstructorInitializer &&
                    !IsBracketedArgumentListMissingBrackets(argument as BracketedArgumentListSyntax))
                {
                    AddIndentBlockOperations(list, argument);
                    return;
                }

                // only valid if the user has started to actually type a constructor initializer
                var constructorInitializer = node as ConstructorInitializerSyntax;

                if (constructorInitializer != null &&
                    constructorInitializer.ArgumentList.OpenParenToken.Kind() != SyntaxKind.None &&
                    !constructorInitializer.ThisOrBaseKeyword.IsMissing)
                {
                    var text = node.SyntaxTree.GetText();

                    // 3 different cases
                    // first case : this or base is the first token on line
                    // second case : colon is the first token on line
                    var colonIsFirstTokenOnLine      = !constructorInitializer.ColonToken.IsMissing && constructorInitializer.ColonToken.IsFirstTokenOnLine(text);
                    var thisOrBaseIsFirstTokenOnLine = !constructorInitializer.ThisOrBaseKeyword.IsMissing && constructorInitializer.ThisOrBaseKeyword.IsFirstTokenOnLine(text);

                    if (colonIsFirstTokenOnLine || thisOrBaseIsFirstTokenOnLine)
                    {
                        list.Add(FormattingOperations.CreateRelativeIndentBlockOperation(
                                     constructorInitializer.ThisOrBaseKeyword,
                                     constructorInitializer.ArgumentList.OpenParenToken.GetNextToken(includeZeroWidth: true),
                                     constructorInitializer.ArgumentList.CloseParenToken.GetPreviousToken(includeZeroWidth: true),
                                     indentationDelta: 1,
                                     option: IndentBlockOption.RelativePosition));
                    }
                    else
                    {
                        // third case : none of them are the first token on the line
                        AddIndentBlockOperations(list, constructorInitializer.ArgumentList);
                    }
                }
            }
Exemple #3
0
        public UseCaseHandler <M> FromResult <M>(NextAction <M> action, UseCaseHandler <M> callbackHandler)
        {
            M   result      = default;
            var nextHandler = new UseCaseHandler <M>();

            nextHandler.ExecutingTask = ExecutingTask?.ContinueWith(t =>
            {
                callbackHandler.OnStart?.Invoke();

                try
                {
                    result = action.Invoke(Result);

                    callbackHandler.OnComplete?.Invoke(result);
                }
                catch (Exception e)
                {
                    callbackHandler.OnError?.Invoke(e);
                }

                nextHandler.Result = result;
            });

            return(nextHandler);
        }
        public override void AddIndentBlockOperations(List <IndentBlockOperation> list, SyntaxNode node, OptionSet optionSet, NextAction <IndentBlockOperation> nextOperation)
        {
            nextOperation.Invoke(list);

            if (node is QueryExpressionSyntax queryExpression)
            {
                AddIndentBlockOperationsForFromClause(list, queryExpression.FromClause);

                foreach (var queryClause in queryExpression.Body.Clauses)
                {
                    // if it is nested query expression
                    if (queryClause is FromClauseSyntax fromClause)
                    {
                        AddIndentBlockOperationsForFromClause(list, fromClause);
                    }
                }

                // set alignment line for query expression
                var baseToken = queryExpression.GetFirstToken(includeZeroWidth: true);
                var endToken  = queryExpression.GetLastToken(includeZeroWidth: true);
                if (!baseToken.IsMissing && !baseToken.Equals(endToken))
                {
                    var startToken = baseToken.GetNextToken(includeZeroWidth: true);
                    SetAlignmentBlockOperation(list, baseToken, startToken, endToken);
                }
            }
        }
Exemple #5
0
    private static IEnumerator AnimationCoroutine(SpriteRenderer spriteRenderer, float durationSec, Sprite[] sprites, bool playOnce, NextAction nextAction)
    {
        if (spriteRenderer != null && sprites != null && sprites.Length > 0)
        {
            int curSprite = 0;
            do
            {
                spriteRenderer.sprite = sprites[curSprite];

                curSprite++;
                if (curSprite == sprites.Length)
                {
                    if (playOnce)
                    {
                        break;
                    }

                    curSprite = 0;
                }

                yield return(new WaitForSeconds(durationSec / sprites.Length));
            } while (true);
        }

        nextAction?.Invoke();
    }
        public override void AddAnchorIndentationOperations(List <AnchorIndentationOperation> list, SyntaxNode node, OptionSet optionSet, NextAction <AnchorIndentationOperation> nextOperation)
        {
            nextOperation.Invoke(list);

            var queryClause = node as QueryClauseSyntax;

            if (queryClause != null)
            {
                var firstToken = queryClause.GetFirstToken(includeZeroWidth: true);
                AddAnchorIndentationOperation(list, firstToken, queryClause.GetLastToken(includeZeroWidth: true));
            }

            var selectOrGroupClause = node as SelectOrGroupClauseSyntax;

            if (selectOrGroupClause != null)
            {
                var firstToken = selectOrGroupClause.GetFirstToken(includeZeroWidth: true);
                AddAnchorIndentationOperation(list, firstToken, selectOrGroupClause.GetLastToken(includeZeroWidth: true));
            }

            var continuation = node as QueryContinuationSyntax;

            if (continuation != null)
            {
                AddAnchorIndentationOperation(list, continuation.IntoKeyword, continuation.GetLastToken(includeZeroWidth: true));
            }
        }
        public override void AddIndentBlockOperations(List<IndentBlockOperation> list, SyntaxNode node, OptionSet optionSet, NextAction<IndentBlockOperation> nextOperation)
        {
            nextOperation.Invoke(list);

            var queryExpression = node as QueryExpressionSyntax;
            if (queryExpression != null)
            {
                var firstToken = queryExpression.FromClause.Expression.GetFirstToken(includeZeroWidth: true);
                var lastToken = queryExpression.FromClause.Expression.GetLastToken(includeZeroWidth: true);
                AddIndentBlockOperation(list, queryExpression.FromClause.FromKeyword, firstToken, lastToken);

                for (int i = 0; i < queryExpression.Body.Clauses.Count; i++)
                {
                    // if it is nested query expression
                    var fromClause = queryExpression.Body.Clauses[i] as FromClauseSyntax;
                    if (fromClause != null)
                    {
                        firstToken = fromClause.Expression.GetFirstToken(includeZeroWidth: true);
                        lastToken = fromClause.Expression.GetLastToken(includeZeroWidth: true);
                        AddIndentBlockOperation(list, fromClause.FromKeyword, firstToken, lastToken);
                    }
                }

                // set alignment line for query expression
                var baseToken = queryExpression.GetFirstToken(includeZeroWidth: true);
                var endToken = queryExpression.GetLastToken(includeZeroWidth: true);
                if (!baseToken.IsMissing && !baseToken.Equals(endToken))
                {
                    var startToken = baseToken.GetNextToken(includeZeroWidth: true);
                    SetAlignmentBlockOperation(list, baseToken, startToken, endToken);
                }
            }
        }
Exemple #8
0
 public void ConcludeMinigame()
 {
     if (countdown != null)
     {
         StopCoroutine(countdown);
     }
     conclusion.Invoke();
 }
Exemple #9
0
            public override void AddAnchorIndentationOperations(List <AnchorIndentationOperation> list, SyntaxNode node, OptionSet optionSet, NextAction <AnchorIndentationOperation> nextOperation)
            {
                if (node.IsKind(SyntaxKind.SimpleLambdaExpression) || node.IsKind(SyntaxKind.ParenthesizedLambdaExpression) || node.IsKind(SyntaxKind.AnonymousMethodExpression))
                {
                    return;
                }

                nextOperation.Invoke(list);
            }
        public override void AddIndentBlockOperations(List<IndentBlockOperation> list, SyntaxNode node, OptionSet optionSet, NextAction<IndentBlockOperation> nextOperation)
        {
            nextOperation.Invoke(list);

            if (s_allowableKinds.Contains(node.Kind()))
            {
                AddChangeSignatureIndentOperation(list, node);
            }
        }
        public override void AddSuppressOperations(List <SuppressOperation> list, SyntaxNode node, OptionSet optionSet, NextAction <SuppressOperation> nextOperation)
        {
            nextOperation.Invoke(list);

            if (node is QueryExpressionSyntax queryExpression)
            {
                AddSuppressWrappingIfOnSingleLineOperation(list, queryExpression.GetFirstToken(includeZeroWidth: true), queryExpression.GetLastToken(includeZeroWidth: true));
            }
        }
Exemple #12
0
        public override void AddIndentBlockOperations(List <IndentBlockOperation> list, SyntaxNode node, OptionSet optionSet, NextAction <IndentBlockOperation> nextOperation)
        {
            nextOperation.Invoke(list);

            if (s_allowableKinds.Contains(node.Kind()))
            {
                AddChangeSignatureIndentOperation(list, node);
            }
        }
            public override void AddAnchorIndentationOperations(List<AnchorIndentationOperation> list, SyntaxNode node, OptionSet optionSet, NextAction<AnchorIndentationOperation> nextOperation)
            {
                if (node.IsKind(SyntaxKind.SimpleLambdaExpression) || node.IsKind(SyntaxKind.ParenthesizedLambdaExpression) || node.IsKind(SyntaxKind.AnonymousMethodExpression))
                {
                    return;
                }

                nextOperation.Invoke(list);
            }
        public override void AddSuppressOperations(List<SuppressOperation> list, SyntaxNode node, SyntaxToken lastToken, OptionSet optionSet, NextAction<SuppressOperation> nextOperation)
        {
            nextOperation.Invoke(list);

            var queryExpression = node as QueryExpressionSyntax;
            if (queryExpression != null)
            {
                AddSuppressWrappingIfOnSingleLineOperation(list, queryExpression.GetFirstToken(includeZeroWidth: true), queryExpression.GetLastToken(includeZeroWidth: true));
            }
        }
        public override void AddSuppressOperations(List<SuppressOperation> list, SyntaxNode node, SyntaxToken lastToken, OptionSet optionSet, NextAction<SuppressOperation> nextOperation)
        {
            nextOperation.Invoke(list);

            AddInitializerSuppressOperations(list, node);

            AddBraceSuppressOperations(list, node, lastToken);

            AddStatementExceptBlockSuppressOperations(list, node);

            AddSpecificNodesSuppressOperations(list, node);
        }
Exemple #16
0
        public override void AddSuppressOperations(List <SuppressOperation> list, SyntaxNode node, SyntaxToken lastToken, OptionSet optionSet, NextAction <SuppressOperation> nextOperation)
        {
            nextOperation.Invoke(list);

            AddInitializerSuppressOperations(list, node);

            AddBraceSuppressOperations(list, node, lastToken);

            AddStatementExceptBlockSuppressOperations(list, node);

            AddSpecificNodesSuppressOperations(list, node);
        }
        static void Main(string[] args)
        {
            string line = null;

            while (line != "exit")
            {
                NextAction?.Invoke(line);
                NextAction = null;
                UpdateUI();
                Console.WriteLine();
                line = Console.ReadLine();
            }
        }
        public override void AddSuppressOperations(List<SuppressOperation> list, SyntaxNode node, OptionSet optionSet, NextAction<SuppressOperation> nextOperation)
        {
            nextOperation.Invoke(list);

            if (!node.ContainsAnnotations)
            {
                return;
            }

            AddPropertyDeclarationSuppressOperations(list, node);

            AddInitializerSuppressOperations(list, node);
        }
        public override void AddSuppressOperations(List <SuppressOperation> list, SyntaxNode node, OptionSet optionSet, NextAction <SuppressOperation> nextOperation)
        {
            nextOperation.Invoke(list);

            if (!node.ContainsAnnotations)
            {
                return;
            }

            AddPropertyDeclarationSuppressOperations(list, node);

            AddInitializerSuppressOperations(list, node);
        }
        public override void AddIndentBlockOperations(List<IndentBlockOperation> list, SyntaxNode node, OptionSet optionSet, NextAction<IndentBlockOperation> nextOperation)
        {
            nextOperation.Invoke(list);

            AddBlockIndentationOperation(list, node, optionSet);

            AddLabelIndentationOperation(list, node, optionSet);

            AddSwitchIndentationOperation(list, node, optionSet);

            AddEmbeddedStatementsIndentationOperation(list, node);

            AddTypeParameterConstraintClauseOperation(list, node);
        }
        public override void AddIndentBlockOperations(List <IndentBlockOperation> list, SyntaxNode node, OptionSet optionSet, NextAction <IndentBlockOperation> nextOperation)
        {
            nextOperation.Invoke(list);

            AddBlockIndentationOperation(list, node, optionSet);

            AddLabelIndentationOperation(list, node, optionSet);

            AddSwitchIndentationOperation(list, node, optionSet);

            AddEmbeddedStatementsIndentationOperation(list, node);

            AddTypeParameterContraintClauseOperation(list, node);
        }
Exemple #22
0
        public Popup(float contentWidth, float contentHeight) : base()
        {
            _y            = -Height;
            ContentHeight = contentHeight;

            _popupWidth        = contentWidth;
            _headerHeight      = HeaderHeightRatio * Height;
            _footerHeight      = FooterHeightRatio * Height;
            _radius            = Height / 25;
            _popupX            = (Width - _popupWidth) / 2;
            _popupY            = (Height - (_headerHeight + _footerHeight + ContentHeight)) / 2;
            _secondButtonX     = _popupX + _popupWidth * ButtonWidthRatio;
            _secondButtonWidth = _popupWidth * (1 - ButtonWidthRatio);
            _popupHeight       = _headerHeight + ContentHeight + _footerHeight;


            _titleBlock = new TextBlock(_popupX + _popupWidth / 2, _popupY + _headerHeight / 2, Title, _headerHeight / 2, new SKColor(255, 255, 255));
            AddChild(_titleBlock);

            var leftButton = new PopupLeftButton(_popupX, _popupY + _headerHeight + ContentHeight,
                                                 _popupWidth * ButtonWidthRatio, _footerHeight, _popupWidth, _popupHeight, _radius);

            _rightButton = new PopupRightButton(_secondButtonX, _popupY + _headerHeight + ContentHeight, _secondButtonWidth, _footerHeight, _popupWidth, _popupHeight, _radius, ActionName);

            Title      = "Popup title";
            ActionName = "Action";

            AddChild(leftButton);
            AddChild(_rightButton);

            _container = new CenteredContainer(_popupX, _popupY + _headerHeight, contentHeight, contentWidth);
            AddChild(_container);

            leftButton.Activated += () =>
            {
                HideLeft();
                BackAction?.Invoke();
            };

            _rightButton.Activated += () =>
            {
                HideRight();
                NextAction?.Invoke();
            };

            DeclareTappable(this);
        }
        public override void AddIndentBlockOperations(List<IndentBlockOperation> list, SyntaxNode node, OptionSet optionSet, NextAction<IndentBlockOperation> nextOperation)
        {
            nextOperation.Invoke(list);

            var bracePair = node.GetBracePair();

            // don't put block indentation operation if the block only contains lambda expression body block
            if (node.IsLambdaBodyBlock() || !bracePair.IsValidBracePair())
            {
                return;
            }

            if (optionSet.GetOption(CSharpFormattingOptions.OpenCloseBracesIndent))
            {
                AddIndentBlockOperation(list, bracePair.Item1, bracePair.Item1, bracePair.Item1.Span);
                AddIndentBlockOperation(list, bracePair.Item2, bracePair.Item2, bracePair.Item2.Span);
            }
        }
Exemple #24
0
        public override void AddAlignTokensOperations(List <AlignTokensOperation> list, SyntaxNode node, OptionSet optionSet, NextAction <AlignTokensOperation> nextOperation)
        {
            nextOperation.Invoke(list);
            var syntaxNode = node;

            var bracePair = node.GetBracePair();

            if (!bracePair.IsValidBracePair())
            {
                return;
            }

            if (syntaxNode.IsLambdaBodyBlock() ||
                node is InitializerExpressionSyntax)
            {
                AddAlignIndentationOfTokensToFirstTokenOfBaseTokenLineOperation(list, syntaxNode, bracePair.Item1, SpecializedCollections.SingletonEnumerable((SyntaxToken)bracePair.Item2));
            }
        }
Exemple #25
0
        public override void AddIndentBlockOperations(List <IndentBlockOperation> list, SyntaxNode node, OptionSet optionSet, NextAction <IndentBlockOperation> nextOperation)
        {
            nextOperation.Invoke(list);

            var bracePair = node.GetBracePair();

            // don't put block indentation operation if the block only contains lambda expression body block
            if (node.IsLambdaBodyBlock() || !bracePair.IsValidBracePair())
            {
                return;
            }

            if (optionSet.GetOption(CSharpFormattingOptions.IndentBraces))
            {
                AddIndentBlockOperation(list, bracePair.Item1, bracePair.Item1, bracePair.Item1.Span);
                AddIndentBlockOperation(list, bracePair.Item2, bracePair.Item2, bracePair.Item2.Span);
            }
        }
        public override void AddAlignTokensOperations(List<AlignTokensOperation> list, SyntaxNode node, OptionSet optionSet, NextAction<AlignTokensOperation> nextOperation)
        {
            nextOperation.Invoke(list);
            var syntaxNode = node;

            var bracePair = node.GetBracePair();

            if (!bracePair.IsValidBracePair())
            {
                return;
            }

            if (syntaxNode.IsLambdaBodyBlock() ||
                node is InitializerExpressionSyntax)
            {
                AddAlignIndentationOfTokensToFirstTokenOfBaseTokenLineOperation(list, syntaxNode, bracePair.Item1, SpecializedCollections.SingletonEnumerable((SyntaxToken)bracePair.Item2));
            }
        }
        public override void AddSuppressOperations(List <SuppressOperation> list, SyntaxNode node, OptionSet optionSet, NextAction <SuppressOperation> nextOperation)
        {
            nextOperation.Invoke(list);

            AddBraceSuppressOperations(list, node);

            AddStatementExceptBlockSuppressOperations(list, node);

            AddSpecificNodesSuppressOperations(list, node);

            if (!optionSet.GetOption(CSharpFormattingOptions.WrappingPreserveSingleLine))
            {
                RemoveSuppressOperationForBlock(list, node);
            }

            if (!optionSet.GetOption(CSharpFormattingOptions.WrappingKeepStatementsOnSingleLine))
            {
                RemoveSuppressOperationForStatementMethodDeclaration(list, node);
            }
        }
        public override void AddSuppressOperations(List<SuppressOperation> list, SyntaxNode node, OptionSet optionSet, NextAction<SuppressOperation> nextOperation)
        {
            nextOperation.Invoke(list);

            AddBraceSuppressOperations(list, node);

            AddStatementExceptBlockSuppressOperations(list, node);

            AddSpecificNodesSuppressOperations(list, node);

            if (!optionSet.GetOption(CSharpFormattingOptions.WrappingPreserveSingleLine))
            {
                RemoveSuppressOperationForBlock(list, node);
            }

            if (!optionSet.GetOption(CSharpFormattingOptions.WrappingKeepStatementsOnSingleLine))
            {
                RemoveSuppressOperationForStatementMethodDeclaration(list, node);
            }
        }
                /// <summary>
                /// Align all the wrapped parts of the expression with the token after 'return'.
                /// That way we get:
                ///
                /// return a == obj.a &amp;&amp;
                ///        b == obj.b &amp;&amp;
                ///        ...
                /// </summary>
                public override void AddIndentBlockOperations(
                    List <IndentBlockOperation> list, SyntaxNode node, OptionSet optionSet, NextAction <IndentBlockOperation> nextOperation)
                {
                    if (_syntaxFacts.IsReturnStatement(node))
                    {
                        var expr = _syntaxFacts.GetExpressionOfReturnStatement(node);
                        if (expr?.ChildNodesAndTokens().Count > 1)
                        {
                            list.Add(FormattingOperations.CreateRelativeIndentBlockOperation(
                                         expr.GetFirstToken(),
                                         expr.GetFirstToken().GetNextToken(),
                                         node.GetLastToken(),
                                         indentationDelta: 0,
                                         option: IndentBlockOption.RelativePosition));

                            return;
                        }
                    }

                    nextOperation.Invoke(list);
                }
        public override void AddAnchorIndentationOperations(List <AnchorIndentationOperation> list, SyntaxNode node, OptionSet optionSet, NextAction <AnchorIndentationOperation> nextOperation)
        {
            nextOperation.Invoke(list);
            switch (node)
            {
            case QueryClauseSyntax queryClause:
            {
                var firstToken = queryClause.GetFirstToken(includeZeroWidth: true);
                AddAnchorIndentationOperation(list, firstToken, queryClause.GetLastToken(includeZeroWidth: true));
                return;
            }

            case SelectOrGroupClauseSyntax selectOrGroupClause:
            {
                var firstToken = selectOrGroupClause.GetFirstToken(includeZeroWidth: true);
                AddAnchorIndentationOperation(list, firstToken, selectOrGroupClause.GetLastToken(includeZeroWidth: true));
                return;
            }

            case QueryContinuationSyntax continuation:
                AddAnchorIndentationOperation(list, continuation.IntoKeyword, continuation.GetLastToken(includeZeroWidth: true));
                return;
            }
        }
Exemple #31
0
        public override void AddIndentBlockOperations(
            List <IndentBlockOperation> list, SyntaxNode node, OptionSet optionSet, NextAction <IndentBlockOperation> nextOperation)
        {
            if (node.HasAnnotation(SpecializedFormattingAnnotation) &&
                node is ConditionalExpressionSyntax conditional)
            {
                var statement = conditional.FirstAncestorOrSelf <StatementSyntax>();
                if (statement != null)
                {
                    var baseToken = statement.GetFirstToken();

                    // we want to indent the ? and : in one level from the containing statement.
                    list.Add(FormattingOperations.CreateRelativeIndentBlockOperation(
                                 baseToken, conditional.QuestionToken, conditional.WhenTrue.GetLastToken(),
                                 indentationDelta: 1, IndentBlockOption.RelativeToFirstTokenOnBaseTokenLine));
                    list.Add(FormattingOperations.CreateRelativeIndentBlockOperation(
                                 baseToken, conditional.ColonToken, conditional.WhenFalse.GetLastToken(),
                                 indentationDelta: 1, IndentBlockOption.RelativeToFirstTokenOnBaseTokenLine));
                    return;
                }
            }

            nextOperation.Invoke(list);
        }
        public override void AddAnchorIndentationOperations(List<AnchorIndentationOperation> list, SyntaxNode node, OptionSet optionSet, NextAction<AnchorIndentationOperation> nextOperation)
        {
            nextOperation.Invoke(list);

            var queryClause = node as QueryClauseSyntax;
            if (queryClause != null)
            {
                var firstToken = queryClause.GetFirstToken(includeZeroWidth: true);
                AddAnchorIndentationOperation(list, firstToken, queryClause.GetLastToken(includeZeroWidth: true));
            }

            var selectOrGroupClause = node as SelectOrGroupClauseSyntax;
            if (selectOrGroupClause != null)
            {
                var firstToken = selectOrGroupClause.GetFirstToken(includeZeroWidth: true);
                AddAnchorIndentationOperation(list, firstToken, selectOrGroupClause.GetLastToken(includeZeroWidth: true));
            }

            var continuation = node as QueryContinuationSyntax;
            if (continuation != null)
            {
                AddAnchorIndentationOperation(list, continuation.IntoKeyword, continuation.GetLastToken(includeZeroWidth: true));
            }
        }
        public override void AddAnchorIndentationOperations(List <AnchorIndentationOperation> list, SyntaxNode node, OptionSet optionSet, NextAction <AnchorIndentationOperation> nextOperation)
        {
            nextOperation.Invoke(list);

            var block = node as BlockSyntax;

            if (block != null && block.Parent is BlockSyntax)
            {
                // if it is not nested block, then its anchor will be first token that this block is
                // associated with. otherwise, "{" of block is the anchor token its children would follow
                var startToken = block.GetFirstToken(includeZeroWidth: true);
                var lastToken  = block.GetLastToken(includeZeroWidth: true);

                AddAnchorIndentationOperation(list, startToken, lastToken);
                return;
            }

            var statement = node as StatementSyntax;

            if (statement != null)
            {
                var startToken = statement.GetFirstToken(includeZeroWidth: true);
                var lastToken  = statement.GetLastToken(includeZeroWidth: true);

                AddAnchorIndentationOperation(list, startToken, lastToken);
                return;
            }

            var usingNode = node as UsingDirectiveSyntax;

            if (usingNode != null)
            {
                var startToken = usingNode.GetFirstToken(includeZeroWidth: true);
                var lastToken  = usingNode.GetLastToken(includeZeroWidth: true);
                AddAnchorIndentationOperation(list, startToken, lastToken);
                return;
            }

            var namespaceNode = node as PackageDeclarationSyntax;

            if (namespaceNode != null)
            {
                var startToken = namespaceNode.GetFirstToken(includeZeroWidth: true);
                var lastToken  = namespaceNode.GetLastToken(includeZeroWidth: true);
                AddAnchorIndentationOperation(list, startToken, lastToken);
                return;
            }

            var typeNode = node as TypeDeclarationSyntax;

            if (typeNode != null)
            {
                var startToken = typeNode.GetFirstToken(includeZeroWidth: true);
                var lastToken  = typeNode.GetLastToken(includeZeroWidth: true);
                AddAnchorIndentationOperation(list, startToken, lastToken);
                return;
            }

            var memberDeclNode = node as MemberDeclarationSyntax;

            if (memberDeclNode != null)
            {
                var startToken = memberDeclNode.GetFirstToken(includeZeroWidth: true);
                var lastToken  = memberDeclNode.GetLastToken(includeZeroWidth: true);
                AddAnchorIndentationOperation(list, startToken, lastToken);
                return;
            }

            var accessorDeclNode = node as AccessorDeclarationSyntax;

            if (accessorDeclNode != null)
            {
                var startToken = accessorDeclNode.GetFirstToken(includeZeroWidth: true);
                var lastToken  = accessorDeclNode.GetLastToken(includeZeroWidth: true);
                AddAnchorIndentationOperation(list, startToken, lastToken);
                return;
            }
        }
            public override void AddIndentBlockOperations(List<IndentBlockOperation> list, SyntaxNode node, OptionSet optionSet, NextAction<IndentBlockOperation> nextOperation)
            {
                // these nodes should be from syntax tree from ITextSnapshot.
                Contract.Requires(node.SyntaxTree != null);
                Contract.Requires(node.SyntaxTree.GetText() != null);

                nextOperation.Invoke(list);

                ReplaceCaseIndentationRules(list, node);

                if (node is BaseParameterListSyntax ||
                    node is TypeArgumentListSyntax ||
                    node is TypeParameterListSyntax ||
                    node.IsKind(SyntaxKind.Interpolation))
                {
                    AddIndentBlockOperations(list, node);
                    return;
                }

                var argument = node as BaseArgumentListSyntax;
                if (argument != null && argument.Parent.Kind() != SyntaxKind.ThisConstructorInitializer)
                {
                    AddIndentBlockOperations(list, argument);
                    return;
                }

                var constructorInitializer = node as ConstructorInitializerSyntax;
                if (constructorInitializer != null && constructorInitializer.ArgumentList.OpenParenToken.Kind() != SyntaxKind.None)
                {
                    var text = node.SyntaxTree.GetText();

                    // 3 different cases
                    // first case : this or base is the first token on line
                    // second case : colon is the first token on line
                    var colonIsFirstTokenOnLine = !constructorInitializer.ColonToken.IsMissing && constructorInitializer.ColonToken.IsFirstTokenOnLine(text);
                    var thisOrBaseIsFirstTokenOnLine = !constructorInitializer.ThisOrBaseKeyword.IsMissing && constructorInitializer.ThisOrBaseKeyword.IsFirstTokenOnLine(text);

                    if (colonIsFirstTokenOnLine || thisOrBaseIsFirstTokenOnLine)
                    {
                        list.Add(FormattingOperations.CreateRelativeIndentBlockOperation(
                            constructorInitializer.ThisOrBaseKeyword,
                            constructorInitializer.ArgumentList.OpenParenToken.GetNextToken(includeZeroWidth: true),
                            constructorInitializer.ArgumentList.CloseParenToken.GetPreviousToken(includeZeroWidth: true),
                            indentationDelta: 1,
                            option: IndentBlockOption.RelativePosition));
                    }
                    else
                    {
                        // third case : none of them are the first token on the line
                        AddIndentBlockOperations(list, constructorInitializer.ArgumentList);
                    }
                }
            }
        public override void AddSuppressOperations(List<SuppressOperation> list, SyntaxNode node, OptionSet optionSet, NextAction<SuppressOperation> nextOperation)
        {
            nextOperation.Invoke(list);

            SuppressVariableDeclaration(list, node, optionSet);
        }
Exemple #36
0
 public void AddSuppressOperations(List<SuppressOperation> list, SyntaxNode node, OptionSet optionSet, NextAction<SuppressOperation> nextOperation)
 {
     nextOperation.Invoke(list);
 }
Exemple #37
0
        public Observable <T> FromCallable(NextAction action)
        {
            var result = action.Invoke(_result);

            return(new Observable <T>(result));
        }
        public override void AddAnchorIndentationOperations(List<AnchorIndentationOperation> list, SyntaxNode node, OptionSet optionSet, NextAction<AnchorIndentationOperation> nextOperation)
        {
            nextOperation.Invoke(list);

            if (node.IsKind(SyntaxKind.SimpleLambdaExpression) || node.IsKind(SyntaxKind.ParenthesizedLambdaExpression))
            {
                AddAnchorIndentationOperation(list, node);
                return;
            }

            if (node.IsKind(SyntaxKind.AnonymousMethodExpression))
            {
                AddAnchorIndentationOperation(list, node);
                return;
            }

            var block = node as BlockSyntax;
            if (block != null)
            {
                // if it is not nested block, then its anchor will be first token that this block is
                // associated with. otherwise, "{" of block is the anchor token its children would follow
                if (block.Parent == null || block.Parent is BlockSyntax)
                {
                    AddAnchorIndentationOperation(list, block);
                    return;
                }
                else
                {
                    AddAnchorIndentationOperation(list,
                        block.Parent.GetFirstToken(includeZeroWidth: true),
                        block.GetLastToken(includeZeroWidth: true));
                    return;
                }
            }

            var statement = node as StatementSyntax;
            if (statement != null)
            {
                AddAnchorIndentationOperation(list, statement);
                return;
            }

            var usingNode = node as UsingDirectiveSyntax;
            if (usingNode != null)
            {
                AddAnchorIndentationOperation(list, usingNode);
                return;
            }

            var namespaceNode = node as NamespaceDeclarationSyntax;
            if (namespaceNode != null)
            {
                AddAnchorIndentationOperation(list, namespaceNode);
                return;
            }

            var typeNode = node as TypeDeclarationSyntax;
            if (typeNode != null)
            {
                AddAnchorIndentationOperation(list, typeNode);
                return;
            }

            var memberDeclNode = node as MemberDeclarationSyntax;
            if (memberDeclNode != null)
            {
                AddAnchorIndentationOperation(list, memberDeclNode);
                return;
            }

            var accessorDeclNode = node as AccessorDeclarationSyntax;
            if (accessorDeclNode != null)
            {
                AddAnchorIndentationOperation(list, accessorDeclNode);
                return;
            }
        }
Exemple #39
0
 public void AddAnchorIndentationOperations(List<AnchorIndentationOperation> list, SyntaxNode node, OptionSet optionSet, NextAction<AnchorIndentationOperation> nextOperation)
 {
     nextOperation.Invoke(list);
 }
Exemple #40
0
        public override void AddIndentBlockOperations(List <IndentBlockOperation> list, SyntaxNode node, OptionSet optionSet, NextAction <IndentBlockOperation> nextOperation)
        {
            nextOperation.Invoke(list);

            AddAndRemoveBlockIndentationOperation(list, node, optionSet);
        }
Exemple #41
0
 public void AddSuppressOperations(List <SuppressOperation> list, SyntaxNode node, SyntaxToken lastToken, OptionSet optionSet, NextAction <SuppressOperation> nextOperation)
 {
     nextOperation.Invoke(list);
 }
Exemple #42
0
 public void AddAnchorIndentationOperations(List <AnchorIndentationOperation> list, SyntaxNode node, OptionSet optionSet, NextAction <AnchorIndentationOperation> nextOperation)
 {
     nextOperation.Invoke(list);
 }
Exemple #43
0
 public void AddIndentBlockOperations(List <IndentBlockOperation> list, SyntaxNode node, OptionSet optionSet, NextAction <IndentBlockOperation> nextOperation)
 {
     nextOperation.Invoke(list);
 }
Exemple #44
0
 public void AddAlignTokensOperations(List <AlignTokensOperation> list, SyntaxNode node, OptionSet optionSet, NextAction <AlignTokensOperation> nextOperation)
 {
     nextOperation.Invoke(list);
 }
        public override void AddAnchorIndentationOperations(List<AnchorIndentationOperation> list, SyntaxNode node, OptionSet optionSet, NextAction<AnchorIndentationOperation> nextOperation)
        {
            nextOperation.Invoke(list);

            var block = node as BlockSyntax;
            if (block != null && block.Parent is BlockSyntax)
            {
                // if it is not nested block, then its anchor will be first token that this block is
                // associated with. otherwise, "{" of block is the anchor token its children would follow
                var startToken = block.GetFirstToken(includeZeroWidth: true);
                var lastToken = block.GetLastToken(includeZeroWidth: true);

                AddAnchorIndentationOperation(list, startToken, lastToken);
                return;
            }

            var statement = node as StatementSyntax;
            if (statement != null)
            {
                var startToken = statement.GetFirstToken(includeZeroWidth: true);
                var lastToken = statement.GetLastToken(includeZeroWidth: true);

                AddAnchorIndentationOperation(list, startToken, lastToken);
                return;
            }

            var usingNode = node as UsingDirectiveSyntax;
            if (usingNode != null)
            {
                var startToken = usingNode.GetFirstToken(includeZeroWidth: true);
                var lastToken = usingNode.GetLastToken(includeZeroWidth: true);
                AddAnchorIndentationOperation(list, startToken, lastToken);
                return;
            }

            var namespaceNode = node as NamespaceDeclarationSyntax;
            if (namespaceNode != null)
            {
                var startToken = namespaceNode.GetFirstToken(includeZeroWidth: true);
                var lastToken = namespaceNode.GetLastToken(includeZeroWidth: true);
                AddAnchorIndentationOperation(list, startToken, lastToken);
                return;
            }

            var typeNode = node as TypeDeclarationSyntax;
            if (typeNode != null)
            {
                var startToken = typeNode.GetFirstToken(includeZeroWidth: true);
                var lastToken = typeNode.GetLastToken(includeZeroWidth: true);
                AddAnchorIndentationOperation(list, startToken, lastToken);
                return;
            }

            var memberDeclNode = node as MemberDeclarationSyntax;
            if (memberDeclNode != null)
            {
                var startToken = memberDeclNode.GetFirstToken(includeZeroWidth: true);
                var lastToken = memberDeclNode.GetLastToken(includeZeroWidth: true);
                AddAnchorIndentationOperation(list, startToken, lastToken);
                return;
            }

            var accessorDeclNode = node as AccessorDeclarationSyntax;
            if (accessorDeclNode != null)
            {
                var startToken = accessorDeclNode.GetFirstToken(includeZeroWidth: true);
                var lastToken = accessorDeclNode.GetLastToken(includeZeroWidth: true);
                AddAnchorIndentationOperation(list, startToken, lastToken);
                return;
            }
        }
Exemple #46
0
        public override void AddSuppressOperations(List <SuppressOperation> list, SyntaxNode node, SyntaxToken lastToken, OptionSet optionSet, NextAction <SuppressOperation> nextOperation)
        {
            nextOperation.Invoke(list);

            SuppressVariableDeclaration(list, node, optionSet);
        }
Exemple #47
0
 public void AddIndentBlockOperations(List<IndentBlockOperation> list, SyntaxNode node, OptionSet optionSet, NextAction<IndentBlockOperation> nextOperation)
 {
     nextOperation.Invoke(list);
 }
Exemple #48
0
 public void AddAlignTokensOperations(List<AlignTokensOperation> list, SyntaxNode node, OptionSet optionSet, NextAction<AlignTokensOperation> nextOperation)
 {
     nextOperation.Invoke(list);
 }
Exemple #49
0
 public void ShowNext()
 {
     NextAction?.Invoke();
 }