Silence some code completion errors
@@ -5,23 +5,56 @@ except:
import jedi
import sys
import traceback
+from rubicon.objc import at
+from Foundation import NSAutoreleasePool
+
+_completions_queue = 0
def suggestForCode(code, index, path):
+ global _completions_queue
+
+ pool = NSAutoreleasePool.alloc().init()
+
- for console in ConsoleViewController.objcVisibles:
- def visibleEditor():
- return console.editorSplitViewController.editor
+ try:
+ visibles = ConsoleViewController.objcVisibles
+ except AttributeError:
+ visibles = []
+
+ for console in visibles:
- if visibleEditor().document.fileURL.path != path:
+ try:
+ try:
+ if console.editorSplitViewController is None:
+ continue
+ except AttributeError:
+ return
+
+ try:
+ visibleEditor = console.editorSplitViewController.editor
+ except AttributeError:
+ visibleEditor = console.editorSplitViewController().editor
+
+ if visibleEditor is None:
+ continue
+
+ try:
+ if visibleEditor.document.fileURL.path != path:
+ continue
+ except AttributeError:
+ if visibleEditor.document().fileURL.path != path:
continue
if code.endswith(");\n"):
- if visibleEditor() is None:
+ if visibleEditor is None:
return
- visibleEditor().completions = []
- visibleEditor().suggestions = []
- visibleEditor().docStrings = None
+ visibleEditor.completions = []
+ visibleEditor.suggestions = []
+ visibleEditor.docStrings = None
+ return
+ except Exception as e:
+ sys.__stdout__.write("Code completion:\n "+traceback.format_exc()+"\n")
return
try:
@@ -38,7 +71,7 @@ def suggestForCode(code, index, path):
definitions.append([decl, line])
- visibleEditor().definitions = definitions
+ visibleEditor.definitions = definitions
suggestions = []
completions = []
@@ -96,21 +129,24 @@ def suggestForCode(code, index, path):
suggestions = []
break
- visibleEditor().signature = signature
- visibleEditor().completions = completions
- visibleEditor().suggestions = suggestions
- visibleEditor().docStrings = docs
+ visibleEditor.signature = signature
+ visibleEditor.completions = completions
+ visibleEditor.suggestions = suggestions
+ visibleEditor.docStrings = docs
+
except Exception as e:
sys.__stdout__.write("Code completion:\n "+traceback.format_exc()+"\n")
- if visibleEditor() is None:
+ if visibleEditor is None:
return
- visibleEditor().completions = []
- visibleEditor().suggestions = []
- visibleEditor().signature = ""
- visibleEditor().docStrings = None
+ visibleEditor.completions = []
+ visibleEditor.suggestions = []
+ visibleEditor.signature = ""
+ visibleEditor.docStrings = None
+
+ pool.release()
def suggestionsForCode(code, path=None):
