From 140320143a48513caf6f756bc51ecf4ff662fc67 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Thu, 9 Oct 2014 11:02:03 +0200 Subject: [PATCH] Remove the old Leave class. --- jedi/parser/pytree.py | 47 ----------------------------------------- test/test_new_parser.py | 4 ++++ 2 files changed, 4 insertions(+), 47 deletions(-) diff --git a/jedi/parser/pytree.py b/jedi/parser/pytree.py index 66add302..76b55807 100644 --- a/jedi/parser/pytree.py +++ b/jedi/parser/pytree.py @@ -159,53 +159,6 @@ class Node(Base): self.children.append(child) -class Leaf(Base): - - """Concrete implementation for leaf nodes.""" - - # Default values for instance variables - _prefix = "" # Whitespace and comments preceding this token in the input - lineno = 0 # Line where this token starts in the input - column = 0 # Column where this token tarts in the input - - def __init__(self, type, value, start_pos, prefix): - """ - Initializer. - - Takes a type constant (a token number < 256), a string value, and an - optional context keyword argument. - """ - # The whitespace and comments preceding this token in the input. - self.prefix = prefix - self.start_pos = start_pos - self.type = type - self.value = value - - @property - def end_pos(self): - return self.start_pos[0], self.start_pos[1] + len(self.value) - - def __repr__(self): - """Return a canonical string representation.""" - return "%s(%r, %r)" % (self.__class__.__name__, - self.type, - self.value) - - def __unicode__(self): - """ - Return a pretty string representation. - - This reproduces the input source exactly. - """ - return self.prefix + str(self.value) - - if sys.version_info > (3, 0): - __str__ = __unicode__ - - def leaves(self): - yield self - - def convert(grammar, raw_node): """ Convert raw node information to a Node or Leaf instance. diff --git a/test/test_new_parser.py b/test/test_new_parser.py index d4c9d83f..f6035c1f 100644 --- a/test/test_new_parser.py +++ b/test/test_new_parser.py @@ -5,6 +5,10 @@ from jedi.parser.pgen2 import Driver def test_basic(): + def compare(string): + """Generates the AST object and then regenerates the code.""" + return d.parse_string(string).get_code() == string + #if self.options["print_function"]: # python_grammar = pygram.python_grammar_no_print_statement #else: