1
0
forked from VimPlug/jedi

Function is starting to work.

This commit is contained in:
Dave Halter
2014-10-08 17:58:02 +02:00
parent 585e92ac9f
commit 6bb88ddd85
3 changed files with 33 additions and 26 deletions

View File

@@ -46,9 +46,9 @@ del python_grammar_no_print_statement.keywords["print"]
from jedi.parser.representation import ExprStmt, Class, Function
_ast_mapping = {
'simple_stmt': ExprStmt,
#'simple_stmt': ExprStmt,
'classdef': Class,
'funcdef': Function
'funcdef': Function,
}
ast_mapping = dict((getattr(python_symbols, k), v) for k, v in _ast_mapping.items())
@@ -79,7 +79,6 @@ class Base(object):
# Default values for instance variables
type = None # int: token number (< 256) or symbol number (>= 256)
parent = None # Parent node pointer, or None
children = () # Tuple of subnodes
def leaves(self):
for child in self.children:
@@ -134,6 +133,14 @@ class Node(Base):
return ""
return self.children[0].prefix
@property
def start_pos(self):
return self.children[0].start_pos
@property
def end_pos(self):
return self.children[-1].end_pos
@prefix.setter
def prefix(self, prefix):
if self.children:
@@ -172,6 +179,10 @@ class Leaf(Base):
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__,