summaryrefslogtreecommitdiff
blob: 4132e2d1bfef78c44f115d9a8214426029abef76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
From 799a378b96cad5dc9b1093604e76ed362d22f4cc Mon Sep 17 00:00:00 2001
From: Christian Hergert <chergert@redhat.com>
Date: Sun, 27 May 2018 20:19:34 -0700
Subject: [PATCH] jedi: minimal attempt to get things working again

This tries to get some of our jedi code working with recent API changes
in the jedi project.

This is just a minimal fix, and I'd expect some others may be needed for
improved functionality.

Fixes #403
---
 src/plugins/jedi/jedi_plugin.py | 44 ++++++++++++++++++++++-----------
 1 file changed, 29 insertions(+), 15 deletions(-)

diff --git a/src/plugins/jedi/jedi_plugin.py b/src/plugins/jedi/jedi_plugin.py
index fd8e15d68..052500da1 100644
--- a/src/plugins/jedi/jedi_plugin.py
+++ b/src/plugins/jedi/jedi_plugin.py
@@ -91,8 +91,14 @@ try:
     import jedi
     from jedi.evaluate.compiled import CompiledObject
     from jedi.evaluate.compiled import get_special_object
-    from jedi.evaluate.compiled import _create_from_name
-    from jedi.evaluate.context import Context
+    try:
+        # 0.12
+        from jedi.evaluate.compiled import create_from_name
+        from jedi.evaluate.base_context import Context
+    except ImportError:
+        # Pre 0.12
+        from jedi.evaluate.compiled import _create_from_name as create_from_name
+        from jedi.evaluate.context import Context
     from jedi.evaluate.docstrings import _evaluate_for_statement_string
     from jedi.evaluate.imports import Importer
 
@@ -175,23 +181,31 @@ try:
                         pass
             return module_list
 
-    original_jedi_get_module = jedi.evaluate.compiled.fake.get_module
-
-    def patched_jedi_get_module(obj):
-        "Work around a weird bug in jedi"
-        try:
-            return original_jedi_get_module(obj)
-        except ImportError as e:
-            if e.msg == "No module named 'gi._gobject._gobject'":
-                return original_jedi_get_module('gi._gobject')
+    try:
+        # Pre 0.12 workaround
+        # TODO: What needs to be fixed here for 0.12?
+        original_jedi_get_module = jedi.evaluate.compiled.fake.get_module
+        def patched_jedi_get_module(obj):
+            "Work around a weird bug in jedi"
+            try:
+                return original_jedi_get_module(obj)
+            except ImportError as e:
+                if e.msg == "No module named 'gi._gobject._gobject'":
+                    return original_jedi_get_module('gi._gobject')
+        jedi.evaluate.compiled.fake.get_module = patched_jedi_get_module
+    except:
+        pass
 
-    jedi.evaluate.compiled.fake.get_module = patched_jedi_get_module
     jedi.evaluate.compiled.CompiledObject = PatchedJediCompiledObject
-    jedi.evaluate.instance.CompiledBoundMethod = PatchedCompiledBoundMethod
+    try:
+        jedi.evaluate.instance.CompiledBoundMethod = PatchedCompiledBoundMethod
+    except AttributeError:
+        jedi.evaluate.context.instance.CompiledBoundMethod = PatchedCompiledBoundMethod
     jedi.evaluate.imports.Importer = PatchedJediImporter
     HAS_JEDI = True
-except ImportError:
+except ImportError as ex:
     print("jedi not found, python auto-completion not possible.")
+    print(ex)
     HAS_JEDI = False
 
 GIR_PATH_LIST = []
@@ -376,7 +390,7 @@ class JediCompletionProvider(Ide.Object, GtkSource.CompletionProvider, Ide.Compl
         return False
 
     def do_populate(self, context):
-        self.current_word = Ide.CompletionProvider.context_current_word(context)
+        self.current_word = Ide.CompletionProvider.context_current_word(context) or ''
         self.current_word_lower = self.current_word.lower()
 
         _, iter = context.get_iter()
-- 
2.17.0