Add Result.lineno and Result.col_offset
This commit is contained in:
parent
844256b99b
commit
5ffbb4b0eb
@ -180,6 +180,22 @@ class Result(object):
|
||||
self.__used_expr = False
|
||||
self._expr = value
|
||||
|
||||
@property
|
||||
def lineno(self):
|
||||
if self._expr is not None:
|
||||
return self._expr.lineno
|
||||
if self.stmts:
|
||||
return self.stmts[-1].lineno
|
||||
return None
|
||||
|
||||
@property
|
||||
def col_offset(self):
|
||||
if self._expr is not None:
|
||||
return self._expr.col_offset
|
||||
if self.stmts:
|
||||
return self.stmts[-1].col_offset
|
||||
return None
|
||||
|
||||
def add_imports(self, mod, imports):
|
||||
"""Autoimport `imports` from `mod`"""
|
||||
self.imports[mod].update(imports)
|
||||
|
Loading…
Reference in New Issue
Block a user