< prev index next >

src/jdk.internal.clang/share/classes/jdk/internal/clang/Cursor.java

Print this page

        

@@ -60,28 +60,17 @@
     public native boolean isInvalid();
     public native boolean isDefinition();
     public native boolean isAnonymousStruct();
     public native boolean isMacroFunctionLike();
 
-    public boolean isAnonymousEnum() {
-        // libclang::clang_Cursor_isAnonymous only applies to struct, not enum
-        return (type().kind() == TypeKind.Enum && spelling().isEmpty());
-    }
-
-    public boolean isAnonymous() {
-        return isAnonymousStruct() || isAnonymousEnum();
-    }
-
     public native String spelling();
     public native String USR();
 
     public native int kind1();
 
     public native int visitChildren(Visitor visitor, Object data);
 
-    public native boolean equalCursor(Cursor other);
-
     public native Type type();
     public native Type getEnumDeclIntegerType();
 
     public native Cursor getDefinition();
 

@@ -110,14 +99,10 @@
         int v = kind1();
         // FIXME: assert(v == getData().getInt(0));
         return CursorKind.valueOf(v);
     }
 
-    public boolean equals(Cursor other) {
-        return getData().equals(other.getData());
-    }
-
     public Stream<Cursor> children() {
         ArrayList<Cursor> ar = new ArrayList<>();
         visitChildren((c, p, d) -> {
             @SuppressWarnings("unchecked")
             List<Cursor> a = (List<Cursor>) d;

@@ -125,9 +110,27 @@
             return VisitResult.Continue;
         }, ar);
         return ar.stream();
     }
 
-    public Stream<Cursor> stream() {
+    public Stream<Cursor> allChildren() {
         return children().flatMap(c -> Stream.concat(Stream.of(c), c.children()));
     }
+
+    public native boolean equalCursor(Cursor other);
+
+    @Override
+    public boolean equals(Object other) {
+        if (this == other) {
+            return true;
+        }
+        if (!(other instanceof Cursor)) {
+            return false;
+        }
+        return equalCursor((Cursor)other);
+    }
+
+    @Override
+    public int hashCode() {
+        return spelling().hashCode();
+    }
 }
< prev index next >