diff --git a/.travis.yml b/.travis.yml index 29c03f1a..adf32985 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,9 +5,11 @@ env: - TOXENV=py32 - TOXENV=py33 - TOXENV=cov + - TOXENV=sith matrix: allow_failures: - env: TOXENV=cov + - env: TOXENV=sith install: - pip install --quiet --use-mirrors tox script: diff --git a/README.rst b/README.rst index 5f2beb9f..096b3cd4 100644 --- a/README.rst +++ b/README.rst @@ -26,12 +26,15 @@ which uses Jedi's autocompletion. I encourage you to use Jedi in your IDEs. It's really easy. If there are any problems (also with licensing), just contact me. -Jedi can be used with the following plugins/software: +Jedi can be used with the following editors: -- `VIM-Plugin `_ -- `Emacs-Plugin `_ -- `Sublime-Plugin `_ -- `wdb (web debugger) `_ +- Vim (jedi-vim_, YouCompleteMe_) +- Emacs (Jedi.el_) +- Sublime Text (SublimeJEDI_) + +And it powers the following projects: + +- wdb_ Here are some pictures: @@ -123,3 +126,10 @@ Tests are also run automatically on `Travis CI For more detailed information visit the `testing documentation `_ + + +.. _jedi-vim: https://github.com/davidhalter/jedi-vim +.. _youcompleteme: http://valloric.github.io/YouCompleteMe/ +.. _Jedi.el: https://github.com/tkf/emacs-jedi +.. _sublimejedi: https://github.com/svaiter/SublimeJEDI +.. _wdb: https://github.com/Kozea/wdb diff --git a/docs/index.rst b/docs/index.rst index 9f53f667..b6bb2755 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -45,9 +45,18 @@ Resources Editor Plugins -------------- -- `Vim `_ -- `Emacs `_ -- `Sublime Text 2 `_ +Vim: + +- `jedi-vim `_ +- `YouCompleteMe `_ + +Emacs: + +- `Jedi.el `_ + +Sublime Text 2: + +- `SublimeJEDI `_ .. _other-software: diff --git a/jedi/modules.py b/jedi/modules.py index 37e5bbac..c583ec5f 100644 --- a/jedi/modules.py +++ b/jedi/modules.py @@ -141,6 +141,7 @@ class ModuleWithCursor(Module): last_line = self.get_line(self._line_temp) if last_line and last_line[-1] == '\\': line = last_line[:-1] + ' ' + line + self._line_length = len(last_line) else: break return line[::-1] @@ -187,6 +188,7 @@ class ModuleWithCursor(Module): elif token_type == tokenize.NUMBER: pass else: + self._column_temp = self._line_length - end[1] break self._column_temp = self._line_length - end[1] diff --git a/jedi/settings.py b/jedi/settings.py index 666547c9..3f3598c8 100644 --- a/jedi/settings.py +++ b/jedi/settings.py @@ -127,8 +127,10 @@ cache_directory = os.path.expanduser(_cache_directory) """ The path where all the caches can be found. -On Linux, this defaults to ``~/.cache/jedi/``, on OS X to ``~/.jedi/`` and on -Windows to ``%APPDATA%\\Jedi\\Jedi\\``. +On Linux, this defaults to ``~/.cache/jedi/``, on OS X to +``~/Library/Caches/Jedi/`` and on Windows to ``%APPDATA%\\Jedi\\Jedi\\``. +On Linux, if environment variable ``$XDG_CACHE_HOME`` is set, +``$XDG_CACHE_HOME/jedi`` is used instead of the default one. """ # ---------------- diff --git a/sith.py b/sith.py index 2f1eda18..6f07d882 100755 --- a/sith.py +++ b/sith.py @@ -86,6 +86,9 @@ class BaseAttacker(object): return self.record['data'][recid] def save_record(self, path): + directory = os.path.dirname(os.path.abspath(path)) + if not os.path.isdir(directory): + os.makedirs(directory) with open(path, 'w') as f: json.dump(self.record, f) @@ -251,6 +254,7 @@ class AttackApp(object): einfo = sys.exc_info() pdb = __import__(debugger) pdb.post_mortem(einfo if debugger == 'pudb' else einfo[2]) + sys.exit(1) def add_parser(self, attacker_class, *args, **kwds): attacker = attacker_class() diff --git a/test/test_regression.py b/test/test_regression.py index e44afb8d..3753d0bf 100755 --- a/test/test_regression.py +++ b/test/test_regression.py @@ -395,6 +395,43 @@ class TestRegression(TestBase): for c in s.get_commands(): self.assertEqual(c.execution.end_pos[1], i) + def check_definition_by_marker(self, source, after_cursor, names): + r""" + Find definitions specified by `after_cursor` and check what found + + For example, for the following configuration, you can pass + ``after_cursor = 'y)'``.:: + + function( + x, y) + \ + `- You want cursor to be here + """ + source = textwrap.dedent(source) + for (i, line) in enumerate(source.splitlines()): + if after_cursor in line: + break + column = len(line) - len(after_cursor) + defs = self.goto_definitions(source, (i + 1, column)) + self.assertEqual([d.name for d in defs], names) + + def test_backslash_continuation(self): + """ + Test that ModuleWithCursor.get_path_until_cursor handles continuation + """ + self.check_definition_by_marker(r""" + x = 0 + a = \ + [1, 2, 3, 4, 5, 6, 7, 8, 9, x] # <-- here + """, '] # <-- here', ['int']) + + def test_backslash_continuation_and_bracket(self): + self.check_definition_by_marker(r""" + x = 0 + a = \ + [1, 2, 3, 4, 5, 6, 7, 8, 9, (x)] # <-- here + """, '(x)] # <-- here', [None]) + class TestDocstring(TestBase): diff --git a/tox.ini b/tox.ini index c4d86518..8eb4e27c 100644 --- a/tox.ini +++ b/tox.ini @@ -16,3 +16,8 @@ deps = commands = coverage run --source jedi -m py.test coverage report +[testenv:sith] +deps = + argparse +commands = + {envpython} sith.py --record {envtmpdir}/record.json random {posargs:jedi}