本文整理汇总了C#中SyntaxToken.IsPlusOrMinusExpression方法的典型用法代码示例。如果您正苦于以下问题:C# SyntaxToken.IsPlusOrMinusExpression方法的具体用法?C# SyntaxToken.IsPlusOrMinusExpression怎么用?C# SyntaxToken.IsPlusOrMinusExpression使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SyntaxToken
的用法示例。
在下文中一共展示了SyntaxToken.IsPlusOrMinusExpression方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetAdjustSpacesOperation
//.........这里部分代码省略.........
return CreateAdjustSpacesOperation(0, AdjustSpacesOption.ForceSpacesIfOnSingleLine);
}
}
// generic name * < or * >
if ((currentToken.Kind() == SyntaxKind.LessThanToken || currentToken.Kind() == SyntaxKind.GreaterThanToken) &&
(currentToken.Parent.Kind() == SyntaxKind.TypeArgumentList || currentToken.Parent.Kind() == SyntaxKind.TypeParameterList))
{
return CreateAdjustSpacesOperation(0, AdjustSpacesOption.ForceSpacesIfOnSingleLine);
}
// ++ * or -- *
if ((previousToken.Kind() == SyntaxKind.PlusPlusToken || previousToken.Kind() == SyntaxKind.MinusMinusToken) &&
previousToken.Parent is PrefixUnaryExpressionSyntax)
{
return CreateAdjustSpacesOperation(0, AdjustSpacesOption.ForceSpacesIfOnSingleLine);
}
// * ++ or * --
if ((currentToken.Kind() == SyntaxKind.PlusPlusToken || currentToken.Kind() == SyntaxKind.MinusMinusToken) &&
currentToken.Parent is PostfixUnaryExpressionSyntax)
{
return CreateAdjustSpacesOperation(0, AdjustSpacesOption.ForceSpacesIfOnSingleLine);
}
// For spacing between the identifier and the conditional operator
if (currentToken.IsKind(SyntaxKind.QuestionToken) && currentToken.Parent.Kind() == SyntaxKind.ConditionalAccessExpression)
{
return CreateAdjustSpacesOperation(0, AdjustSpacesOption.ForceSpacesIfOnSingleLine);
}
// ( * or ) * or [ * or ] * or . * or -> *
switch (previousToken.Kind())
{
case SyntaxKind.OpenParenToken:
case SyntaxKind.OpenBracketToken:
case SyntaxKind.DotToken:
case SyntaxKind.MinusGreaterThanToken:
return CreateAdjustSpacesOperation(0, AdjustSpacesOption.ForceSpacesIfOnSingleLine);
case SyntaxKind.CloseParenToken:
case SyntaxKind.CloseBracketToken:
int space = (previousToken.Kind() == currentToken.Kind()) ? 0 : 1;
return CreateAdjustSpacesOperation(space, AdjustSpacesOption.ForceSpacesIfOnSingleLine);
}
// +1 or -1
if (previousToken.IsPlusOrMinusExpression() && !currentToken.IsPlusOrMinusExpression())
{
return CreateAdjustSpacesOperation(0, AdjustSpacesOption.ForceSpacesIfOnSingleLine);
}
// +- or -+
if (previousToken.IsPlusOrMinusExpression() && currentToken.IsPlusOrMinusExpression() &&
previousToken.Kind() != currentToken.Kind())
{
return CreateAdjustSpacesOperation(0, AdjustSpacesOption.ForceSpacesIfOnSingleLine);
}
// ! *
if (previousToken.Kind() == SyntaxKind.ExclamationToken)
{
return CreateAdjustSpacesOperation(0, AdjustSpacesOption.ForceSpacesIfOnSingleLine);
}
// nullable
if (currentToken.Kind() == SyntaxKind.QuestionToken &&
currentToken.Parent.Kind() == SyntaxKind.NullableType)
{
return CreateAdjustSpacesOperation(0, AdjustSpacesOption.ForceSpacesIfOnSingleLine);
}
// pointer case
if ((currentToken.Kind() == SyntaxKind.AsteriskToken && currentToken.Parent is PointerTypeSyntax) ||
(previousToken.Kind() == SyntaxKind.AsteriskToken && previousToken.Parent is PrefixUnaryExpressionSyntax))
{
return CreateAdjustSpacesOperation(0, AdjustSpacesOption.ForceSpacesIfOnSingleLine);
}
// ~ * case
if (previousToken.Kind() == SyntaxKind.TildeToken && (previousToken.Parent is PrefixUnaryExpressionSyntax || previousToken.Parent is DestructorDeclarationSyntax))
{
return CreateAdjustSpacesOperation(0, AdjustSpacesOption.ForceSpacesIfOnSingleLine);
}
// & * case
if (previousToken.Kind() == SyntaxKind.AmpersandToken &&
previousToken.Parent is PrefixUnaryExpressionSyntax)
{
return CreateAdjustSpacesOperation(0, AdjustSpacesOption.ForceSpacesIfOnSingleLine);
}
// * :: or :: * case
if (previousToken.Kind() == SyntaxKind.ColonColonToken || currentToken.Kind() == SyntaxKind.ColonColonToken)
{
return CreateAdjustSpacesOperation(0, AdjustSpacesOption.ForceSpacesIfOnSingleLine);
}
return nextOperation.Invoke();
}