Example #1
0
 internal override void AppendCodeString(StringBuilder res, PythonAst ast, CodeFormattingOptions format)
 {
     SliceStart?.AppendCodeString(res, ast, format);
     if (!this.IsIncompleteNode(ast))
     {
         format.Append(res, format.SpaceBeforeSliceColon, " ", string.Empty, this.GetPreceedingWhiteSpaceDefaultNull(ast) ?? "");
         res.Append(':');
         if (SliceStop != null)
         {
             string ws = null;
             if (format.SpaceAfterSliceColon.HasValue)
             {
                 ws = string.Empty;
                 format.Append(res, format.SpaceAfterSliceColon, " ", string.Empty, string.Empty);
             }
             SliceStop.AppendCodeString(res, ast, format, ws);
         }
         if (StepProvided)
         {
             format.Append(res, format.SpaceBeforeSliceColon, " ", string.Empty, this.GetSecondWhiteSpaceDefaultNull(ast) ?? "");
             res.Append(':');
             if (SliceStep != null)
             {
                 string ws = null;
                 if (format.SpaceAfterSliceColon.HasValue)
                 {
                     ws = string.Empty;
                     format.Append(res, format.SpaceAfterSliceColon, " ", string.Empty, string.Empty);
                 }
                 SliceStep.AppendCodeString(res, ast, format, ws);
             }
         }
     }
 }
Example #2
0
 public override void Walk(PythonWalker walker)
 {
     if (walker.Walk(this))
     {
         SliceStart?.Walk(walker);
         SliceStop?.Walk(walker);
         SliceStep?.Walk(walker);
     }
     walker.PostWalk(this);
 }
Example #3
0
 public override async Task WalkAsync(PythonWalkerAsync walker, CancellationToken cancellationToken = default)
 {
     if (await walker.WalkAsync(this, cancellationToken))
     {
         if (SliceStart != null)
         {
             await SliceStart.WalkAsync(walker, cancellationToken);
         }
         if (SliceStop != null)
         {
             await SliceStop.WalkAsync(walker, cancellationToken);
         }
         if (SliceStep != null)
         {
             await SliceStep.WalkAsync(walker, cancellationToken);
         }
     }
     await walker.PostWalkAsync(this, cancellationToken);
 }