private static bool IsNearExpressionBlockRightBoundary([NotNull] CSharpFmtStageContext ctx) { if (!(ctx.LeftChild is ICommentNode comment)) { return(false); } return(comment.GetText() == T4CSharpCodeBehindIntermediateConverter.ExpressionCommentEndText); }
public SpaceType?Provide(CSharpFmtStageContext ctx) { if (!IsApplicable(ctx)) { return(null); } return(Type); }
protected override bool IsApplicable(CSharpFmtStageContext ctx) { var leftExpressionBlock = ctx.LeftChild.GetT4ContainerFromCSharpNode <IT4ExpressionBlock>(); var rightExpressionBlock = ctx.RightChild.GetT4ContainerFromCSharpNode <IT4ExpressionBlock>(); if (leftExpressionBlock == null || rightExpressionBlock == null) { return(false); } return(leftExpressionBlock == rightExpressionBlock); }
public override SpaceType GetBlockSpaceType(CSharpFmtStageContext context) { ITreeNode leftChild = context.LeftChild; if (leftChild is ICommentNode && leftChild.GetText() == T4CSharpCodeGenerator.CodeCommentStart && !leftChild.HasLineFeedsTo(context.RightChild)) return context.Parent is IClassBody ? SpaceType.Vertical : SpaceType.Horizontal; if (context.RightChild is ICommentNode && context.RightChild.GetText() == T4CSharpCodeGenerator.CodeCommentEnd) return context.Parent is IClassBody || leftChild.HasLineFeedsTo(context.RightChild) ? SpaceType.Vertical : SpaceType.Horizontal; return SpaceType.Default; }
private bool IsInBlockLeftBound([NotNull] CSharpFmtStageContext ctx) { if (!(ctx.RightChild is ICommentNode comment)) { return(false); } if (comment.GetText() != EndComment) { return(false); } var leftExpressionBlock = ctx.LeftChild.GetLastTokenIn().GetT4ContainerFromCSharpNode <TBlock>(); if (leftExpressionBlock == null) { return(false); } return(true); }
public override SpaceType GetBlockSpaceType(CSharpFmtStageContext context) { ITreeNode leftChild = context.LeftChild; if (leftChild is ICommentNode && leftChild.GetText() == T4CSharpCodeGenerator.CodeCommentStart && !leftChild.HasLineFeedsTo(context.RightChild)) { return(context.Parent is IClassBody ? SpaceType.Vertical : SpaceType.Horizontal); } if (context.RightChild is ICommentNode && context.RightChild.GetText() == T4CSharpCodeGenerator.CodeCommentEnd) { return(context.Parent is IClassBody || leftChild.HasLineFeedsTo(context.RightChild) ? SpaceType.Vertical : SpaceType.Horizontal); } return(SpaceType.Default); }
protected abstract bool IsApplicable([NotNull] CSharpFmtStageContext ctx);
protected override bool IsApplicable(CSharpFmtStageContext ctx) => IsNearExpressionBlockLeftBoundary(ctx) || IsNearExpressionBlockRightBoundary(ctx);
protected override bool IsApplicable(CSharpFmtStageContext ctx) => IsInBlockLeftBound(ctx) || IsInBlockRightBound(ctx);