From 36368cd606c39adb584cf92f5a9a41fc44ea571a Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Wed, 8 Oct 2014 15:13:43 +0200 Subject: [PATCH] More removals and cleanups. --- jedi/parser/pytree.py | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/jedi/parser/pytree.py b/jedi/parser/pytree.py index 66046e3f..054ae091 100644 --- a/jedi/parser/pytree.py +++ b/jedi/parser/pytree.py @@ -252,7 +252,8 @@ class Node(Base): for el in child.post_order(): yield el - def _prefix_getter(self): + @property + def prefix(self): """ The whitespace and comments preceding this node in the input. """ @@ -260,11 +261,12 @@ class Node(Base): return "" return self.children[0].prefix - def _prefix_setter(self, prefix): + @prefix.setter + def prefix(self, prefix): if self.children: self.children[0].prefix = prefix - - prefix = property(_prefix_getter, _prefix_setter) + else: + raise NotImplementedError def set_child(self, i, child): """ @@ -274,7 +276,6 @@ class Node(Base): child.parent = self self.children[i].parent = None self.children[i] = child - self.changed() def insert_child(self, i, child): """ @@ -283,7 +284,6 @@ class Node(Base): """ child.parent = self self.children.insert(i, child) - self.changed() def append_child(self, child): """ @@ -292,7 +292,6 @@ class Node(Base): """ child.parent = self self.children.append(child) - self.changed() class Leaf(Base): @@ -316,8 +315,8 @@ class Leaf(Base): self._prefix, (self.lineno, self.column) = context self.type = type self.value = value - if prefix is not None: - self._prefix = prefix + # The whitespace and comments preceding this token in the input. + self.prefix = prefix or '' def __repr__(self): """Return a canonical string representation.""" @@ -351,18 +350,6 @@ class Leaf(Base): """Return a pre-order iterator for the tree.""" yield self - def _prefix_getter(self): - """ - The whitespace and comments preceding this token in the input. - """ - return self._prefix - - def _prefix_setter(self, prefix): - self.changed() - self._prefix = prefix - - prefix = property(_prefix_getter, _prefix_setter) - def convert(gr, raw_node): """