* @param labelNode the node representing the label being looked up
* @return the element corresponding to the given label node in the current scope
*/
private LabelElementImpl lookupLabel(AstNode parentNode, SimpleIdentifier labelNode) {
LabelScope labelScope = resolver.getLabelScope();
LabelElementImpl labelElement = null;
if (labelNode == null) {
if (labelScope == null) {
// TODO(brianwilkerson) Do we need to report this error, or is this condition always caught in the parser?
// reportError(ResolverErrorCode.BREAK_OUTSIDE_LOOP);
} else {
labelElement = (LabelElementImpl) labelScope.lookup(LabelScope.EMPTY_LABEL);
if (labelElement == null) {
// TODO(brianwilkerson) Do we need to report this error, or is this condition always caught in the parser?
// reportError(ResolverErrorCode.BREAK_OUTSIDE_LOOP);
}
//
// The label element that was returned was a marker for look-up and isn't stored in the
// element model.
//
labelElement = null;
}
} else {
if (labelScope == null) {
resolver.reportErrorForNode(
CompileTimeErrorCode.LABEL_UNDEFINED,
labelNode,
labelNode.getName());
} else {
labelElement = (LabelElementImpl) labelScope.lookup(labelNode.getName());
if (labelElement == null) {
resolver.reportErrorForNode(
CompileTimeErrorCode.LABEL_UNDEFINED,
labelNode,
labelNode.getName());
} else {
labelNode.setStaticElement(labelElement);
}
}
}
if (labelElement != null) {
ExecutableElement labelContainer = labelElement.getAncestor(ExecutableElement.class);
if (labelContainer != resolver.getEnclosingFunction()) {
resolver.reportErrorForNode(
CompileTimeErrorCode.LABEL_IN_OUTER_SCOPE,
labelNode,
labelNode.getName());