1
0
forked from VimPlug/jedi

tried to start introducing the compiled module to the library

This commit is contained in:
Dave Halter
2014-01-09 01:26:51 +01:00
parent 3017e72b86
commit 0cb23dcfa2
3 changed files with 25 additions and 18 deletions

View File

@@ -6,6 +6,7 @@ import re
from jedi._compatibility import builtins as _builtins, is_py3k
from jedi import debug
from jedi.parser.representation import Base
from jedi.cache import underscore_memoization
@@ -13,13 +14,17 @@ from jedi.cache import underscore_memoization
# unbound methods such as pyqtSignals have no __name__
# if not hasattr(func, "__name__"):
class PyObject(object):
class PyObject(Base):
def __init__(self, obj, parent=None, instantiated=False):
self.obj = obj
self.parent = parent
self.instantiated = instantiated
self.doc = inspect.getdoc(obj)
# comply with the parser
self.get_parent_until = lambda: parent
self.start_pos = 0, 0
def __repr__(self):
return '<%s: %s>' % (type(self).__name__, self.obj)
@@ -30,19 +35,25 @@ class PyObject(object):
return _parse_function_doc(self.doc)
def type(self):
if inspect.isclass(self.obj):
return 'class'
elif inspect.ismodule(self.obj):
return 'module'
elif inspect.isbuiltin(self.obj) or inspect.ismethod(self.obj) \
or inspect.ismethoddescriptor(self.obj):
return 'def'
def get_defined_names(self):
# We don't want to execute properties, therefore we have to try to get
# the class
cls = self
if not (inspect.isclass(self.obj) or inspect.ismodule(self.obj)):
if not inspect.isclass(self.obj):
cls = PyObject(self.obj.__class__, self.parent)
for name in dir(cls.obj):
yield PyName(cls, name)
def isinstance(self, *obj):
return isinstance(self, obj)
@property
def name(self):
# might not exist sometimes (raises AttributeError)
@@ -64,7 +75,6 @@ class PyName(object):
def __init__(self, obj, name):
self._obj = obj
self._name = name
self.start_pos = 0, 0 # an illegal start_pos, to make sorting easy.
@property