moved modules.py -> parser/user_context.py

This commit is contained in:
Dave Halter
2014-01-05 14:13:59 +01:00
parent 3afda3cb3e
commit 5857b4dbc9
4 changed files with 7 additions and 9 deletions

View File

@@ -15,20 +15,20 @@ import os
import warnings import warnings
from itertools import chain from itertools import chain
from jedi._compatibility import next, unicode, builtins
from jedi.parser import Parser from jedi.parser import Parser
from jedi.parser import representation as pr from jedi.parser import representation as pr
from jedi.parser import fast from jedi.parser import fast
from jedi.parser.user_context import UserContext
from jedi import debug from jedi import debug
from jedi import settings from jedi import settings
from jedi import helpers from jedi import helpers
from jedi import common from jedi import common
from jedi import cache from jedi import cache
from jedi import modules
from jedi import interpret from jedi import interpret
from jedi._compatibility import next, unicode, builtins from jedi import keywords
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 import keywords
from jedi.evaluate import builtin from jedi.evaluate import builtin
from jedi.evaluate import imports from jedi.evaluate import imports
from jedi.evaluate import dynamic from jedi.evaluate import dynamic
@@ -88,7 +88,7 @@ class Script(object):
api_classes.clear_caches() api_classes.clear_caches()
debug.reset_time() debug.reset_time()
self.source = common.source_to_unicode(source, encoding) self.source = common.source_to_unicode(source, encoding)
self._user_context = modules.UserContext(self.source, self._pos) self._user_context = UserContext(self.source, self._pos)
self._evaluator = Evaluator() self._evaluator = Evaluator()
debug.speed('init') debug.speed('init')
@@ -364,7 +364,7 @@ class Script(object):
# reset cursor position: # reset cursor position:
(row, col) = call.name.end_pos (row, col) = call.name.end_pos
pos = (row, max(col - 1, 0)) pos = (row, max(col - 1, 0))
self._user_context = modules.UserContext(self.source, pos) self._user_context = UserContext(self.source, pos)
# then try to find the path again # then try to find the path again
goto_path = self._user_context.get_path_under_cursor() goto_path = self._user_context.get_path_under_cursor()

View File

@@ -8,7 +8,6 @@ from jedi import debug
class UserContext(object): class UserContext(object):
""" """
:param source: The source code of the file. :param source: The source code of the file.
:param position: The position, the user is currently in. Only important \ :param position: The position, the user is currently in. Only important \
for the main file. for the main file.

View File

@@ -17,7 +17,6 @@ from __future__ import with_statement
import difflib import difflib
from jedi import common from jedi import common
from jedi import modules
from jedi import helpers from jedi import helpers
from jedi.parser import representation as pr from jedi.parser import representation as pr

View File

@@ -12,7 +12,7 @@ import pytest
import jedi import jedi
from jedi import Script from jedi import Script
from jedi import api from jedi import api
from jedi import modules from jedi.evaluate import imports
from jedi.parser import Parser from jedi.parser import Parser
#jedi.set_debug_function() #jedi.set_debug_function()
@@ -84,7 +84,7 @@ class TestRegression(TestCase):
src1 = "def r(a): return a" src1 = "def r(a): return a"
# Other fictional modules in another place in the fs. # Other fictional modules in another place in the fs.
src2 = 'from .. import setup; setup.r(1)' src2 = 'from .. import setup; setup.r(1)'
modules.load_module(os.path.abspath(fname), src2) imports.load_module(os.path.abspath(fname), src2)
result = Script(src1, path='../setup.py').goto_definitions() result = Script(src1, path='../setup.py').goto_definitions()
assert len(result) == 1 assert len(result) == 1
assert result[0].description == 'class int' assert result[0].description == 'class int'