childs -> children.

This commit is contained in:
Holger Rapp 2014-02-12 22:22:55 +01:00
parent 82ca377aaf
commit ad6e8ed21e
4 changed files with 31 additions and 31 deletions

View File

@ -14,7 +14,7 @@ with open(DUMP_FILENAME, "w"):
pass # clears the file pass # clears the file
def echo_to_hierarchy(text_object): def echo_to_hierarchy(text_object):
"""Outputs the given 'text_object' and its childs hierarchically.""" """Outputs the given 'text_object' and its children hierarchically."""
# pylint:disable=protected-access # pylint:disable=protected-access
parent = text_object parent = text_object
while parent._parent: while parent._parent:
@ -24,7 +24,7 @@ def echo_to_hierarchy(text_object):
"""prints recursively.""" """prints recursively."""
debug(indent + as_unicode(text_object)) debug(indent + as_unicode(text_object))
try: try:
for child in text_object._childs: for child in text_object._children:
_do_print(child, indent=indent + " ") _do_print(child, indent=indent + " ")
except AttributeError: except AttributeError:
pass pass

View File

@ -115,7 +115,7 @@ class TextObject(object):
length information. If 'gtext' is None use the initial text of this length information. If 'gtext' is None use the initial text of this
object. object.
""" """
# We explicitly do not want to move our childs around here as we # We explicitly do not want to move our children around here as we
# either have non or we are replacing text initially which means we do # either have non or we are replacing text initially which means we do
# not want to mess with their positions # not want to mess with their positions
if self.current_text == gtext: if self.current_text == gtext:
@ -125,7 +125,7 @@ class TextObject(object):
self._start, self._end, gtext or self._initial_text) self._start, self._end, gtext or self._initial_text)
if self._parent: if self._parent:
self._parent._child_has_moved( self._parent._child_has_moved(
self._parent._childs.index(self), min(old_end, self._end), self._parent._children.index(self), min(old_end, self._end),
self._end.delta(old_end) self._end.delta(old_end)
) )
@ -144,21 +144,21 @@ class EditableTextObject(TextObject):
""" """
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
TextObject.__init__(self, *args, **kwargs) TextObject.__init__(self, *args, **kwargs)
self._childs = [] self._children = []
self._tabstops = {} self._tabstops = {}
############## ##############
# Properties # # Properties #
############## ##############
@property @property
def childs(self): def children(self):
"""List of all childs.""" """List of all children."""
return self._childs return self._children
@property @property
def _editable_childs(self): def _editable_children(self):
"""List of all childs that are EditableTextObjects""" """List of all children that are EditableTextObjects"""
return [child for child in self._childs if return [child for child in self._children if
isinstance(child, EditableTextObject)] isinstance(child, EditableTextObject)]
#################### ####################
@ -166,9 +166,9 @@ class EditableTextObject(TextObject):
#################### ####################
def find_parent_for_new_to(self, pos): def find_parent_for_new_to(self, pos):
"""Figure out the parent object for something at 'pos'.""" """Figure out the parent object for something at 'pos'."""
for childs in self._editable_childs: for children in self._editable_children:
if childs._start <= pos < childs._end: if children._start <= pos < children._end:
return childs.find_parent_for_new_to(pos) return children.find_parent_for_new_to(pos)
return self return self
############################### ###############################
@ -182,7 +182,7 @@ class EditableTextObject(TextObject):
to_kill = set() to_kill = set()
new_cmds = [] new_cmds = []
for child in self._childs: for child in self._children:
if ctype == "I": # Insertion if ctype == "I": # Insertion
if (child._start < pos < if (child._start < pos <
Position(child._end.line, child._end.col) and Position(child._end.line, child._end.col) and
@ -247,7 +247,7 @@ class EditableTextObject(TextObject):
delta.col *= -1 delta.col *= -1
pivot = Position(line, col) pivot = Position(line, col)
idx = -1 idx = -1
for cidx, child in enumerate(self._childs): for cidx, child in enumerate(self._children):
if child._start < pivot <= child._end: if child._start < pivot <= child._end:
idx = cidx idx = cidx
self._child_has_moved(idx, pivot, delta) self._child_has_moved(idx, pivot, delta)
@ -255,7 +255,7 @@ class EditableTextObject(TextObject):
def _move(self, pivot, diff): def _move(self, pivot, diff):
TextObject._move(self, pivot, diff) TextObject._move(self, pivot, diff)
for child in self._childs: for child in self._children:
child._move(pivot, diff) child._move(pivot, diff)
def _child_has_moved(self, idx, pivot, diff): def _child_has_moved(self, idx, pivot, diff):
@ -263,12 +263,12 @@ class EditableTextObject(TextObject):
'diff'.""" 'diff'."""
self._end.move(pivot, diff) self._end.move(pivot, diff)
for child in self._childs[idx+1:]: for child in self._children[idx+1:]:
child._move(pivot, diff) child._move(pivot, diff)
if self._parent: if self._parent:
self._parent._child_has_moved( self._parent._child_has_moved(
self._parent._childs.index(self), pivot, diff self._parent._children.index(self), pivot, diff
) )
def _get_next_tab(self, number): def _get_next_tab(self, number):
@ -285,7 +285,7 @@ class EditableTextObject(TextObject):
break break
i += 1 i += 1
child = [c._get_next_tab(number) for c in self._editable_childs] child = [c._get_next_tab(number) for c in self._editable_children]
child = [c for c in child if c] child = [c for c in child if c]
possible_sol += child possible_sol += child
@ -310,7 +310,7 @@ class EditableTextObject(TextObject):
break break
i -= 1 i -= 1
child = [c._get_prev_tab(number) for c in self._editable_childs] child = [c._get_prev_tab(number) for c in self._editable_children]
child = [c for c in child if c] child = [c for c in child if c]
possible_sol += child possible_sol += child
@ -325,7 +325,7 @@ class EditableTextObject(TextObject):
interested in this.""" interested in this."""
if number in self._tabstops: if number in self._tabstops:
return self._tabstops[number] return self._tabstops[number]
for child in self._editable_childs: for child in self._editable_children:
if child is requester: if child is requester:
continue continue
rv = child._get_tabstop(self, number) rv = child._get_tabstop(self, number)
@ -335,20 +335,20 @@ class EditableTextObject(TextObject):
return self._parent._get_tabstop(self, number) return self._parent._get_tabstop(self, number)
def _update(self, done): def _update(self, done):
if all((child in done) for child in self._childs): if all((child in done) for child in self._children):
assert self not in done assert self not in done
done.add(self) done.add(self)
return True return True
def _add_child(self, child): def _add_child(self, child):
"""Add 'child' as a new child of this text object.""" """Add 'child' as a new child of this text object."""
self._childs.append(child) self._children.append(child)
self._childs.sort() self._children.sort()
def _del_child(self, child): def _del_child(self, child):
"""Delete this 'child'.""" """Delete this 'child'."""
child._parent = None child._parent = None
self._childs.remove(child) self._children.remove(child)
# If this is a tabstop, delete it # If this is a tabstop, delete it
try: try:

View File

@ -60,8 +60,8 @@ def _do_parse(all_tokens, seen_ts, parent_to, text, indent):
def parse_text_object(parent_to, text, indent): def parse_text_object(parent_to, text, indent):
"""Parses a text object from 'text' assuming the current 'indent'. Will """Parses a text object from 'text' assuming the current 'indent'. Will
instantiate all the objects and link them as childs to parent_to. Will also instantiate all the objects and link them as children to parent_to. Will
put the initial text into Vim.""" also put the initial text into Vim."""
seen_ts = {} seen_ts = {}
all_tokens = [] all_tokens = []

View File

@ -37,10 +37,10 @@ class SnippetInstance(EditableTextObject):
def replace_initial_text(self): def replace_initial_text(self):
"""Puts the initial text of all text elements into Vim.""" """Puts the initial text of all text elements into Vim."""
def _place_initial_text(obj): def _place_initial_text(obj):
"""recurses on the childs to do the work.""" """recurses on the children to do the work."""
obj.overwrite() obj.overwrite()
if isinstance(obj, EditableTextObject): if isinstance(obj, EditableTextObject):
for child in obj._childs: for child in obj._children:
_place_initial_text(child) _place_initial_text(child)
_place_initial_text(self) _place_initial_text(self)
@ -60,7 +60,7 @@ class SnippetInstance(EditableTextObject):
def _find_recursive(obj): def _find_recursive(obj):
"""Finds all text objects and puts them into 'not_done'.""" """Finds all text objects and puts them into 'not_done'."""
if isinstance(obj, EditableTextObject): if isinstance(obj, EditableTextObject):
for child in obj._childs: for child in obj._children:
_find_recursive(child) _find_recursive(child)
not_done.add(obj) not_done.add(obj)
_find_recursive(self) _find_recursive(self)