--- old/src/jdk.jextract/share/classes/com/sun/tools/jextract/tree/EnumTree.java 2018-09-18 19:08:00.000000000 +0530 +++ new/src/jdk.jextract/share/classes/com/sun/tools/jextract/tree/EnumTree.java 2018-09-18 19:07:59.000000000 +0530 @@ -24,14 +24,32 @@ import java.util.List; import java.util.Collections; +import java.util.Objects; +import java.util.Optional; import jdk.internal.clang.Cursor; public class EnumTree extends Tree { + private final Optional definition; private final List constants; - public EnumTree(Cursor c, List constants) { - super(c); - this.constants = Collections.unmodifiableList(constants); + EnumTree(Cursor c, Optional definition, List consts) { + this(c, definition, consts, c.spelling()); + } + + private EnumTree(Cursor c, Optional definition, List consts, String name) { + super(c, name); + this.definition = c.isDefinition()? Optional.of(this) : Objects.requireNonNull(definition); + this.constants = Collections.unmodifiableList(consts); + } + + @Override + public EnumTree withName(String newName) { + return name().equals(newName)? this : + new EnumTree(cursor(), definition, constants, newName); + } + + public Optional definition() { + return definition; } public List constants() {