/** Return the statement referenced by a label.
* If the label refers to a loop or switch, return that switch
* otherwise return the labelled statement itself
*/
public static JCTree referencedStatement(JCLabeledStatement tree) {
JCTree t = tree;
do t = ((JCLabeledStatement) t).body;
while (t.getTag() == JCTree.LABELLED);
switch (t.getTag()) {
case JCTree.DOLOOP: case JCTree.WHILELOOP: case JCTree.FORLOOP: case JCTree.FOREACHLOOP: case JCTree.SWITCH:
return t;
default:
return tree;
}