Skip to content

Commit

Permalink
Make Region fields private
Browse files Browse the repository at this point in the history
This is a follow-up to jruby#58 and will release in 2.2.
  • Loading branch information
headius committed Feb 4, 2023
1 parent 43adfb9 commit c696d94
Showing 1 changed file with 4 additions and 20 deletions.
24 changes: 4 additions & 20 deletions src/org/joni/Region.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,23 @@
public final class Region {
static final int REGION_NOTPOS = -1;

@Deprecated
public final int numRegs;
@Deprecated
public final int[] beg;
@Deprecated
public final int[] end;
@Deprecated
public CaptureTreeNode historyRoot;
private final int numRegs;
private final int[] beg;
private final int[] end;
private CaptureTreeNode historyRoot;

@SuppressWarnings("deprecation")
public Region(int num) {
this.numRegs = num;
this.beg = new int[num];
this.end = new int[num];
}

@SuppressWarnings("deprecation")
public Region(int begin, int end) {
this.numRegs = 1;
this.beg = new int[]{begin};
this.end = new int[]{end};
}

@SuppressWarnings("deprecation")
public Region clone() {
Region region = new Region(numRegs);
System.arraycopy(beg, 0, region.beg, 0, beg.length);
Expand All @@ -54,50 +47,41 @@ public Region clone() {
return region;
}

@SuppressWarnings("deprecation")
public int getNumRegs() {
return numRegs;
}

@SuppressWarnings("deprecation")
public int getBeg(int index) {
return beg[index];
}

@SuppressWarnings("deprecation")
public int setBeg(int index, int value) {
return beg[index] = value;
}

@SuppressWarnings("deprecation")
public int getEnd(int index) {
return end[index];
}

@SuppressWarnings("deprecation")
public int setEnd(int index, int value) {
return end[index] = value;
}

@SuppressWarnings("deprecation")
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("Region: \n");
for (int i=0; i<beg.length; i++) sb.append(" " + i + ": (" + beg[i] + "-" + end[i] + ")");
return sb.toString();
}

@SuppressWarnings("deprecation")
CaptureTreeNode getCaptureTree() {
return historyRoot;
}

@SuppressWarnings("deprecation")
CaptureTreeNode setCaptureTree(CaptureTreeNode ctn) {
return this.historyRoot = ctn;
}

@SuppressWarnings("deprecation")
void clear() {
for (int i=0; i<beg.length; i++) {
beg[i] = end[i] = REGION_NOTPOS;
Expand Down

0 comments on commit c696d94

Please sign in to comment.