mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 14:04:26 +08:00
type of NamePart in definition should work.
This commit is contained in:
@@ -518,7 +518,7 @@ class Script(object):
|
||||
names = usages.usages(self._evaluator, definitions, search_name, module)
|
||||
|
||||
for d in set(definitions):
|
||||
if isinstance(d, pr.Module):
|
||||
if isinstance(d, (pr.Module, compiled.CompiledObject)):
|
||||
names.append(usages.Usage(self._evaluator, d, d))
|
||||
elif isinstance(d, er.Instance):
|
||||
# Instances can be ignored, because they have been created by
|
||||
|
||||
@@ -137,6 +137,8 @@ class BaseDefinition(object):
|
||||
return stripped.type()
|
||||
if isinstance(stripped, er.InstanceElement):
|
||||
stripped = stripped.var
|
||||
if isinstance(stripped, pr.NamePart):
|
||||
stripped = stripped.parent
|
||||
if isinstance(stripped, pr.Name):
|
||||
stripped = stripped.parent
|
||||
return type(stripped).__name__.lower()
|
||||
|
||||
@@ -9,10 +9,10 @@ from jedi.evaluate import helpers
|
||||
class Usage(classes.Definition):
|
||||
"""TODO: document this"""
|
||||
def __init__(self, evaluator, name_part, scope):
|
||||
super(Usage, self).__init__(evaluator, scope)
|
||||
super(Usage, self).__init__(evaluator, name_part)
|
||||
self._start_pos = name_part.start_pos
|
||||
self.text = unicode(name_part)
|
||||
self.end_pos = name_part.end_pos
|
||||
#self.end_pos = name_part.end_pos
|
||||
|
||||
@property
|
||||
def description(self):
|
||||
|
||||
@@ -1395,6 +1395,9 @@ class NamePart(object):
|
||||
def __hash__(self):
|
||||
return hash(self.string)
|
||||
|
||||
def get_parent_until(self, *args, **kwargs):
|
||||
return self.parent.get_parent_until(*args, **kwargs)
|
||||
|
||||
@property
|
||||
def start_pos(self):
|
||||
offset = self.parent._sub_module.line_offset
|
||||
|
||||
@@ -255,7 +255,7 @@ check(DynamicParam())
|
||||
# Compiled Objects
|
||||
# -----------------
|
||||
|
||||
import sys
|
||||
import _sre
|
||||
|
||||
#< 0 (-3,7), (0,0)
|
||||
sys
|
||||
#< 0 (-3,7), (0,0), ('_sre', None, None)
|
||||
_sre
|
||||
|
||||
@@ -221,8 +221,10 @@ class IntegrationTestCase(object):
|
||||
# this means that there is a module specified
|
||||
wanted.append(pos_tup)
|
||||
else:
|
||||
wanted.append((self.module_name, self.line_nr + pos_tup[0],
|
||||
pos_tup[1]))
|
||||
line = pos_tup[0]
|
||||
if pos_tup[0] is not None:
|
||||
line += self.line_nr
|
||||
wanted.append((self.module_name, line, pos_tup[1]))
|
||||
|
||||
return compare_cb(self, compare, sorted(wanted))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user