lookout.style.format.virtual_node

Defines VirtualNode - a class which backs any source code token.

Module Contents

class lookout.style.format.virtual_node.Position

Bases:typing.NamedTuple()

Data class to hold position information of virtual nodes.

line and col are 1-based to match UAST, offset is 0-based.

static from_bblfsh_position(position:bblfsh.Position)

Create a lookout.style.format.virtual_node.Position from a bblfsh.Position.

class lookout.style.format.virtual_node.VirtualNode(value:str, start:Position, end:Position, *, node:bblfsh.Node=None, y:Optional[Tuple[int, ...]]=None, is_accumulated_indentation:bool=False, path:str=None)

Represent either a real UAST node or an imaginary token.

The class instance should be considered as read-only.

__str__(self)
__repr__(self)
__eq__(self, other:'VirtualNode')
copy(self)

Produce a full clone of the node.

is_labeled_on_lines(self, lines:Optional[Set[int]])

Return true for labeled VirtualNode instance that located on specified lines.

Parameters:lines – list of lines or None. None is considered as all possible lines.
Returns:Condition value
static from_node(node:bblfsh.Node, file:str, token_unwrappers:Mapping[str, Callable[[str], Tuple[str, str]]])

Initialize the VirtualNode from a UAST node. Takes into account prefixes and suffixes.

Parameters:
  • node – UAST node.
  • file – File contents.
  • token_unwrappers – Mapping from bblfsh internal types to functions to unwrap tokens.
Returns:

New VirtualNode-s.

lookout.style.format.virtual_node.AnyNode