forked from VimPlug/jedi
@property now returns Name.type == 'property', fixes muffinmad/anakin-language-server#15
This commit is contained in:
+1
-1
@@ -174,7 +174,7 @@ class BaseName(object):
|
||||
'function'
|
||||
|
||||
Valid values for type are ``module``, ``class``, ``instance``, ``function``,
|
||||
``param``, ``path``, ``keyword`` and ``statement``.
|
||||
``param``, ``path``, ``keyword``, ``property`` and ``statement``.
|
||||
|
||||
"""
|
||||
tree_name = self._name.tree_name
|
||||
|
||||
@@ -37,7 +37,8 @@ py__doc__() Returns the docstring for a value.
|
||||
|
||||
"""
|
||||
from jedi import debug
|
||||
from jedi.parser_utils import get_cached_parent_scope, expr_is_dotted
|
||||
from jedi.parser_utils import get_cached_parent_scope, expr_is_dotted, \
|
||||
function_is_property
|
||||
from jedi.inference.cache import inference_state_method_cache, CachedMetaClass, \
|
||||
inference_state_method_generator_cache
|
||||
from jedi.inference import compiled
|
||||
@@ -72,6 +73,20 @@ class ClassName(TreeNameDefinition):
|
||||
else:
|
||||
yield result_value
|
||||
|
||||
@property
|
||||
def api_type(self):
|
||||
if self.tree_name is not None:
|
||||
definition = self.tree_name.get_definition()
|
||||
if definition.type == 'funcdef':
|
||||
if function_is_property(definition):
|
||||
# This essentially checks if there is an @property before
|
||||
# the function. @property could be something different, but
|
||||
# any programmer that redefines property as something that
|
||||
# is not really a property anymore, should be shot. (i.e.
|
||||
# this is a heuristic).
|
||||
return 'property'
|
||||
return super().api_type
|
||||
|
||||
|
||||
class ClassFilter(ParserTreeFilter):
|
||||
def __init__(self, class_value, node_context=None, until_position=None,
|
||||
|
||||
@@ -316,3 +316,4 @@ def _function_is_x_method(method_name):
|
||||
|
||||
function_is_staticmethod = _function_is_x_method('staticmethod')
|
||||
function_is_classmethod = _function_is_x_method('classmethod')
|
||||
function_is_property = _function_is_x_method('property')
|
||||
|
||||
@@ -384,6 +384,8 @@ def builtins_classmethod(functions, value, arguments):
|
||||
|
||||
|
||||
class PropertyObject(AttributeOverwrite, ValueWrapper):
|
||||
api_type = 'property'
|
||||
|
||||
def __init__(self, property_obj, function):
|
||||
super().__init__(property_obj)
|
||||
self._function = function
|
||||
|
||||
Reference in New Issue
Block a user