예제 #1
0
            public bool Apply(AdjustNewLinesOperation operation, int pairIndex, CancellationToken cancellationToken)
            {
                if (operation.Option == AdjustNewLinesOption.PreserveLines)
                {
                    return(ApplyPreserveLinesOperation(operation, pairIndex, cancellationToken));
                }
                else if (operation.Option == AdjustNewLinesOption.ForceLines)
                {
                    return(ApplyForceLinesOperation(operation, pairIndex, cancellationToken));
                }
                else
                {
                    Debug.Assert(operation.Option == AdjustNewLinesOption.ForceLinesIfOnSingleLine);

                    // We force the tokens to the different line only they are on the same line
                    // else we leave the tokens as it is (Note: We should not preserve too. If we
                    // we do, then that will be counted as a line operation and the indentation of
                    // the second token will be modified)
                    if (_tokenStream.TwoTokensOnSameLine(_tokenStream.GetToken(pairIndex),
                                                         _tokenStream.GetToken(pairIndex + 1)))
                    {
                        return(ApplyForceLinesOperation(operation, pairIndex, cancellationToken));
                    }
                    else
                    {
                        return(false);
                    }
                }
            }