1
0
forked from VimPlug/jedi

moved parsing.Simple.module to _sub_module

This commit is contained in:
David Halter
2013-02-17 00:30:44 +04:30
parent 1366f5fa61
commit 79216f189f
3 changed files with 12 additions and 12 deletions

View File

@@ -517,11 +517,11 @@ class Execution(Executable):
new_param.parent = parent new_param.parent = parent
# create an Array (-> needed for *args/**kwargs tuples/dicts) # create an Array (-> needed for *args/**kwargs tuples/dicts)
arr = pr.Array(self.module, start_pos, array_type, parent) arr = pr.Array(self._sub_module, start_pos, array_type, parent)
arr.values = values arr.values = values
key_stmts = [] key_stmts = []
for key in keys: for key in keys:
stmt = pr.Statement(self.module, 'XXX code', [], [], [], [], stmt = pr.Statement(self._sub_module, 'XXX code', [], [], [], [],
start_pos, None) start_pos, None)
stmt._commands = [key] stmt._commands = [key]
key_stmts.append(stmt) key_stmts.append(stmt)
@@ -709,7 +709,7 @@ class Execution(Executable):
raise common.MultiLevelAttributeError(sys.exc_info()) raise common.MultiLevelAttributeError(sys.exc_info())
def __getattr__(self, name): def __getattr__(self, name):
if name not in ['start_pos', 'end_pos', 'imports', 'module']: if name not in ['start_pos', 'end_pos', 'imports', '_sub_module']:
raise AttributeError('Tried to access %s: %s. Why?' % (name, self)) raise AttributeError('Tried to access %s: %s. Why?' % (name, self))
return getattr(self.base, name) return getattr(self.base, name)

View File

@@ -39,7 +39,7 @@ def fast_parent_copy(obj):
setattr(new_obj, key, new_elements[value]) setattr(new_obj, key, new_elements[value])
except KeyError: except KeyError:
pass pass
elif key in ['parent_function', 'use_as_parent', 'module']: elif key in ['parent_function', 'use_as_parent', '_sub_module']:
continue continue
elif isinstance(value, list): elif isinstance(value, list):
setattr(new_obj, key, list_rec(value)) setattr(new_obj, key, list_rec(value))

View File

@@ -49,10 +49,10 @@ class Simple(Base):
The super class for Scope, Import, Name and Statement. Every object in The super class for Scope, Import, Name and Statement. Every object in
the parser tree inherits from this class. the parser tree inherits from this class.
""" """
__slots__ = ('parent', 'module', '_start_pos', 'use_as_parent', '_end_pos') __slots__ = ('parent', '_sub_module', '_start_pos', 'use_as_parent', '_end_pos')
def __init__(self, module, start_pos, end_pos=(None, None)): def __init__(self, module, start_pos, end_pos=(None, None)):
self.module = module self._sub_module = module
self._start_pos = start_pos self._start_pos = start_pos
self._end_pos = end_pos self._end_pos = end_pos
@@ -62,7 +62,7 @@ class Simple(Base):
@property @property
def start_pos(self): def start_pos(self):
return self.module.line_offset + self._start_pos[0], self._start_pos[1] return self._sub_module.line_offset + self._start_pos[0], self._start_pos[1]
@start_pos.setter @start_pos.setter
def start_pos(self, value): def start_pos(self, value):
@@ -72,7 +72,7 @@ class Simple(Base):
def end_pos(self): def end_pos(self):
if None in self._end_pos: if None in self._end_pos:
return self._end_pos return self._end_pos
return self.module.line_offset + self._end_pos[0], self._end_pos[1] return self._sub_module.line_offset + self._end_pos[0], self._end_pos[1]
@end_pos.setter @end_pos.setter
def end_pos(self, value): def end_pos(self, value):
@@ -621,7 +621,7 @@ class Import(Simple):
return [self.alias] return [self.alias]
if len(self.namespace) > 1: if len(self.namespace) > 1:
o = self.namespace o = self.namespace
n = Name(self.module, [(o.names[0], o.start_pos)], o.start_pos, n = Name(self._sub_module, [(o.names[0], o.start_pos)], o.start_pos,
o.end_pos, parent=o.parent) o.end_pos, parent=o.parent)
return [n] return [n]
else: else:
@@ -771,7 +771,7 @@ class Statement(Simple):
and not tok in ['>=', '<=', '==', '!='] and not tok in ['>=', '<=', '==', '!=']
def parse_array(token_iterator, array_type, start_pos, add_el=None): def parse_array(token_iterator, array_type, start_pos, add_el=None):
arr = Array(self.module, start_pos, array_type, self) arr = Array(self._sub_module, start_pos, array_type, self)
if add_el is not None: if add_el is not None:
arr.add_statement(add_el) arr.add_statement(add_el)
@@ -841,7 +841,7 @@ class Statement(Simple):
if not token_list: if not token_list:
return None, tok return None, tok
statement = Statement(self.module, "XXX" + self.code, [], [], [], statement = Statement(self._sub_module, "XXX" + self.code, [], [], [],
token_list, start_pos, end_pos) token_list, start_pos, end_pos)
statement.parent = self.parent statement.parent = self.parent
return statement, tok return statement, tok
@@ -883,7 +883,7 @@ class Statement(Simple):
elif token_type == tokenize.NUMBER: elif token_type == tokenize.NUMBER:
c_type = Call.NUMBER c_type = Call.NUMBER
call = Call(self.module, tok, c_type, start_pos, self) call = Call(self._sub_module, tok, c_type, start_pos, self)
if is_chain: if is_chain:
result[-1].set_next(call) result[-1].set_next(call)
else: else: