Exemplo n.º 1
0
 public int GetCurrentColumn(TokenData tokenData)
 {
     return(GetColumn(tokenData, _getTriviaData));
 }
Exemplo n.º 2
0
 public int GetCurrentColumn(TokenData tokenData)
 => GetColumn(tokenData, _getTriviaData);
Exemplo n.º 3
0
            private bool ApplyBaseTokenIndentationChangesFromTo(
                TokenData baseToken,
                TokenData startToken,
                TokenData endToken,
                Dictionary <SyntaxToken, int> previousChangesMap,
                CancellationToken cancellationToken
                )
            {
                // if baseToken is not in the stream, then it is guaranteed to be not moved.
                var tokenWithIndex = baseToken;

                if (tokenWithIndex.IndexInStream < 0)
                {
                    return(false);
                }

                // now, check whether tokens on that the base token depends have been moved.
                // any token before the base token on the same line has implicit dependency over the base token.
                while (tokenWithIndex.IndexInStream >= 0)
                {
                    // check whether given token have moved
                    if (previousChangesMap.ContainsKey(tokenWithIndex.Token))
                    {
                        break;
                    }

                    // okay, this token is not moved, check one before me as long as it is on the same line
                    var tokenPairIndex = tokenWithIndex.IndexInStream - 1;
                    if (
                        tokenPairIndex < 0 ||
                        _context.TokenStream.GetTriviaData(
                            tokenPairIndex
                            ).SecondTokenIsFirstTokenOnLine
                        )
                    {
                        return(false);
                    }

                    tokenWithIndex = tokenWithIndex.GetPreviousTokenData();
                }

                // didn't find anything moved
                if (tokenWithIndex.IndexInStream < 0)
                {
                    return(false);
                }

                // we are not moved
                var indentationDelta = _context.GetDeltaFromPreviousChangesMap(
                    tokenWithIndex.Token,
                    previousChangesMap
                    );

                if (indentationDelta == 0)
                {
                    return(false);
                }

                startToken =
                    startToken.IndexInStream < 0
                        ? _context.TokenStream.FirstTokenInStream
                        : startToken;
                endToken =
                    endToken.IndexInStream < 0 ? _context.TokenStream.LastTokenInStream : endToken;

                ApplyIndentationDeltaFromTo(
                    startToken,
                    endToken,
                    indentationDelta,
                    previousChangesMap,
                    cancellationToken
                    );
                return(true);
            }