Refactor AST APIs
Added public visibility to some constructors/accessors, and made child LValue nodes explicitly constructed by the caller rather than hidden inside constructors. This makes it easier to treat nodes as uniform dumb values. Also added some helpers.
RELNOTES: None
PiperOrigin-RevId: 158761415
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/ASTNode.java b/src/main/java/com/google/devtools/build/lib/syntax/ASTNode.java
index 84d859f..d2e22d9 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/ASTNode.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/ASTNode.java
@@ -21,6 +21,10 @@
/**
* Root class for nodes in the Abstract Syntax Tree of the Build language.
+ *
+ * The standard {@link Object#equals} and {@link Object#hashCode} methods are not supported. This is
+ * because their implementation would require traversing the entire tree in the worst case, and we
+ * don't want this kind of cost to occur implicitly.
*/
public abstract class ASTNode implements Serializable {
@@ -78,7 +82,7 @@
@Override
public int hashCode() {
- throw new UnsupportedOperationException(); // avoid nondeterminism
+ throw new UnsupportedOperationException();
}
@Override