Skip to content

Commit

Permalink
GROOVY-9649: Refactored RangeExpression
Browse files Browse the repository at this point in the history
- Old constructor now delegates to the new constructor
- Dropped inclusive class variable, isInclusive is handled via right exclusivity.
  • Loading branch information
iiroki authored and paulk-asert committed Apr 12, 2021
1 parent 06b56f2 commit e642159
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions src/main/java/org/codehaus/groovy/ast/expr/RangeExpression.java
Expand Up @@ -29,26 +29,18 @@
public class RangeExpression extends Expression {
private final Expression from;
private final Expression to;
private final boolean inclusive; // Kept to keep old code depending on this working
// GROOVY-9649
private final boolean exclusiveLeft;
private final boolean exclusiveRight;

// Kept until sure this can be removed
public RangeExpression(Expression from, Expression to, boolean inclusive) {
this.from = from;
this.to = to;
this.inclusive = inclusive;
this.exclusiveLeft = false;
this.exclusiveRight = !inclusive;
setType(ClassHelper.RANGE_TYPE);
this(from, to, false, !inclusive);
}

// GROOVY-9649
public RangeExpression(Expression from, Expression to, boolean exclusiveLeft, boolean exclusiveRight) {
this.from = from;
this.to = to;
this.inclusive = !exclusiveRight; // Old code depends on this
this.exclusiveLeft = exclusiveLeft;
this.exclusiveRight = exclusiveRight;
setType(ClassHelper.RANGE_TYPE);
Expand Down Expand Up @@ -77,7 +69,7 @@ public Expression getTo() {
}

public boolean isInclusive() {
return inclusive;
return !isExclusiveRight();
}

public boolean isExclusiveLeft() {
Expand Down

0 comments on commit e642159

Please sign in to comment.