forked from VimPlug/jedi
again Definition/Usage merging
This commit is contained in:
@@ -10,6 +10,7 @@ from jedi._compatibility import next, unicode, use_metaclass
|
||||
from jedi import settings
|
||||
from jedi import common
|
||||
from jedi.parser import representation as pr
|
||||
from jedi.cache import underscore_memoization
|
||||
from jedi.evaluate.cache import memoize_default, CachedMetaClass
|
||||
from jedi.evaluate import representation as er
|
||||
from jedi.evaluate import iterable
|
||||
@@ -529,6 +530,7 @@ class Definition(use_metaclass(CachedMetaClass, BaseDefinition)):
|
||||
super(Definition, self).__init__(evaluator, definition, definition.start_pos)
|
||||
|
||||
@property
|
||||
@underscore_memoization
|
||||
def name(self):
|
||||
"""
|
||||
Name of variable/function/class/module.
|
||||
@@ -568,6 +570,10 @@ class Definition(use_metaclass(CachedMetaClass, BaseDefinition)):
|
||||
except IndexError:
|
||||
pass
|
||||
return None
|
||||
elif isinstance(d, iterable.Generator):
|
||||
return None
|
||||
elif isinstance(d, pr.NamePart):
|
||||
name = d
|
||||
return unicode(name)
|
||||
|
||||
@property
|
||||
@@ -649,6 +655,14 @@ class Definition(use_metaclass(CachedMetaClass, BaseDefinition)):
|
||||
iterable = list(iterable)
|
||||
return list(chain.from_iterable(iterable))
|
||||
|
||||
def __eq__(self, other):
|
||||
return self._start_pos == other._start_pos \
|
||||
and self.module_path == other.module_path \
|
||||
and self.name == other.name
|
||||
|
||||
def __hash__(self):
|
||||
return hash((self._start_pos, self.module_path, self.name))
|
||||
|
||||
|
||||
class CallSignature(Definition):
|
||||
"""
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
from jedi._compatibility import unicode
|
||||
from jedi import common
|
||||
from jedi.api import classes
|
||||
from jedi.parser import representation as pr
|
||||
@@ -11,13 +10,8 @@ class Usage(classes.Definition):
|
||||
def __init__(self, evaluator, name_part, 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
|
||||
|
||||
@property
|
||||
def description(self):
|
||||
return "%s@%s,%s" % (self.text, self.line, self.column)
|
||||
|
||||
def __eq__(self, other):
|
||||
return self._start_pos == other._start_pos \
|
||||
and self.module_path == other.module_path
|
||||
|
||||
@@ -89,7 +89,7 @@ def _rename(names, replace_str):
|
||||
nr, indent = name.line, name.column
|
||||
line = new_lines[nr - 1]
|
||||
new_lines[nr - 1] = line[:indent] + replace_str + \
|
||||
line[indent + len(name.text):]
|
||||
line[indent + len(name.name):]
|
||||
process(current_path, old_lines, new_lines)
|
||||
return dct
|
||||
|
||||
|
||||
Reference in New Issue
Block a user