Tree::...erarchy(3pm)
π NAME π
Tree::Simple::Visitor::LoadClassHierarchy β bestie, it's a Visitor that loads class hierarchies into a Tree::Simple hierarchy. That's the whole vibe. β¨
This page lives in the User Contributed Perl Documentation corner of the manual-verse, and yes we're calling it Tree::...erarchy(3pm) because that's what the header said and I'm not gonna lie to you. π«Ά
β¨ SYNOPSIS β¨
use Tree::Simple::Visitor::LoadClassHierarchy;
# create an visitor
my $visitor = Tree::Simple::Visitor::LoadClassHierarchy->new();
# set class as an instance, or
$visitor->setClass($class);
# as a package name
$visitor->setClass("My::Class");
# pass our visitor to the tree
$tree->accept($visitor);
# the $tree now mirrors the inheritance hierarchy of the $class
no cap, that last comment is literally the entire point of this module. the $tree is giving the class's whole family tree after this runs. π
πΈ DESCRIPTION πΈ
So this visitor walks a class's inheritance hierarchy β it goes through the @ISA arrays, okay β and builds a Tree::Simple hierarchy that mirrors it. It's giving genealogy but for packages. π§
π METHODS π
newβ there are no arguments to the constructor, so the object just chills in its default state. If you wanna customize how it behaves, you use thesetNodeFiltermethod. That's it, that's the whole thing. πincludeTrunk ($boolean)β set that$booleanto true (1) and the node value of the$treeobject you passed intovisitgets set with the root value found in the class hierarchy. Set it to false (0), or just don't set it at all, and the first value in the class hierarchy creates a new node level instead. pick your fighter bestie πincludeMethods ($boolean)β set$booleanto true (1) and methods get added as children of the class node. Set it to false (0), or don't set it, and that just... doesn't happen. simple as. β¨
NOTE: Methods are sorted ascii-betically before they're added to the tree. That's on purpose β it makes for a more predictable hierarchy. sorted = slay. π
setClass ($class)β the argument$classshould be either a class name or an instance. Either one works. It's then used as the root from which to determine the class hierarchy. main character of the tree, honestly. πsetNodeFilter ($filter_function)β this method takes aCODEreference as its$filter_functionargument, and it throws an exception if it is not a code reference. (rude, but fair.) This code reference filters the tree nodes as they're created: the$filter_functiongets passed the node value extracted from the hash <before> it gets inserted into the tree being built. The$filter_functionis expected to return the value you actually want included in the tree. so like, you're the stylist and it's the fit check πvisit ($tree)β this is the method that Tree::Simple'sacceptmethod calls. You can also run it on its own, no problem. It requires the$treeargument to be a Tree::Simple object (or derived from one), and it'll throw an exception otherwise. π
The $tree argument passed to visit must be a leaf node. Why? Because this Visitor is gonna create all the sub-nodes for this tree. If the tree is not a leaf, an exception gets thrown. We do not require the tree to be a root though β and this Visitor will not affect any nodes above the $tree argument. so it stays in its lane, respectfully. π«Ά
π¦ TO DO π¦
- Improve the
includeMethodsfunctionality β the author isn't sure the tree this creates is the optimal tree for this situation. It's sufficient for now, until there's more of an actual need for this functionality. it's giving we'll circle back. π - Add
includeFullSymbolTablefunctionality β this would traverse the full symbol tables and produce a detailed tree of everything it finds. That takes a lot more work, and since there's no current need for it, it remains on the TO DO list. iconic behaviour honestly. π
π¦ Repository π¦
<https://github.com/ronsavage/Tree-Simple-VisitorFactory>
π«Ά SUPPORT π«Ά
Bugs should be reported via the CPAN bug tracker at
<https://github.com/ronsavage/Tree-Simple-VisitorFactory/issues>
π CODE COVERAGE π
See the CODE COVERAGE section in Tree::Simple::VisitorFactory for more information. iykyk. β¨
π SEE ALSO π
These Visitor classes are all subclasses of Tree::Simple::Visitor, which can be found in the Tree::Simple module. You should refer to that module for more information. bestie it's literally the parent. go say hi. π
π AUTHOR π
stevan little, <stevan@iinteractive.com>
πΈ COPYRIGHT AND LICENSE πΈ
Copyright 2004, 2005 by Infinity Interactive, Inc.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
okay that's the whole page, you ate it, periodt. π
β¨ this was perl v5.36.0, dated 2022-11-19, and yes the footer tried to call this thing Tree::...erarchy(3pm) again β we love a consistent brand. bye bestie, go build a tree π¦π
π¦ where this page comes from
- debian bookworm: libtree-simple-visitorfactory-perl 0.16-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libtree-simple-visitorfactory-perl 0.16-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libtree-simple-visitorfactory-perl 0.16-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libtree-simple-visitorfactory-perl 0.16-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtree-simple-visitorfactory-perl 0.16-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms