Rename parser.utils to parser.cache.

This commit is contained in:
Dave Halter
2017-03-30 01:57:48 +02:00
parent db364bc44d
commit 35fd1c70bd
9 changed files with 16 additions and 16 deletions

View File

@@ -9,7 +9,7 @@ import re
from jedi._compatibility import u
from jedi import settings
from jedi import common
from jedi.parser import utils as parser_utils
from jedi.parser.cache import parser_cache
from jedi.cache import memoize_method
from jedi.evaluate import representation as er
from jedi.evaluate import instance
@@ -391,7 +391,7 @@ class BaseDefinition(object):
return ''
path = self._name.get_root_context().py__file__()
lines = parser_utils.parser_cache[path].lines
lines = parser_cache[path].lines
line_nr = self._name.start_pos[0]
start_line_nr = line_nr - before

View File

@@ -15,7 +15,7 @@ import time
import inspect
from jedi import settings
from jedi.parser.utils import parser_cache
from jedi.parser.cache import parser_cache
_time_caches = {}

View File

@@ -22,7 +22,7 @@ from jedi import settings
from jedi.common import source_to_unicode, unite
from jedi.parser.python import parse
from jedi.parser.python import tree
from jedi.parser.utils import parser_cache
from jedi.parser.cache import parser_cache
from jedi.evaluate import sys_path
from jedi.evaluate import helpers
from jedi.evaluate import compiled

View File

@@ -8,7 +8,7 @@ from jedi.parser.pgen2.pgen import generate_grammar
from jedi.parser.python.parser import Parser, _remove_last_newline
from jedi.parser.python.diff import DiffParser
from jedi.parser.tokenize import generate_tokens
from jedi.parser import utils
from jedi.parser.cache import parser_cache, load_module, save_module
from jedi.common import splitlines, source_to_unicode
@@ -78,7 +78,7 @@ def parse(code=None, path=None, grammar=None, error_recovery=True,
use_cache = cache and path is not None and not code
if use_cache:
# In this case we do actual caching. We just try to load it.
module_node = utils.load_module(grammar, path)
module_node = load_module(grammar, path)
if module_node is not None:
return module_node
@@ -88,7 +88,7 @@ def parse(code=None, path=None, grammar=None, error_recovery=True,
if diff_cache:
try:
module_cache_item = utils.parser_cache[path]
module_cache_item = parser_cache[path]
except KeyError:
pass
else:
@@ -98,7 +98,7 @@ def parse(code=None, path=None, grammar=None, error_recovery=True,
old_lines=module_cache_item.lines,
new_lines=lines
)
utils.save_module(grammar, path, module_node, lines, pickling=False)
save_module(grammar, path, module_node, lines, pickling=False)
return new_node
added_newline = not code.endswith('\n')
@@ -117,5 +117,5 @@ def parse(code=None, path=None, grammar=None, error_recovery=True,
_remove_last_newline(root_node)
if use_cache or diff_cache:
utils.save_module(grammar, path, root_node, lines)
save_module(grammar, path, root_node, lines)
return root_node

View File

@@ -14,7 +14,7 @@ from jedi import settings
from jedi.common import splitlines
from jedi.parser.python.parser import Parser, _remove_last_newline
from jedi.parser.python.tree import EndMarker
from jedi.parser.utils import parser_cache
from jedi.parser.cache import parser_cache
from jedi import debug
from jedi.parser.tokenize import (generate_tokens, NEWLINE, TokenInfo,
ENDMARKER, INDENT, DEDENT)

View File

@@ -7,7 +7,7 @@ from textwrap import dedent
from jedi import api
from jedi._compatibility import is_py3
from pytest import raises
from jedi.parser import utils
from jedi.parser import cache
def test_preload_modules():
@@ -17,15 +17,15 @@ def test_preload_modules():
for i in modules:
assert [i in k for k in parser_cache.keys() if k is not None]
temp_cache, utils.parser_cache = utils.parser_cache, {}
parser_cache = utils.parser_cache
temp_cache, cache.parser_cache = cache.parser_cache, {}
parser_cache = cache.parser_cache
api.preload_module('sys')
check_loaded() # compiled (c_builtin) modules shouldn't be in the cache.
api.preload_module('types', 'token')
check_loaded('types', 'token')
utils.parser_cache = temp_cache
cache.parser_cache = temp_cache
def test_empty_script():

View File

@@ -9,7 +9,7 @@ import pytest
import jedi
from jedi import settings, cache
from jedi.parser.utils import _NodeCacheItem
from jedi.parser.cache import _NodeCacheItem
from jedi.parser.python import load_grammar

View File

@@ -6,7 +6,7 @@ import jedi
from jedi import debug
from jedi.common import splitlines
from jedi import cache
from jedi.parser.utils import parser_cache
from jedi.parser.cache import parser_cache
from jedi.parser.python import load_grammar
from jedi.parser.python.diff import DiffParser
from jedi.parser.python import parse