Skip to content

Commit

Permalink
Merge branch 'main' into friendly-error-messages
Browse files Browse the repository at this point in the history
  • Loading branch information
sampottinger authored Jul 13, 2023
2 parents 777d051 + 6cba79b commit e541663
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
13 changes: 5 additions & 8 deletions java/src/processing/mode/java/debug/VariableNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,9 @@ public class VariableNode implements MutableTreeNode {
public static final int TYPE_BYTE = 9;
public static final int TYPE_SHORT = 10;
public static final int TYPE_VOID = 11;

private static final Pattern ARRAY_REGEX = Pattern.compile(
"^(?<prefix>[^\\[]+)(?<unbounded>(\\[\\])*)(?<bounded>(\\[\\d+\\])+)(?<unneeded>[^\\[]*)$"
);


private static final Pattern ARRAY_REGEX = Pattern.compile("^(?<prefix>[^\\[]+)(?<unbounded>(\\[\\])+)(?<bounded>(\\[\\d+\\])+)(?<unneeded>[^\\[]*)$");

protected String type;
protected String name;
protected Value value;
Expand Down Expand Up @@ -111,7 +109,6 @@ public String getStringValue() {
}
}


public String getTypeName() {
return type;
}
Expand Down Expand Up @@ -391,18 +388,18 @@ public int hashCode() {
* Describe an array in a human friendly description.
*
* @see Issue #606
* @param fullDescrition The full description of the array like "instance of
* @param fullDescription The full description of the array like "instance of
* int[5] (id=998)" or "instance of int[][5] (id=998)"
* @return Human-friendly description like "instance of int[5]" or
* "instance of int[5][]".
*/
private String describeArray(String fullDescription) {
Matcher matcher = ARRAY_REGEX.matcher(fullDescription);
StringJoiner joiner = new StringJoiner("");
if (!matcher.matches()) {
return fullDescription;
}

StringJoiner joiner = new StringJoiner("");
joiner.add(matcher.group("prefix")); // Type without brackets
joiner.add(matcher.group("bounded")); // Brackets with numbers
joiner.add(matcher.group("unbounded")); // Brackets without numbers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void describeString() {
public void describeSimpleArray() {
Value value = buildMockValue("instance of int[5] (id=998)");
VariableNode node = new VariableNode("test", "int[]", value);
Assert.assertEquals(node.getStringValue(), "instance of int[5]");
Assert.assertEquals(node.getStringValue(), "instance of int[5] (id=998)");
}

@Test
Expand Down

0 comments on commit e541663

Please sign in to comment.