MCPcopy
hub / github.com/psf/black / visit_default

Method visit_default

src/black/debug.py:26–44  ·  view source on GitHub ↗
(self, node: LN)

Source from the content-addressed store, hash-verified

24 out(message, *args, **kwargs)
25
26 def visit_default(self, node: LN) -> Iterator[T]:
27 indent = " " * (2 * self.tree_depth)
28 if isinstance(node, Node):
29 _type = type_repr(node.type)
30 self.out(f"{indent}{_type}", fg="yellow")
31 self.tree_depth += 1
32 for child in node.children:
33 yield from self.visit(child)
34
35 self.tree_depth -= 1
36 self.out(f"{indent}/{_type}", fg="yellow", bold=False)
37 else:
38 _type = token.tok_name.get(node.type, str(node.type))
39 self.out(f"{indent}{_type}", fg="blue", nl=False)
40 if node.prefix:
41 # We don't have to handle prefixes for `Node` objects since
42 # that delegates to the first child anyway.
43 self.out(f" {node.prefix!r}", fg="green", bold=False, nl=False)
44 self.out(f" {node.value!r}", fg="blue", bold=False)
45
46 @classmethod
47 def show(cls, code: str | Leaf | Node) -> None:

Callers

nothing calls this directly

Calls 3

outMethod · 0.95
type_reprFunction · 0.90
visitMethod · 0.80

Tested by

no test coverage detected