1
0
forked from VimPlug/jedi

Delete more unused code.

This commit is contained in:
Dave Halter
2016-12-17 18:00:54 +01:00
parent 9cbfb76eb5
commit 81e9403aef
5 changed files with 3 additions and 75 deletions
-8
View File
@@ -92,14 +92,6 @@ def memoize_method(method):
return wrapper return wrapper
def cache_star_import(func):
@time_cache("star_import_cache_validity")
def wrapper(self):
yield self.base # The cache key
yield func(self)
return wrapper
def _invalidate_star_import_cache_module(module, only_main=False): def _invalidate_star_import_cache_module(module, only_main=False):
""" Important if some new modules are being reparsed """ """ Important if some new modules are being reparsed """
try: try:
+2 -21
View File
@@ -324,13 +324,6 @@ class Evaluator(object):
if isinstance(atom, tree.Name): if isinstance(atom, tree.Name):
# This is the first global lookup. # This is the first global lookup.
stmt = atom.get_definition() stmt = atom.get_definition()
#if isinstance(context, er.FunctionExecution):
## Adjust scope: If the name is not in the suite, it's a param
## default or annotation and will be resolved as part of the
## parent scope.
#colon = scope.children.index(':')
#if atom.start_pos < scope.children[colon + 1].start_pos:
##scope = scope.get_parent_scope()
if isinstance(stmt, tree.CompFor): if isinstance(stmt, tree.CompFor):
stmt = stmt.get_parent_until((tree.ClassOrFunc, tree.ExprStmt)) stmt = stmt.get_parent_until((tree.ClassOrFunc, tree.ExprStmt))
if stmt.type != 'expr_stmt': if stmt.type != 'expr_stmt':
@@ -355,8 +348,8 @@ class Evaluator(object):
return types return types
# Parentheses without commas are not tuples. # Parentheses without commas are not tuples.
elif c[0] == '(' and not len(c) == 2 \ elif c[0] == '(' and not len(c) == 2 \
and not(tree.is_node(c[1], 'testlist_comp') and not(tree.is_node(c[1], 'testlist_comp') and
and len(c[1].children) > 1): len(c[1].children) > 1):
return self.eval_element(context, c[1]) return self.eval_element(context, c[1])
try: try:
@@ -520,18 +513,6 @@ class Evaluator(object):
search_global=True, is_goto=True search_global=True, is_goto=True
) )
def wrap(self, element, parent_context):
raise DeprecationWarning
if element.type == 'classdef':
return er.ClassContext(self, element, parent_context)
elif element.type == 'lambda':
return er.LambdaWrapper(self, element)
elif element.type == 'file_input':
return er.ModuleContext(self, element)
else:
raise DeprecationWarning
return element
def create_context(self, base_context, node, node_is_context=False): def create_context(self, base_context, node, node_is_context=False):
def parent_scope(node): def parent_scope(node):
while True: while True:
-30
View File
@@ -31,32 +31,6 @@ from jedi.evaluate.cache import memoize_default
from jedi.evaluate.filters import AbstractNameDefinition from jedi.evaluate.filters import AbstractNameDefinition
def completion_names(evaluator, imp, pos):
name = imp.name_for_position(pos)
module = evaluator.wrap(imp.get_parent_until())
if name is None:
level = 0
for node in imp.children:
if node.end_pos <= pos:
if node in ('.', '...'):
level += len(node.value)
import_path = []
else:
# Completion on an existing name.
# The import path needs to be reduced by one, because we're completing.
import_path = imp.path_for_name(name)[:-1]
level = imp.level
importer = Importer(evaluator, tuple(import_path), module, level)
if isinstance(imp, tree.ImportFrom):
c = imp.children
only_modules = c[c.index('import')].start_pos >= pos
else:
only_modules = True
return importer.completion_names(evaluator, only_modules)
# This memoization is needed, because otherwise we will infinitely loop on # This memoization is needed, because otherwise we will infinitely loop on
# certain imports. # certain imports.
@memoize_default(default=set()) @memoize_default(default=set())
@@ -385,9 +359,6 @@ class Importer(object):
def _generate_name(self, name, in_module=None): def _generate_name(self, name, in_module=None):
# Create a pseudo import to be able to follow them. # Create a pseudo import to be able to follow them.
if in_module is None: if in_module is None:
#imp = helpers.FakeImport(name, parent=self.module_context)
#name.parent = imp
#return name
return ImportName(self.module_context, name) return ImportName(self.module_context, name)
return SubModuleName(in_module, name) return SubModuleName(in_module, name)
@@ -413,7 +384,6 @@ class Importer(object):
:param only_modules: Indicates wheter it's possible to import a :param only_modules: Indicates wheter it's possible to import a
definition that is not defined in a module. definition that is not defined in a module.
""" """
from jedi.evaluate import finder
from jedi.evaluate.representation import ModuleContext from jedi.evaluate.representation import ModuleContext
names = [] names = []
if self.import_path: if self.import_path:
-12
View File
@@ -367,18 +367,6 @@ class SelfNameFilter(InstanceClassFilter):
and trailer.children[0] == '.': and trailer.children[0] == '.':
if name.is_definition() and self._access_possible(name): if name.is_definition() and self._access_possible(name):
yield name yield name
continue
init_execution = self.context.get_init_function()
# Hopefully we can somehow change this.
if init_execution is not None and \
init_execution.start_pos < name.start_pos < init_execution.end_pos:
name = init_execution.name_for_position(name.start_pos)
yield name
def _check_flows(self, names): def _check_flows(self, names):
return names return names
+1 -4
View File
@@ -41,14 +41,12 @@ import pkgutil
import imp import imp
import re import re
from jedi._compatibility import use_metaclass, unicode, Python3Method from jedi._compatibility import use_metaclass
from jedi.parser import tree from jedi.parser import tree
from jedi import debug from jedi import debug
from jedi import common from jedi import common
from jedi.cache import cache_star_import
from jedi.evaluate.cache import memoize_default, CachedMetaClass, NO_DEFAULT from jedi.evaluate.cache import memoize_default, CachedMetaClass, NO_DEFAULT
from jedi.evaluate import compiled from jedi.evaluate import compiled
from jedi.evaluate.compiled import mixed
from jedi.evaluate import recursion from jedi.evaluate import recursion
from jedi.evaluate import iterable from jedi.evaluate import iterable
from jedi.evaluate import docstrings from jedi.evaluate import docstrings
@@ -444,7 +442,6 @@ class ModuleContext(use_metaclass(CachedMetaClass, context.TreeContext)):
# I'm not sure if the star import cache is really that effective anymore # I'm not sure if the star import cache is really that effective anymore
# with all the other really fast import caches. Recheck. Also we would need # with all the other really fast import caches. Recheck. Also we would need
# to push the star imports into Evaluator.modules, if we reenable this. # to push the star imports into Evaluator.modules, if we reenable this.
#@cache_star_import
@memoize_default([]) @memoize_default([])
def star_imports(self): def star_imports(self):
modules = [] modules = []