struct Bindgen::Graph::Path
- Bindgen::Graph::Path
- Struct
- Value
- Object
Overview
Pathing logic for the graph. See Path.local to find a locally-qualified
path between two nodes. Or use .from to build a path from a string.
The structure doesn't store any origin by itself.
Defined in:
bindgen/graph/path.crConstructors
-
.from(path : String) : Path
Returns a new
Pathon path. -
.from(path : Enumerable(String)) : Path
ditto
-
.from(path : Nil) : Path
Returns a self-referencing path.
-
.global(node : Graph::Node) : Path
Returns the global path to node.
-
.local(node : Graph::Node, wants : Graph::Node) : Path
Finds the local path to go from node to wants, in terms of constant resolution for Crystal.
- .new(nodes : Nil | Array(String) = [] of String)
Instance Method Summary
-
#[](range : Range) : Path
Returns the path parts in range.
-
#global?
Is this a global path?
-
#inspect(io)
Much like
#to_s, but tells the user when this path points to itself. - #last
-
#last_part : String
Returns the last element of
#nodesitself. -
#local?
Is this a local path? Also
trueif this is a#self?path. -
#lookup(base : Node) : Node | Nil
Does a local look-up starting at base for path.
-
#nodes : Array(String) | Nil
Node path.
- #parent
-
#self?
Does this path point to itself?
-
#to_global(base : Node) : Path
Returns a global path from this local path, starting look-up at base.
-
#to_s(io)
Gives the path as Crystal constants look-up path.
Constructor Detail
Returns a new Path on path. Supports generic parts.
BUG Doesn't support nested generics, like Foo(Bar(Baz))::Quux.
Finds the local path to go from node to wants, in terms of constant resolution for Crystal.
BUG Fails if Foo::Node, Foo::Wants and Foo::Node::Wants exist.
The affected branches are marked with !!.
Instance Method Detail
Does a local look-up starting at base for path. The look-up will begin in base itself. If not found, it'll try to find the path by going up to the parent(s).
If the path starts with :: (An empty element), the look-up will
always start at the global scope. If :: is given, the root node
is returned. Otherwise, the first part of the path must be the name
of the root node: ::RootNameHere::And::So::On instead of
::And::So::On.
If not found, returns nil. This method does not raise.
Returns a global path from this local path, starting look-up at base. Does a full look-up under the hood, thus, the path has to be valid.
If this is already a #global? path, it is returned without further
checks.