nonSynthetic property

  1. @override
Element nonSynthetic
inherited

The non-synthetic element that caused this element to be created.

If this element is not synthetic, then the element itself is returned.

If this element is synthetic, then the corresponding non-synthetic element is returned. For example, for a synthetic getter of a non-synthetic field the field is returned; for a synthetic constructor the enclosing class is returned.

Implementation

@override
Element get nonSynthetic {
  if (isSynthetic) {
    if (enclosingElement is EnumElementImpl) {
      // TODO(scheglov): remove 'index'?
      if (name == 'index' || name == 'values') {
        return enclosingElement;
      }
    }
    return (getter ?? setter)!;
  } else {
    return this;
  }
}