mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-09 23:34:45 +08:00
added fullname for #61
This commit is contained in:
@@ -10,6 +10,13 @@ import keywords
|
|||||||
|
|
||||||
|
|
||||||
class BaseOutput(object):
|
class BaseOutput(object):
|
||||||
|
_mapping = {'posixpath': 'os.path',
|
||||||
|
'riscospath': 'os.path',
|
||||||
|
'ntpath': 'os.path',
|
||||||
|
'os2emxpath': 'os.path',
|
||||||
|
'_io': 'io'
|
||||||
|
}
|
||||||
|
|
||||||
def __init__(self, definition, start_pos):
|
def __init__(self, definition, start_pos):
|
||||||
self.start_pos = start_pos
|
self.start_pos = start_pos
|
||||||
self.definition = definition
|
self.definition = definition
|
||||||
@@ -24,13 +31,14 @@ class BaseOutput(object):
|
|||||||
# 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 = []
|
self.path = []
|
||||||
par = definition
|
if not isinstance(definition, keywords.Keyword):
|
||||||
while par is not None:
|
par = definition
|
||||||
if not par.isinstance(
|
while par is not None:
|
||||||
parsing.Flow, parsing.Statement, parsing.Import,
|
if not par.isinstance(
|
||||||
evaluate.Array, parsing.Name):
|
parsing.Flow, parsing.Statement, parsing.Import,
|
||||||
self.path.insert(0, par.name)
|
evaluate.Array, parsing.Name):
|
||||||
par = par.parent()
|
self.path.insert(0, par.name)
|
||||||
|
par = par.parent()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def module_name(self):
|
def module_name(self):
|
||||||
@@ -70,6 +78,19 @@ class BaseOutput(object):
|
|||||||
def description(self):
|
def description(self):
|
||||||
raise NotImplementedError('Base Class')
|
raise NotImplementedError('Base Class')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def full_name(self):
|
||||||
|
"""
|
||||||
|
Returns the path to a certain class/function, see #61.
|
||||||
|
"""
|
||||||
|
path = [str(p) for p in self.path]
|
||||||
|
# TODO add further checks, the mapping should only occur on stdlib.
|
||||||
|
try:
|
||||||
|
path[0] = self._mapping[path[0]]
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
return '.'.join(path)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<%s %s>" % (type(self).__name__, self.description)
|
return "<%s %s>" % (type(self).__name__, self.description)
|
||||||
|
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ def func(a_param):
|
|||||||
#? []
|
#? []
|
||||||
a_param.
|
a_param.
|
||||||
|
|
||||||
|
from os import path
|
||||||
# -----------------
|
# -----------------
|
||||||
# class
|
# class
|
||||||
# -----------------
|
# -----------------
|
||||||
|
|||||||
@@ -229,6 +229,11 @@ class TestRegression(Base):
|
|||||||
assert 'P_NOWAIT' in [i.word for i in s]
|
assert 'P_NOWAIT' in [i.word for i in s]
|
||||||
|
|
||||||
|
|
||||||
|
class TestFeature(Base):
|
||||||
|
def test_full_name(self):
|
||||||
|
""" feature request #61"""
|
||||||
|
assert self.complete('import os; os.path.join')[0].full_name == 'os.path.join'
|
||||||
|
|
||||||
class TestSpeed(Base):
|
class TestSpeed(Base):
|
||||||
def _check_speed(time_per_run, number=10):
|
def _check_speed(time_per_run, number=10):
|
||||||
""" Speed checks should typically be very tolerant. Some machines are
|
""" Speed checks should typically be very tolerant. Some machines are
|
||||||
|
|||||||
Reference in New Issue
Block a user