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