Exemplo n.º 1
0
            public override AdjustNewLinesOperation GetAdjustNewLinesOperation(SyntaxToken previousToken, SyntaxToken currentToken, OptionSet optionSet, NextOperation <AdjustNewLinesOperation> nextOperation)
            {
                // for extract method case, for a hybrid case, don't force rule, but preserve user style
                var operation = base.GetAdjustNewLinesOperation(previousToken, currentToken, optionSet, nextOperation);

                if (operation == null)
                {
                    return(null);
                }

                if (operation.Option == AdjustNewLinesOption.ForceLinesIfOnSingleLine)
                {
                    return(FormattingOperations.CreateAdjustNewLinesOperation(operation.Line, AdjustNewLinesOption.PreserveLines));
                }

                if (operation.Option != AdjustNewLinesOption.ForceLines)
                {
                    return(operation);
                }

                if (previousToken.RawKind == (int)SyntaxKind.OpenBraceToken)
                {
                    return(operation);
                }

                if (previousToken.BetweenFieldAndNonFieldMember(currentToken))
                {
                    // make sure to have at least 2 line breaks between field and other members except field
                    return(FormattingOperations.CreateAdjustNewLinesOperation(2, AdjustNewLinesOption.PreserveLines));
                }

                if (previousToken.HasHybridTriviaBetween(currentToken))
                {
                    return(FormattingOperations.CreateAdjustNewLinesOperation(operation.Line, AdjustNewLinesOption.PreserveLines));
                }

                return(operation);
            }
            public override AdjustNewLinesOperation GetAdjustNewLinesOperation(SyntaxToken previousToken, SyntaxToken currentToken, OptionSet optionSet, NextOperation<AdjustNewLinesOperation> nextOperation)
            {
                // for extract method case, for a hybrid case, don't force rule, but preserve user style
                var operation = base.GetAdjustNewLinesOperation(previousToken, currentToken, optionSet, nextOperation);
                if (operation == null)
                {
                    return null;
                }

                if (operation.Option == AdjustNewLinesOption.ForceLinesIfOnSingleLine)
                {
                    return FormattingOperations.CreateAdjustNewLinesOperation(operation.Line, AdjustNewLinesOption.PreserveLines);
                }

                if (operation.Option != AdjustNewLinesOption.ForceLines)
                {
                    return operation;
                }

                if (previousToken.RawKind == (int)SyntaxKind.OpenBraceToken)
                {
                    return operation;
                }

                if (previousToken.BetweenFieldAndNonFieldMember(currentToken))
                {
                    // make sure to have at least 2 line breaks between field and other members except field
                    return FormattingOperations.CreateAdjustNewLinesOperation(2, AdjustNewLinesOption.PreserveLines);
                }

                if (previousToken.HasHybridTriviaBetween(currentToken))
                {
                    return FormattingOperations.CreateAdjustNewLinesOperation(operation.Line, AdjustNewLinesOption.PreserveLines);
                }

                return operation;
            }