Merge: Ci more
[nit.git] / src / astvalidation.nit
index 2883197..cf3da76 100644 (file)
@@ -24,11 +24,23 @@ class ASTValidationVisitor
        do
                node.accept_ast_validation(self)
        end
-       private var path = new List[ANode]
+       private var path = new CircularArray[ANode]
        private var seen = new HashSet[ANode]
 end
 
 redef class ANode
+       # Recursively validate a AST node.
+       # This ensure that location and parenting are defined and coherent.
+       #
+       # After complex low-level AST manipulation and construction,
+       # it is recommended to call it.
+       #
+       # Note: this just instantiate and run an `ASTValidationVisitor`.
+       fun validate
+       do
+               (new ASTValidationVisitor).enter_visit(self)
+       end
+
        private fun accept_ast_validation(v: ASTValidationVisitor)
        do
                var parent = self.parent