Class Cs.RangeExpression

java.lang.Object
org.openrewrite.csharp.tree.Cs.RangeExpression
All Implemented Interfaces:
Cs, org.openrewrite.java.tree.Expression, org.openrewrite.java.tree.J, org.openrewrite.Tree
Enclosing interface:
Cs

public static final class Cs.RangeExpression extends Object implements Cs, org.openrewrite.java.tree.Expression
Represents a C# range expression which creates a Range value representing a sequence of indices. Range expressions use the '..' operator to specify start and end bounds, and can use '^' to specify indices from the end.

For example:

     // Full range
     arr[..]

     // Range with start index
     arr[2..]

     // Range with end index
     arr[..5]

     // Range with both indices
     arr[2..5]

     // Range with end-relative indices using '^'
     arr[..^1]     // excludes last element
     arr[1..^1]    // from index 1 to last-1
     arr[^2..^1]   // second-to-last to last-but-one

     // Standalone range expressions
     Range r1 = 1..4;
     Range r2 = ..^1;
 
  • Constructor Details

    • RangeExpression

      public RangeExpression()
  • Method Details

    • getStart

      public @Nullable org.openrewrite.java.tree.Expression getStart()
    • withStart

      public Cs.RangeExpression withStart(@Nullable org.openrewrite.java.tree.Expression start)
    • getType

      public org.openrewrite.java.tree.JavaType getType()
      Specified by:
      getType in interface org.openrewrite.java.tree.Expression
    • withType

      public Cs.RangeExpression withType(@Nullable org.openrewrite.java.tree.JavaType type)
      Specified by:
      withType in interface org.openrewrite.java.tree.Expression
    • acceptCSharp

      public <P> org.openrewrite.java.tree.J acceptCSharp(CSharpVisitor<P> v, P p)
      Specified by:
      acceptCSharp in interface Cs
    • getCoordinates

      public org.openrewrite.java.tree.CoordinateBuilder.Expression getCoordinates()
      Specified by:
      getCoordinates in interface org.openrewrite.java.tree.Expression
    • getPadding

      public Cs.RangeExpression.Padding getPadding()