From 105bb2b1ca9d76d377ed24a10bc7ff0c05a219f3 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Fri, 24 May 2013 19:43:23 +0200 Subject: [PATCH 01/11] ModuleWithCursor.get_path_until_cursor cannot handle "\" It raises: IndexError: string index out of range --- test/test_regression.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/test_regression.py b/test/test_regression.py index e44afb8d..1e72cadf 100755 --- a/test/test_regression.py +++ b/test/test_regression.py @@ -395,6 +395,22 @@ class TestRegression(TestBase): for c in s.get_commands(): self.assertEqual(c.execution.end_pos[1], i) + def test_backslash_continuation(self): + """ + Test that ModuleWithCursor.get_path_until_cursor handles continuation + """ + source = textwrap.dedent(r""" + x = 0 + a = \ + [1, 2, 3, 4, 5, 6, 7, 8, 9, x] # <-- here + """) + for (i, line) in enumerate(source.splitlines()): + if '<-- here' in line: + break + column = len(line) - len('] # <-- here') + defs = self.goto_definitions(source, (i + 1, column)) + self.assertEqual([d.name for d in defs], ['int']) + class TestDocstring(TestBase): From 05564c23d58e2c595604b5f48450d8986b5ecb92 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Fri, 24 May 2013 21:06:48 +0200 Subject: [PATCH 02/11] Fix the error --- jedi/modules.py | 1 + 1 file changed, 1 insertion(+) diff --git a/jedi/modules.py b/jedi/modules.py index 37e5bbac..46195c80 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] From 71455f6b31ac36bbf276852a5a1b84adad133ce9 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Fri, 24 May 2013 22:05:12 +0200 Subject: [PATCH 03/11] Add another failing case --- test/test_regression.py | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/test/test_regression.py b/test/test_regression.py index 1e72cadf..3753d0bf 100755 --- a/test/test_regression.py +++ b/test/test_regression.py @@ -395,21 +395,42 @@ 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 """ - source = textwrap.dedent(r""" + self.check_definition_by_marker(r""" x = 0 a = \ [1, 2, 3, 4, 5, 6, 7, 8, 9, x] # <-- here - """) - for (i, line) in enumerate(source.splitlines()): - if '<-- here' in line: - break - column = len(line) - len('] # <-- here') - defs = self.goto_definitions(source, (i + 1, column)) - self.assertEqual([d.name for d in defs], ['int']) + """, '] # <-- 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): From 1f3c4700c9c581bf3f64cf570989788636f259d6 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Fri, 24 May 2013 22:09:24 +0200 Subject: [PATCH 04/11] Fix get_path_until_cursor for empty path + continuation --- jedi/modules.py | 1 + 1 file changed, 1 insertion(+) diff --git a/jedi/modules.py b/jedi/modules.py index 46195c80..c583ec5f 100644 --- a/jedi/modules.py +++ b/jedi/modules.py @@ -188,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] From a94642b9c0f0762fe4079052fd7f53d9f4813319 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Fri, 24 May 2013 23:00:43 +0200 Subject: [PATCH 05/11] Add testenv:sith in tox.ini --- sith.py | 4 ++++ tox.ini | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/sith.py b/sith.py index 2f1eda18..f903eb61 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(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/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} From 96ca86e9f7590f7fadba46521e9c9a7e35139852 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Fri, 24 May 2013 23:01:35 +0200 Subject: [PATCH 06/11] Run random smoke test at Travis --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) 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: From 868a4b5dd86df7aaf4751d9867ed4fc572479189 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Fri, 24 May 2013 23:19:45 +0200 Subject: [PATCH 07/11] Fix sith.py for default --record --- sith.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sith.py b/sith.py index f903eb61..6f07d882 100755 --- a/sith.py +++ b/sith.py @@ -86,7 +86,7 @@ class BaseAttacker(object): return self.record['data'][recid] def save_record(self, path): - directory = os.path.dirname(path) + directory = os.path.dirname(os.path.abspath(path)) if not os.path.isdir(directory): os.makedirs(directory) with open(path, 'w') as f: From 06cd9752bda5247cf229d451899ef95f2daaea15 Mon Sep 17 00:00:00 2001 From: Danilo Bargen Date: Mon, 27 May 2013 10:33:20 +0200 Subject: [PATCH 08/11] Added YCM to plugin list --- README.rst | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index 5f2beb9f..d9e11212 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 (emacs-jedi_) +- 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/ +.. _emacs-jedi: https://github.com/tkf/emacs-jedi +.. _sublimejedi: https://github.com/svaiter/SublimeJEDI +.. _wdb: https://github.com/Kozea/wdb From 97ef7b00db103e446e8fe4b4981bd986efa1f6e5 Mon Sep 17 00:00:00 2001 From: Danilo Bargen Date: Mon, 27 May 2013 10:38:43 +0200 Subject: [PATCH 09/11] Added YCM link to docs too --- docs/index.rst | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index 9f53f667..c6b03d35 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: + +- `emacs-jedi `_ + +Sublime Text 2: + +- `SublimeJEDI `_ .. _other-software: From c5a2ba3d353937f6bbd6659d25100d91ccffa2a5 Mon Sep 17 00:00:00 2001 From: Danilo Bargen Date: Mon, 27 May 2013 10:40:43 +0200 Subject: [PATCH 10/11] s/emacs-jedi/Jedi.el/g --- README.rst | 4 ++-- docs/index.rst | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index d9e11212..096b3cd4 100644 --- a/README.rst +++ b/README.rst @@ -29,7 +29,7 @@ me. Jedi can be used with the following editors: - Vim (jedi-vim_, YouCompleteMe_) -- Emacs (emacs-jedi_) +- Emacs (Jedi.el_) - Sublime Text (SublimeJEDI_) And it powers the following projects: @@ -130,6 +130,6 @@ For more detailed information visit the `testing documentation .. _jedi-vim: https://github.com/davidhalter/jedi-vim .. _youcompleteme: http://valloric.github.io/YouCompleteMe/ -.. _emacs-jedi: https://github.com/tkf/emacs-jedi +.. _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 c6b03d35..b6bb2755 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -52,7 +52,7 @@ Vim: Emacs: -- `emacs-jedi `_ +- `Jedi.el `_ Sublime Text 2: From 5de63873df761f00f28e0a116b9e3c20e0da748b Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Wed, 19 Jun 2013 15:38:24 +0200 Subject: [PATCH 11/11] Fix and improve settings.cache_directory document fixes #244 --- jedi/settings.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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. """ # ----------------