forked from VimPlug/jedi
replaced builtin with compiled in all modules except imports
This commit is contained in:
@@ -27,7 +27,7 @@ from jedi import keywords
|
|||||||
from jedi.api import classes
|
from jedi.api import classes
|
||||||
from jedi.evaluate import Evaluator, filter_private_variable
|
from jedi.evaluate import Evaluator, filter_private_variable
|
||||||
from jedi.evaluate import representation as er
|
from jedi.evaluate import representation as er
|
||||||
from jedi.evaluate import builtin
|
from jedi.evaluate import compiled
|
||||||
from jedi.evaluate import imports
|
from jedi.evaluate import imports
|
||||||
from jedi.evaluate import helpers
|
from jedi.evaluate import helpers
|
||||||
|
|
||||||
@@ -137,8 +137,8 @@ class Script(object):
|
|||||||
path, dot, like = self._get_completion_parts()
|
path, dot, like = self._get_completion_parts()
|
||||||
|
|
||||||
user_stmt = self._user_stmt(True)
|
user_stmt = self._user_stmt(True)
|
||||||
bs = builtin.Builtin.scope
|
b = compiled.builtin
|
||||||
completions = get_completions(user_stmt, bs)
|
completions = get_completions(user_stmt, b)
|
||||||
|
|
||||||
if not dot:
|
if not dot:
|
||||||
# add named params
|
# add named params
|
||||||
@@ -149,8 +149,7 @@ class Script(object):
|
|||||||
|
|
||||||
if not path and not isinstance(user_stmt, pr.Import):
|
if not path and not isinstance(user_stmt, pr.Import):
|
||||||
# add keywords
|
# add keywords
|
||||||
completions += ((k, bs) for k in keywords.keyword_names(
|
completions += ((k, b) for k in keywords.keyword_names(all=True))
|
||||||
all=True))
|
|
||||||
|
|
||||||
needs_dot = not dot and path
|
needs_dot = not dot and path
|
||||||
|
|
||||||
|
|||||||
@@ -71,6 +71,10 @@ class PyObject(Base):
|
|||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def get_self_attributes(self):
|
||||||
|
# Instance compatibility
|
||||||
|
return []
|
||||||
|
|
||||||
|
|
||||||
class PyName(object):
|
class PyName(object):
|
||||||
def __init__(self, obj, name):
|
def __init__(self, obj, name):
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ from jedi import debug
|
|||||||
from jedi import settings
|
from jedi import settings
|
||||||
from jedi._compatibility import use_metaclass, is_py3k
|
from jedi._compatibility import use_metaclass, is_py3k
|
||||||
from jedi.parser import representation as pr
|
from jedi.parser import representation as pr
|
||||||
from jedi.evaluate import builtin
|
from jedi.evaluate import compiled
|
||||||
from jedi.evaluate import helpers
|
from jedi.evaluate import helpers
|
||||||
from jedi.evaluate.cache import CachedMetaClass, memoize_default
|
from jedi.evaluate.cache import CachedMetaClass, memoize_default
|
||||||
|
|
||||||
@@ -27,12 +27,12 @@ class Generator(use_metaclass(CachedMetaClass, pr.Base)):
|
|||||||
none_pos = (0, 0)
|
none_pos = (0, 0)
|
||||||
executes_generator = ('__next__', 'send')
|
executes_generator = ('__next__', 'send')
|
||||||
for n in ('close', 'throw') + executes_generator:
|
for n in ('close', 'throw') + executes_generator:
|
||||||
name = pr.Name(builtin.Builtin.scope, [(n, none_pos)],
|
name = pr.Name(compiled.builtin, [(n, none_pos)],
|
||||||
none_pos, none_pos)
|
none_pos, none_pos)
|
||||||
if n in executes_generator:
|
if n in executes_generator:
|
||||||
name.parent = self
|
name.parent = self
|
||||||
else:
|
else:
|
||||||
name.parent = builtin.Builtin.scope
|
name.parent = compiled.builtin
|
||||||
names.append(name)
|
names.append(name)
|
||||||
debug.dbg('generator names', names)
|
debug.dbg('generator names', names)
|
||||||
return names
|
return names
|
||||||
@@ -130,17 +130,17 @@ class Array(use_metaclass(CachedMetaClass, pr.Base)):
|
|||||||
It returns e.g. for a list: append, pop, ...
|
It returns e.g. for a list: append, pop, ...
|
||||||
"""
|
"""
|
||||||
# `array.type` is a string with the type, e.g. 'list'.
|
# `array.type` is a string with the type, e.g. 'list'.
|
||||||
scope = self._evaluator.find_types(builtin.Builtin.scope, self._array.type)[0]
|
scope = self._evaluator.find_types(compiled.builtin, self._array.type)[0]
|
||||||
scope = self._evaluator.execute(scope)[0] # builtins only have one class
|
scope = self._evaluator.execute(scope)[0] # builtins only have one class
|
||||||
names = scope.get_defined_names()
|
names = scope.get_defined_names()
|
||||||
return [ArrayMethod(n) for n in names]
|
return [ArrayMethod(n) for n in names]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def parent(self):
|
def parent(self):
|
||||||
return builtin.Builtin.scope
|
return compiled.builtin
|
||||||
|
|
||||||
def get_parent_until(self):
|
def get_parent_until(self):
|
||||||
return builtin.Builtin.scope
|
return compiled.builtin
|
||||||
|
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
if name not in ['type', 'start_pos', 'get_only_subelement', 'parent',
|
if name not in ['type', 'start_pos', 'get_only_subelement', 'parent',
|
||||||
@@ -177,7 +177,7 @@ class ArrayMethod(object):
|
|||||||
return getattr(self.name, name)
|
return getattr(self.name, name)
|
||||||
|
|
||||||
def get_parent_until(self):
|
def get_parent_until(self):
|
||||||
return builtin.Builtin.scope
|
return compiled.builtin
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<%s of %s>" % (type(self).__name__, self.name)
|
return "<%s of %s>" % (type(self).__name__, self.name)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import copy
|
|||||||
|
|
||||||
from jedi.parser import representation as pr
|
from jedi.parser import representation as pr
|
||||||
from jedi.evaluate import iterable
|
from jedi.evaluate import iterable
|
||||||
from jedi.evaluate import builtin
|
from jedi.evaluate import compiled
|
||||||
from jedi.evaluate import common
|
from jedi.evaluate import common
|
||||||
|
|
||||||
|
|
||||||
@@ -140,8 +140,7 @@ def _var_args_iterator(evaluator, var_args):
|
|||||||
continue
|
continue
|
||||||
old = stmt
|
old = stmt
|
||||||
# generate a statement if it's not already one.
|
# generate a statement if it's not already one.
|
||||||
module = builtin.Builtin.scope
|
stmt = pr.Statement(compiled.builtin, [], (0, 0), None)
|
||||||
stmt = pr.Statement(module, [], (0, 0), None)
|
|
||||||
stmt._expression_list = [old]
|
stmt._expression_list = [old]
|
||||||
|
|
||||||
# *args
|
# *args
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ calls.
|
|||||||
from jedi.parser import representation as pr
|
from jedi.parser import representation as pr
|
||||||
from jedi import debug
|
from jedi import debug
|
||||||
from jedi import settings
|
from jedi import settings
|
||||||
from jedi.evaluate import builtin
|
from jedi.evaluate import compiled
|
||||||
from jedi.evaluate import iterable
|
from jedi.evaluate import iterable
|
||||||
|
|
||||||
|
|
||||||
@@ -82,7 +82,7 @@ class _RecursionNode(object):
|
|||||||
# The same's true for the builtins, because the builtins are really
|
# The same's true for the builtins, because the builtins are really
|
||||||
# simple.
|
# simple.
|
||||||
self.is_ignored = isinstance(stmt, pr.Param) \
|
self.is_ignored = isinstance(stmt, pr.Param) \
|
||||||
or (self.script == builtin.Builtin.scope)
|
or (self.script == compiled.builtin)
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
if not other:
|
if not other:
|
||||||
@@ -148,7 +148,7 @@ class ExecutionRecursionDetector(object):
|
|||||||
if isinstance(execution.base, (iterable.Array, iterable.Generator)):
|
if isinstance(execution.base, (iterable.Array, iterable.Generator)):
|
||||||
return False
|
return False
|
||||||
module = execution.get_parent_until()
|
module = execution.get_parent_until()
|
||||||
if evaluate_generator or module == builtin.Builtin.scope:
|
if evaluate_generator or module == compiled.builtin:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if in_par_execution_funcs:
|
if in_par_execution_funcs:
|
||||||
|
|||||||
@@ -141,8 +141,7 @@ class Instance(use_metaclass(CachedMetaClass, Executable)):
|
|||||||
"""
|
"""
|
||||||
names = self.get_self_attributes()
|
names = self.get_self_attributes()
|
||||||
|
|
||||||
class_names = self.base.instance_names()
|
for var in self.base.instance_names():
|
||||||
for var in class_names:
|
|
||||||
names.append(InstanceElement(self._evaluator, self, var, True))
|
names.append(InstanceElement(self._evaluator, self, var, True))
|
||||||
return names
|
return names
|
||||||
|
|
||||||
@@ -154,8 +153,7 @@ class Instance(use_metaclass(CachedMetaClass, Executable)):
|
|||||||
yield self, self.get_self_attributes()
|
yield self, self.get_self_attributes()
|
||||||
|
|
||||||
names = []
|
names = []
|
||||||
class_names = self.base.instance_names()
|
for var in self.base.instance_names():
|
||||||
for var in class_names:
|
|
||||||
names.append(InstanceElement(self._evaluator, self, var, True))
|
names.append(InstanceElement(self._evaluator, self, var, True))
|
||||||
yield self, names
|
yield self, names
|
||||||
|
|
||||||
@@ -263,6 +261,7 @@ class Class(use_metaclass(CachedMetaClass, pr.IsScope)):
|
|||||||
|
|
||||||
@memoize_default(default=())
|
@memoize_default(default=())
|
||||||
def instance_names(self):
|
def instance_names(self):
|
||||||
|
# TODO REMOVE instance_names
|
||||||
def in_iterable(name, iterable):
|
def in_iterable(name, iterable):
|
||||||
""" checks if the name is in the variable 'iterable'. """
|
""" checks if the name is in the variable 'iterable'. """
|
||||||
for i in iterable:
|
for i in iterable:
|
||||||
@@ -277,6 +276,9 @@ class Class(use_metaclass(CachedMetaClass, pr.IsScope)):
|
|||||||
# TODO mro!
|
# TODO mro!
|
||||||
for cls in self.get_super_classes():
|
for cls in self.get_super_classes():
|
||||||
# Get the inherited names.
|
# Get the inherited names.
|
||||||
|
if isinstance(cls, compiled.PyObject):
|
||||||
|
super_result += cls.get_defined_names()
|
||||||
|
else:
|
||||||
for i in cls.instance_names():
|
for i in cls.instance_names():
|
||||||
if not in_iterable(i, result):
|
if not in_iterable(i, result):
|
||||||
super_result.append(i)
|
super_result.append(i)
|
||||||
@@ -287,7 +289,7 @@ class Class(use_metaclass(CachedMetaClass, pr.IsScope)):
|
|||||||
def get_defined_names(self):
|
def get_defined_names(self):
|
||||||
result = self.instance_names()
|
result = self.instance_names()
|
||||||
type_cls = self._evaluator.find_types(compiled.builtin, 'type')[0]
|
type_cls = self._evaluator.find_types(compiled.builtin, 'type')[0]
|
||||||
return result + type_cls.base.get_defined_names()
|
return result + list(type_cls.get_defined_names())
|
||||||
|
|
||||||
def get_subscope_by_name(self, name):
|
def get_subscope_by_name(self, name):
|
||||||
for sub in reversed(self.subscopes):
|
for sub in reversed(self.subscopes):
|
||||||
@@ -374,10 +376,10 @@ class Function(use_metaclass(CachedMetaClass, pr.IsScope)):
|
|||||||
return decorated_func
|
return decorated_func
|
||||||
|
|
||||||
def get_magic_method_names(self):
|
def get_magic_method_names(self):
|
||||||
return builtin.Builtin.magic_function_scope(self._evaluator).get_defined_names()
|
return compiled.magic_function_scope(self._evaluator).get_defined_names()
|
||||||
|
|
||||||
def get_magic_method_scope(self):
|
def get_magic_method_scope(self):
|
||||||
return builtin.Builtin.magic_function_scope(self._evaluator)
|
return compiled.magic_function_scope(self._evaluator)
|
||||||
|
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
return getattr(self.base_func, name)
|
return getattr(self.base_func, name)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ Implementations of standard library functions, because it's not possible to
|
|||||||
understand them with Jedi.
|
understand them with Jedi.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from jedi.evaluate import builtin
|
from jedi.evaluate import compiled
|
||||||
from jedi.evaluate import representation as er
|
from jedi.evaluate import representation as er
|
||||||
from jedi.evaluate import iterable
|
from jedi.evaluate import iterable
|
||||||
from jedi.parser import representation as pr
|
from jedi.parser import representation as pr
|
||||||
@@ -17,7 +17,7 @@ class NotInStdLib(LookupError):
|
|||||||
def execute(evaluator, obj, params):
|
def execute(evaluator, obj, params):
|
||||||
if not isinstance(obj, (iterable.Generator, iterable.Array)):
|
if not isinstance(obj, (iterable.Generator, iterable.Array)):
|
||||||
obj_name = str(obj.name)
|
obj_name = str(obj.name)
|
||||||
if obj.parent == builtin.Builtin.scope:
|
if obj.parent == compiled.builtin:
|
||||||
# for now we just support builtin functions.
|
# for now we just support builtin functions.
|
||||||
try:
|
try:
|
||||||
return _implemented['builtins'][obj_name](evaluator, obj, params)
|
return _implemented['builtins'][obj_name](evaluator, obj, params)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import keyword
|
|||||||
from jedi._compatibility import is_py3k
|
from jedi._compatibility import is_py3k
|
||||||
from jedi.parser import representation as pr
|
from jedi.parser import representation as pr
|
||||||
from jedi import common
|
from jedi import common
|
||||||
from jedi.evaluate import builtin
|
from jedi.evaluate import compiled
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from pydoc_data import topics as pydoc_topics
|
from pydoc_data import topics as pydoc_topics
|
||||||
@@ -43,7 +43,7 @@ class Keyword(object):
|
|||||||
def __init__(self, name, pos):
|
def __init__(self, name, pos):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.start_pos = pos
|
self.start_pos = pos
|
||||||
self.parent = builtin.Builtin.scope
|
self.parent = compiled.builtin
|
||||||
|
|
||||||
def get_parent_until(self):
|
def get_parent_until(self):
|
||||||
return self.parent
|
return self.parent
|
||||||
|
|||||||
Reference in New Issue
Block a user