public void SyntaxFacts_Token_SwapBinaryExpressionTokenKind_Throws() { var invalidOperators = GetAllKinds().Where(k => !SyntaxFacts.CanSwapBinaryExpressionTokenKind(k)); foreach (var tokenKind in invalidOperators) { Assert.Throws <InvalidOperationException>(() => SyntaxFacts.SwapBinaryExpressionTokenKind(tokenKind)); } }
protected override IEnumerable <ICodeAction> GetRefactorings(SemanticModel semanticModel, int position, BinaryExpressionSyntax node) { var operatorToken = node.OperatorToken; var canSwap = operatorToken.Span.ContainsOrTouches(position) && SyntaxFacts.CanSwapBinaryExpressionTokenKind(operatorToken.Kind); return(canSwap ? new[] { new FlipBinaryOperatorSidesCodeAction(node) } : Enumerable.Empty <ICodeAction>()); }
public static IEnumerable <object[]> GetBinaryOperatorTokensThatCannotBeSwapped() { return(SyntaxFacts.GetBinaryExpressionTokenKinds() .Where(k => !SyntaxFacts.CanSwapBinaryExpressionTokenKind(k)) .Select(k => new object[] { k })); }