Ejemplo n.º 1
0
            private void ApplyIndentationDelta(
                int pairIndex,
                SyntaxToken currentToken,
                int indentationDelta,
                TriviaData triviaInfo,
                Dictionary <SyntaxToken, int> previousChangesMap,
                CancellationToken cancellationToken)
            {
                Contract.ThrowIfFalse(triviaInfo.SecondTokenIsFirstTokenOnLine);

                var indentation = triviaInfo.Spaces + indentationDelta;

                if (triviaInfo.Spaces == indentation)
                {
                    // indentation didn't actually move. nothing to change
                    return;
                }

                // record the fact that this pair has been moved
                Debug.Assert(!previousChangesMap.ContainsKey(currentToken));
                previousChangesMap.Add(currentToken, triviaInfo.Spaces);

                // okay, update indentation
                _tokenStream.ApplyChange(pairIndex, triviaInfo.WithIndentation(indentation, _context, _formattingRules, cancellationToken));
            }
Ejemplo n.º 2
0
            private void ApplyIndentationToGivenPosition(
                TokenData previousToken,
                TokenData currentToken,
                TriviaData triviaInfo,
                int baseSpaceOrIndentation,
                Dictionary <SyntaxToken, int> previousChangesMap,
                CancellationToken cancellationToken)
            {
                // add or replace existing value. this could happen if a token get moved multiple times
                // due to one being involved in multiple alignment operations
                previousChangesMap[currentToken.Token] = triviaInfo.Spaces;

                if (previousToken.IndexInStream < 0 || triviaInfo.Spaces == baseSpaceOrIndentation)
                {
                    return;
                }

                // before make any change, check whether spacing is allowed
                var spanBetweenTokens = TextSpan.FromBounds(previousToken.Token.Span.End, currentToken.Token.SpanStart);

                if (_context.IsSpacingSuppressed(spanBetweenTokens))
                {
                    return;
                }

                // okay, update indentation
                _tokenStream.ApplyChange(
                    previousToken.IndexInStream,
                    triviaInfo.WithIndentation(baseSpaceOrIndentation, _context, _formattingRules, cancellationToken));
            }
            private void ApplyIndentationDelta(
                int pairIndex,
                SyntaxToken currentToken,
                int indentationDelta,
                TriviaData triviaInfo,
                Dictionary<SyntaxToken, int> previousChangesMap,
                CancellationToken cancellationToken)
            {
                Contract.ThrowIfFalse(triviaInfo.SecondTokenIsFirstTokenOnLine);

                var indentation = triviaInfo.Spaces + indentationDelta;

                if (triviaInfo.Spaces == indentation)
                {
                    // indentation didn't actually move. nothing to change
                    return;
                }

                // record the fact that this pair has been moved
                Debug.Assert(!previousChangesMap.ContainsKey(currentToken));
                previousChangesMap.Add(currentToken, triviaInfo.Spaces);

                // okay, update indentation
                this.tokenStream.ApplyChange(pairIndex, triviaInfo.WithIndentation(indentation, context, formattingRules, cancellationToken));
            }
            private void ApplyIndentationToGivenPosition(
                TokenData previousToken,
                TokenData currentToken,
                TriviaData triviaInfo,
                int baseSpaceOrIndentation,
                Dictionary<SyntaxToken, int> previousChangesMap,
                CancellationToken cancellationToken)
            {
                // add or replace existing value. this could happen if a token get moved multiple times
                // due to one being involved in multiple alignment operations
                previousChangesMap[currentToken.Token] = triviaInfo.Spaces;

                if (previousToken.IndexInStream < 0 || triviaInfo.Spaces == baseSpaceOrIndentation)
                {
                    return;
                }

                // before make any change, check whether spacing is allowed
                var spanBetweenTokens = TextSpan.FromBounds(previousToken.Token.Span.End, currentToken.Token.SpanStart);
                if (this.context.IsSpacingSuppressed(spanBetweenTokens))
                {
                    return;
                }

                // okay, update indentation
                this.tokenStream.ApplyChange(
                    previousToken.IndexInStream,
                    triviaInfo.WithIndentation(baseSpaceOrIndentation, context, formattingRules, cancellationToken));
            }