IsInArguments() public méthode

Tells if scope is opening inside function or indexer arguments and hence user indentation of curly braces must be respected.
public IsInArguments ( ) : bool
Résultat bool
Exemple #1
0
        private void CloseFormattingScope()
        {
            Debug.Assert(_tokens.CurrentToken.TokenType == RTokenType.CloseCurlyBrace);

            // if it is not single line scope like { } add linke break before }
            if (!SingleLineScope)
            {
                _tb.SoftLineBreak();
            }

            var leadingSpace = SingleLineScope && _tokens.PreviousToken.TokenType != RTokenType.CloseCurlyBrace;

            // Close formatting scope and remember if it was based on the user-supplied indent.
            _formattingScopes.TryCloseScope(_tokens.Position);

            // Closing curly indentation is defined by the line that either holds the opening curly brace
            // or the line that holds keyword that defines the expression that the curly belongs to.
            // Examples:
            //
            //      x <-
            //          function(a) {
            //          }
            //
            //      x <- function(a) {
            //      }
            //
            if (!SingleLineScope)
            {
                int lineIndentSize = _braceHandler.GetCloseCurlyBraceIndentSize(_tokens.CurrentToken, _tb, _options);
                if (lineIndentSize > 0)
                {
                    var indentString = IndentBuilder.GetIndentString(lineIndentSize, _options.IndentType, _options.TabSize);
                    _tb.AppendPreformattedText(indentString);
                    leadingSpace = false;
                }
                else
                {
                    _tb.SoftIndent();
                }
            }

            AppendToken(leadingSpace: leadingSpace, trailingSpace: false);

            bool singleLineScopeJustClosed = false;

            if (_tokens.CurrentToken.Start >= _singleLineScopeEnd)
            {
                _singleLineScopeEnd       = -1;
                singleLineScopeJustClosed = true;
            }

            if (_formattingScopes.SuppressLineBreakCount == 0 && !_tokens.IsEndOfStream())
            {
                // We insert line break after } unless
                //  a) Next token is comma (scope is in the argument list) or
                //  b) Next token is a closing brace (last parameter in a function or indexer) or
                //  c) Next token is by 'else' (so 'else' does not get separated from 'if') or
                //  d) We are in a single-line scope sequence like if() {{ }}
                if (!KeepCurlyAndElseTogether())
                {
                    if (singleLineScopeJustClosed &&
                        !IsClosingToken(_tokens.CurrentToken) &&
                        !_braceHandler.IsInArguments())
                    {
                        SoftLineBreak();
                    }
                }
            }
        }