1
0
forked from VimPlug/jedi

clean up parse_dot_name and other small things

This commit is contained in:
Dave Halter
2014-03-05 22:46:11 +01:00
parent 1f7e4ca637
commit 66a488b911
3 changed files with 7 additions and 16 deletions

View File

@@ -23,6 +23,11 @@ class CompiledObject(Base):
asserts = [] asserts = []
path = None # modules have this attribute - set it to None. path = None # modules have this attribute - set it to None.
def __init__(self, obj, parent=None):
self.obj = obj
self.parent = parent
self.doc = inspect.getdoc(obj)
@property @property
def params(self): def params(self):
params_str, ret = self._parse_function_doc() params_str, ret = self._parse_function_doc()
@@ -37,18 +42,9 @@ class CompiledObject(Base):
end_pos)) end_pos))
return params return params
def __init__(self, obj, parent=None):
self.obj = obj
self.parent = parent
self.doc = inspect.getdoc(obj)
def __repr__(self): def __repr__(self):
return '<%s: %s>' % (type(self).__name__, repr(self.obj)) return '<%s: %s>' % (type(self).__name__, repr(self.obj))
def get_parent_until(self, *args, **kwargs):
# compiled modules only use functions and classes/methods (2 levels)
return getattr(self.parent, 'parent', self.parent) or self.parent or self
@underscore_memoization @underscore_memoization
def _parse_function_doc(self): def _parse_function_doc(self):
if self.doc is None: if self.doc is None:

View File

@@ -108,15 +108,9 @@ class Parser(object):
self.module.temp_used_names.append(el[0]) self.module.temp_used_names.append(el[0])
names = [] names = []
if pre_used_token is None: tok = next(self._gen) if pre_used_token is None else pre_used_token
tok = next(self._gen)
if tok.type != tokenize.NAME and tok.string != '*':
return [], tok # TODO the fuck, why []?
else:
tok = pre_used_token
if tok.type != tokenize.NAME and tok.string != '*': if tok.type != tokenize.NAME and tok.string != '*':
# token maybe a name or star
return None, tok return None, tok
first_pos = tok.start_pos first_pos = tok.start_pos

View File

@@ -1473,6 +1473,7 @@ class Operator(Base):
__slots__ = ('string', '_line', '_column') __slots__ = ('string', '_line', '_column')
def __init__(self, string, start_pos): def __init__(self, string, start_pos):
# TODO needs module param
self.string = string self.string = string
self._line = start_pos[0] self._line = start_pos[0]
self._column = start_pos[1] self._column = start_pos[1]