Add toString support for Label and LabelReference.
@@ -96,7 +96,7 @@ class ToStringRenderer {
print("break");
if (breakStatement.getLabelReference() != null) {
print(" ");
- print(breakStatement.getLabelReference().getTarget().getName());
+ accept(breakStatement.getLabelReference());
}
print(";");
return false;
@@ -175,7 +175,7 @@ class ToStringRenderer {
print("continue");
if (continueStatement.getLabelReference() != null) {
print(" ");
- print(continueStatement.getLabelReference().getTarget().getName());
+ accept(continueStatement.getLabelReference());
}
print(";");
return false;
@@ -287,7 +287,7 @@ class ToStringRenderer {
@Override
public boolean enterLabeledStatement(LabeledStatement labeledStatement) {
- print(labeledStatement.getLabel().getName());
+ accept(labeledStatement.getLabel());
print(": ");
accept(labeledStatement.getStatement());
return false;
@@ -302,6 +302,18 @@ class ToStringRenderer {
return false;
}
+ @Override
+ public boolean enterLabel(Label label) {
+ print(label.getName());
+ return false;
+ }
+
+ @Override
+ public boolean enterLabelReference(LabelReference labelReference) {
+ print(labelReference.getTarget().getName());
+ return false;
+ }
+
@Override
public boolean enterMethod(Method method) {
print(method.getReadableDescription() + " ");
@@ -629,4 +641,6 @@ class ToStringRenderer {
}.accept(node);
return result.toString();
}
+
+ private ToStringRenderer() {}
}
