forked from VimPlug/jedi
changed code for more readability that has been used because of weakrefs
This commit is contained in:
@@ -32,23 +32,29 @@ class BaseOutput(object):
|
|||||||
self.definition = definition
|
self.definition = definition
|
||||||
self.is_keyword = isinstance(definition, keywords.Keyword)
|
self.is_keyword = isinstance(definition, keywords.Keyword)
|
||||||
|
|
||||||
# generate the type
|
|
||||||
self.stripped_definition = self.definition
|
|
||||||
if isinstance(self.definition, evaluate.InstanceElement):
|
|
||||||
self.stripped_definition = self.definition.var
|
|
||||||
self.type = type(self.stripped_definition).__name__
|
|
||||||
|
|
||||||
# generate a path to the definition
|
# generate a path to the definition
|
||||||
self.module_path = str(definition.get_parent_until().path)
|
self.module_path = str(definition.get_parent_until().path)
|
||||||
self.path = []
|
|
||||||
if not isinstance(definition, keywords.Keyword):
|
@property
|
||||||
par = definition
|
def type(self):
|
||||||
|
# generate the type
|
||||||
|
stripped = self.definition
|
||||||
|
if isinstance(self.definition, evaluate.InstanceElement):
|
||||||
|
stripped = self.definition.var
|
||||||
|
self.type = type(stripped).__name__
|
||||||
|
|
||||||
|
@property
|
||||||
|
def path(self):
|
||||||
|
path = []
|
||||||
|
if not isinstance(self.definition, keywords.Keyword):
|
||||||
|
par = self.definition
|
||||||
while par is not None:
|
while par is not None:
|
||||||
try:
|
try:
|
||||||
self.path.insert(0, par.name)
|
path.insert(0, par.name)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
par = par.parent
|
par = par.parent
|
||||||
|
return path
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def module_name(self):
|
def module_name(self):
|
||||||
|
|||||||
@@ -461,12 +461,11 @@ class Builtin(object):
|
|||||||
FunctionType = types.FunctionType
|
FunctionType = types.FunctionType
|
||||||
source = _generate_code(Container, depth=0)
|
source = _generate_code(Container, depth=0)
|
||||||
parser = parsing.PyFuzzyParser(source, None)
|
parser = parsing.PyFuzzyParser(source, None)
|
||||||
# needed for caching (because of weakref)
|
module = parser.module
|
||||||
module = self.magic_func_module = parser.module
|
|
||||||
module.parent = self.scope
|
module.parent = self.scope
|
||||||
typ = evaluate.follow_path(iter(['FunctionType']), module, module)
|
typ = evaluate.follow_path(iter(['FunctionType']), module, module)
|
||||||
|
|
||||||
self._magic_function_scope = s = typ.pop()
|
s = self._magic_function_scope = typ.pop()
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user