From 26b78ce8c7864460eb684462878d6328f18df7d2 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 17 Jul 2016 17:16:35 +0100 Subject: Update docs for DynamicNodeVisitor --- .../org/zwobble/couscous/ast/visitors/DynamicNodeVisitor.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/main/java/org/zwobble/couscous/ast/visitors/DynamicNodeVisitor.java b/src/main/java/org/zwobble/couscous/ast/visitors/DynamicNodeVisitor.java index 438bcea..4dc46ec 100644 --- a/src/main/java/org/zwobble/couscous/ast/visitors/DynamicNodeVisitor.java +++ b/src/main/java/org/zwobble/couscous/ast/visitors/DynamicNodeVisitor.java @@ -39,7 +39,7 @@ import static org.zwobble.couscous.util.ExtraMaps.entry; /** * Dynamically generate a method to dispatch methods based on node type. * - *

For instance, let's say you've defined two methods in a class:

+ *

For instance, let's say you've defined two methods in a class called {@code NodeWriter}:

* *
  *     void visit(LiteralNode);
@@ -49,7 +49,7 @@ import static org.zwobble.couscous.util.ExtraMaps.entry;
  * Calling:
  *
  * 
- *     DynamicNodeVisitor.build(NodeWriter.class, "visit").instantiate(nodeWriter)
+ *     DynamicNodeVisitor.instantiate(nodeWriter, "visit")
  * 
* * will generate a function accepting a node equivalent to: @@ -68,8 +68,10 @@ import static org.zwobble.couscous.util.ExtraMaps.entry; *
* *

- * Note that {@code build} is comparatively expensive, - * so should normally be called once separately from {@code instantiate}. + * {@code visit} methods are found by performing reflection on the run-time type + * of the value passed to {@code instantiate()}. To use reflection on a super-type, + * or to avoid repeating the cost of looking up the generated code for that type, + * use {@code visitor()} instead of {@code instantiate()}. *

* *

-- cgit v1.2.3