Dispose() public méthode

public Dispose ( ) : void
Résultat void
Exemple #1
0
 public void TryCloseScope(int tokenIndex)
 {
     if (_formattingScopes.Count > 1)
     {
         if (_formattingScopes.Peek().CloseCurlyBraceTokenIndex == tokenIndex)
         {
             FormattingScope scope = _formattingScopes.Pop();
             scope.Dispose();
         }
     }
 }
Exemple #2
0
        private void CloseFormattingScope()
        {
            Debug.Assert(_tokens.CurrentToken.TokenType == RTokenType.CloseCurlyBrace);

            if (!SingleLineScope)
            {
                _tb.SoftLineBreak();
                _tb.CloseIndentLevel();
                _tb.SoftIndent();
            }

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

            if (_formattingScopes.Count > 1)
            {
                if (_formattingScopes.Peek().CloseBracePosition == _tokens.Position)
                {
                    FormattingScope scope = _formattingScopes.Pop();
                    scope.Dispose();
                }
            }

            AppendToken(leadingSpace: leadingSpace, trailingSpace: false);

            bool singleLineScopeJustClosed = false;

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

            if (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) &&
                        !IsInArguments())
                    {
                        SoftLineBreak();
                    }
                }
            }
        }