diff options
| author | Michael Williamson <mike@zwobble.org> | 2016-07-17 17:16:35 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2016-07-17 17:16:35 +0100 |
| commit | 26b78ce8c7864460eb684462878d6328f18df7d2 (patch) | |
| tree | c0dfd0fd7f6d23b756140314ff0bee43bc70f928 /src | |
| parent | a48b9d12118e650c1edac765ba1fb0f9d1ea10c8 (diff) | |
Update docs for DynamicNodeVisitor
Diffstat (limited to 'src')
| -rw-r--r-- | src/main/java/org/zwobble/couscous/ast/visitors/DynamicNodeVisitor.java | 10 |
1 files changed, 6 insertions, 4 deletions
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. * - * <p>For instance, let's say you've defined two methods in a class:</p> + * <p>For instance, let's say you've defined two methods in a class called {@code NodeWriter}:</p> * * <blockquote><pre> * void visit(LiteralNode); @@ -49,7 +49,7 @@ import static org.zwobble.couscous.util.ExtraMaps.entry; * Calling: * * <blockquote><pre> - * DynamicNodeVisitor.build(NodeWriter.class, "visit").instantiate(nodeWriter) + * DynamicNodeVisitor.instantiate(nodeWriter, "visit") * </pre></blockquote> * * will generate a function accepting a node equivalent to: @@ -68,8 +68,10 @@ import static org.zwobble.couscous.util.ExtraMaps.entry; * </pre></blockquote> * * <p> - * 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()}. * </p> * * <p> |
