< prev index next >

src/jdk.jextract/share/classes/com/sun/tools/jextract/tree/Tree.java

Print this page

        

*** 20,54 **** * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.tools.jextract.tree; import jdk.internal.clang.Cursor; import jdk.internal.clang.SourceLocation; import jdk.internal.clang.SourceRange; - import jdk.internal.clang.Type; public class Tree { private final Cursor c; ! public Tree(Cursor c) { ! this.c = c; } ! final Cursor cursor() { return c; } public final Type type() { return c.type(); } ! public final String name() { ! return c.spelling(); } ! public final String identifier() { ! return LayoutUtils.getIdentifier(c); } public final SourceLocation location() { return c.getSourceLocation(); } --- 20,62 ---- * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.tools.jextract.tree; + import java.util.Objects; import jdk.internal.clang.Cursor; + import jdk.internal.clang.Type; import jdk.internal.clang.SourceLocation; import jdk.internal.clang.SourceRange; public class Tree { private final Cursor c; ! private final String name; ! ! Tree(Cursor c) { ! this(c, c.spelling()); } ! Tree(Cursor c, String name) { ! this.c = Objects.requireNonNull(c); ! this.name = Objects.requireNonNull(name); ! } ! ! public final Cursor cursor() { return c; } public final Type type() { return c.type(); } ! public Tree withName(String newName) { ! return name.equals(newName)? this : new Tree(c, newName); } ! public final String name() { ! return name; } public final SourceLocation location() { return c.getSourceLocation(); }
*** 85,100 **** if (!(obj instanceof Tree)) { return false; } ! return c.equals(((Tree)obj).cursor()); } @Override public final int hashCode() { ! return c.hashCode(); } @Override public final String toString() { return Printer.Stringifier(p -> p.dumpCursor(c, true)); --- 93,109 ---- if (!(obj instanceof Tree)) { return false; } ! Tree t = (Tree)obj; ! return name.equals(t.name()) && c.equals(t.cursor()); } @Override public final int hashCode() { ! return name.hashCode() ^ c.hashCode(); } @Override public final String toString() { return Printer.Stringifier(p -> p.dumpCursor(c, true));
< prev index next >