mirror of
https://github.com/davidhalter/jedi.git
synced 2026-01-18 01:45:02 +08:00
Merge branch 'dev' of github.com:davidhalter/jedi into dev
This commit is contained in:
@@ -554,6 +554,8 @@ class CallDef(object):
|
||||
if isinstance(self._executable, er.InstanceElement):
|
||||
return self._executable.params[1:]
|
||||
return self._executable.params
|
||||
elif self._executable.isinstance(er.compiled.CompiledObject):
|
||||
return self._executable.params
|
||||
else:
|
||||
try:
|
||||
sub = self._executable.get_subscope_by_name('__init__')
|
||||
|
||||
@@ -11,6 +11,9 @@ from jedi import debug
|
||||
from jedi.parser.representation import Base
|
||||
from jedi.cache import underscore_memoization
|
||||
from jedi.evaluate.sys_path import get_sys_path
|
||||
from jedi.parser.representation import Param
|
||||
from jedi.parser.representation import SubModule
|
||||
from jedi.evaluate.helpers import FakeName
|
||||
from . import fake
|
||||
|
||||
|
||||
@@ -20,6 +23,20 @@ class CompiledObject(Base):
|
||||
asserts = []
|
||||
path = None # modules have this attribute - set it to None.
|
||||
|
||||
@property
|
||||
def params(self):
|
||||
params_str, ret = self._parse_function_doc()
|
||||
tokens = params_str.split(',')
|
||||
params = []
|
||||
module = SubModule(self.get_parent_until().name)
|
||||
# it seems like start_pos/end_pos is always (0, 0) for a compiled
|
||||
# object
|
||||
start_pos, end_pos = (0, 0), (0, 0)
|
||||
for p in tokens:
|
||||
params.append(Param(module, [FakeName(p.strip())], start_pos,
|
||||
end_pos))
|
||||
return params
|
||||
|
||||
def __init__(self, obj, parent=None):
|
||||
self.obj = obj
|
||||
self.parent = parent
|
||||
|
||||
@@ -10,10 +10,33 @@ from .helpers import cwd_at
|
||||
|
||||
|
||||
@cwd_at('test/extensions')
|
||||
def test_compiled():
|
||||
def test_completions():
|
||||
if platform.architecture()[0] == '64bit':
|
||||
package_name = "compiled%s%s" % sys.version_info[:2]
|
||||
sys.path.insert(0, os.getcwd())
|
||||
if os.path.exists(package_name):
|
||||
s = jedi.Script("from %s import compiled; compiled." % package_name)
|
||||
assert len(s.completions()) >= 2
|
||||
|
||||
|
||||
@cwd_at('test/extensions')
|
||||
def test_call_signatures_extension():
|
||||
# with a cython extension
|
||||
if platform.architecture()[0] == '64bit':
|
||||
package_name = "compiled%s%s" % sys.version_info[:2]
|
||||
sys.path.insert(0, os.getcwd())
|
||||
if os.path.exists(package_name):
|
||||
s = jedi.Script("from %s import compiled; compiled.Foo(" %
|
||||
package_name)
|
||||
defs = s.call_signatures()
|
||||
for call_def in defs:
|
||||
for param in call_def.params:
|
||||
pass
|
||||
|
||||
|
||||
def test_call_signatures_stdlib():
|
||||
code = "import math; math.cos("
|
||||
s = jedi.Script(code)
|
||||
defs = s.call_signatures()
|
||||
for call_def in defs:
|
||||
assert len(call_def.params) == 1
|
||||
|
||||
Reference in New Issue
Block a user