forked from VimPlug/jedi
Fixing most of the issues that existed, because of the recent Name.get_definition/Call.name.parent change.
This commit is contained in:
@@ -147,10 +147,8 @@ class BaseDefinition(object):
|
|||||||
return stripped.type()
|
return stripped.type()
|
||||||
if isinstance(stripped, er.InstanceElement):
|
if isinstance(stripped, er.InstanceElement):
|
||||||
stripped = stripped.var
|
stripped = stripped.var
|
||||||
if isinstance(stripped, pr.NamePart):
|
if isinstance(stripped, (pr.Name, pr.NamePart)):
|
||||||
stripped = stripped.parent
|
stripped = stripped.get_definition()
|
||||||
if isinstance(stripped, pr.Name):
|
|
||||||
stripped = stripped.parent
|
|
||||||
if isinstance(stripped, iterable.Array):
|
if isinstance(stripped, iterable.Array):
|
||||||
return 'instance'
|
return 'instance'
|
||||||
string = type(stripped).__name__.lower().replace('wrapper', '')
|
string = type(stripped).__name__.lower().replace('wrapper', '')
|
||||||
@@ -343,8 +341,8 @@ class BaseDefinition(object):
|
|||||||
Follow both statements and imports, as far as possible.
|
Follow both statements and imports, as far as possible.
|
||||||
"""
|
"""
|
||||||
stripped = self._definition
|
stripped = self._definition
|
||||||
if isinstance(stripped, pr.Name):
|
if isinstance(stripped, (pr.Name, pr.NamePart)):
|
||||||
stripped = stripped.parent
|
stripped = stripped.get_definition()
|
||||||
|
|
||||||
# We should probably work in `Finder._names_to_types` here.
|
# We should probably work in `Finder._names_to_types` here.
|
||||||
if isinstance(stripped, pr.Function):
|
if isinstance(stripped, pr.Function):
|
||||||
@@ -404,7 +402,8 @@ class Completion(BaseDefinition):
|
|||||||
provide additional information about a completion.
|
provide additional information about a completion.
|
||||||
"""
|
"""
|
||||||
def __init__(self, evaluator, name, needs_dot, like_name_length, base):
|
def __init__(self, evaluator, name, needs_dot, like_name_length, base):
|
||||||
super(Completion, self).__init__(evaluator, name.parent, name.start_pos)
|
super(Completion, self).__init__(evaluator, name.get_definition(),
|
||||||
|
name.start_pos)
|
||||||
|
|
||||||
self._name = name
|
self._name = name
|
||||||
self._needs_dot = needs_dot
|
self._needs_dot = needs_dot
|
||||||
@@ -482,7 +481,7 @@ class Completion(BaseDefinition):
|
|||||||
@property
|
@property
|
||||||
def description(self):
|
def description(self):
|
||||||
"""Provide a description of the completion object."""
|
"""Provide a description of the completion object."""
|
||||||
parent = self._name.parent
|
parent = self._name.get_definition()
|
||||||
if parent is None:
|
if parent is None:
|
||||||
return ''
|
return ''
|
||||||
t = self.type
|
t = self.type
|
||||||
@@ -649,8 +648,8 @@ class Definition(use_metaclass(CachedMetaClass, BaseDefinition)):
|
|||||||
d = self._definition
|
d = self._definition
|
||||||
if isinstance(d, er.InstanceElement):
|
if isinstance(d, er.InstanceElement):
|
||||||
d = d.var
|
d = d.var
|
||||||
if isinstance(d, pr.Name):
|
if isinstance(d, (pr.Name, pr.NamePart)):
|
||||||
d = d.parent
|
d = d.get_definition()
|
||||||
|
|
||||||
if isinstance(d, compiled.CompiledObject):
|
if isinstance(d, compiled.CompiledObject):
|
||||||
typ = d.type()
|
typ = d.type()
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ class KeywordName(object):
|
|||||||
self.names = [name]
|
self.names = [name]
|
||||||
self.start_pos = start_pos
|
self.start_pos = start_pos
|
||||||
|
|
||||||
|
def get_definition(self):
|
||||||
|
return self.parent
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def end_pos(self):
|
def end_pos(self):
|
||||||
return self.start_pos[0], self.start_pos[1] + len(self.name)
|
return self.start_pos[0], self.start_pos[1] + len(self.name)
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ from inspect import cleandoc
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from jedi import Script, defined_names, __doc__ as jedi_doc
|
from jedi import Script, defined_names, __doc__ as jedi_doc
|
||||||
from jedi.parser import representation as pr
|
|
||||||
from ..helpers import cwd_at
|
from ..helpers import cwd_at
|
||||||
from ..helpers import TestCase
|
from ..helpers import TestCase
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user