def getCompletions(self, text, act_tok):
        # Get completions from IPython and from PyDev and merge the results
        # IPython only gives context free list of completions, while PyDev
        # gives detailed information about completions.
        try:
            TYPE_IPYTHON = '11'
            TYPE_IPYTHON_MAGIC = '12'
            _line, ipython_completions = self.complete(text)

            from _pydev_completer import Completer
            completer = Completer(self.getNamespace(), None)
            ret = completer.complete(act_tok)
            append = ret.append
            ip = self.ipython
            pydev_completions = set([f[0] for f in ret])
            for ipython_completion in ipython_completions:
                if ipython_completion not in pydev_completions:
                    pydev_completions.add(ipython_completion)
                    inf = ip.object_inspect(ipython_completion)
                    if inf['type_name'] == 'Magic function':
                        pydev_type = TYPE_IPYTHON_MAGIC
                    else:
                        pydev_type = TYPE_IPYTHON
                    pydev_doc = inf['docstring']
                    if pydev_doc is None:
                        pydev_doc = ''
                    append((ipython_completion, pydev_doc, '', pydev_type))
            return ret
        except:
            import traceback;traceback.print_exc()
            return []
    def getCompletions(self, text, act_tok):
        try:
            ipython_completion = text.startswith("%")
            if not ipython_completion:
                s = re.search(r"\bcd\b", text)
                if s is not None and s.start() == 0:
                    ipython_completion = True

            if ipython_completion:
                TYPE_LOCAL = "9"
                _line, completions = self.complete(text)

                ret = []
                append = ret.append
                for completion in completions:
                    append((completion, "", "", TYPE_LOCAL))
                return ret

            # Otherwise, use the default PyDev completer (to get nice icons)
            from _pydev_completer import Completer

            completer = Completer(self.getNamespace(), None)
            return completer.complete(act_tok)
        except:
            import traceback

            traceback.print_exc()
            return []
Ejemplo n.º 3
0
    def getCompletions(self, text, act_tok):
        try:
            ipython_completion = text.startswith('%')
            if not ipython_completion:
                s = re.search(r'\bcd\b', text)
                if s is not None and s.start() == 0:
                    ipython_completion = True

            if ipython_completion:
                TYPE_LOCAL = '9'
                _line, completions = self.interpreter.complete(text)

                ret = []
                append = ret.append
                for completion in completions:
                    append((completion, '', '', TYPE_LOCAL))
                return ret

            #Otherwise, use the default PyDev completer (to get nice icons)
            from _pydev_completer import Completer
            completer = Completer(self.getNamespace(), None)
            return completer.complete(act_tok)
        except:
            import traceback
            traceback.print_exc()
            return []
Ejemplo n.º 4
0
    def getCompletions(self, text, act_tok):
        # Get completions from IPython and from PyDev and merge the results
        # IPython only gives context free list of completions, while PyDev
        # gives detailed information about completions.
        try:
            TYPE_IPYTHON = '11'
            TYPE_IPYTHON_MAGIC = '12'
            _line, ipython_completions = self.complete(text)

            from _pydev_completer import Completer
            completer = Completer(self.getNamespace(), None)
            ret = completer.complete(act_tok)
            append = ret.append
            ip = self.ipython
            pydev_completions = set([f[0] for f in ret])
            for ipython_completion in ipython_completions:
                if ipython_completion not in pydev_completions:
                    pydev_completions.add(ipython_completion)
                    inf = ip.object_inspect(ipython_completion)
                    if inf['type_name'] == 'Magic function':
                        pydev_type = TYPE_IPYTHON_MAGIC
                    else:
                        pydev_type = TYPE_IPYTHON
                    pydev_doc = inf['docstring']
                    if pydev_doc is None:
                        pydev_doc = ''
                    append((ipython_completion, pydev_doc, '', pydev_type))
            return ret
        except:
            import traceback
            traceback.print_exc()
            return []
Ejemplo n.º 5
0
 def getCompletions(self, text, act_tok):
     try:
         from _pydev_completer import Completer
         completer = Completer(self.namespace, None)
         return completer.complete(act_tok)
     except:
         import traceback;traceback.print_exc()
         return []
Ejemplo n.º 6
0
 def getCompletions(self, text, act_tok):
     try:
         from _pydev_completer import Completer
         completer = Completer(self.namespace, None)
         return completer.complete(act_tok)
     except:
         import traceback
         traceback.print_exc()
         return []
    def getCompletions(self, text, act_tok):
        try:
            ipython_completion = text.startswith('%')
            if not ipython_completion:
                s = re.search(r'\bcd\b', text)
                if s is not None and s.start() == 0:
                    ipython_completion = True

            if text is None:
                text = ""

            TYPE_LOCAL = '9'
            _line, completions = self.interpreter.complete(text)

            ret = []
            append = ret.append
            for completion in completions:
                if completion.startswith('%'):
                    append((completion[1:], '', '%', TYPE_LOCAL))
                else:
                    append((completion, '', '', TYPE_LOCAL))

            if ipython_completion:
                return ret

            #Otherwise, use the default PyDev completer (to get nice icons)
            from _pydev_completer import Completer

            completer = Completer(self.getNamespace(), None)
            completions = completer.complete(act_tok)
            cset = set()
            for c in completions:
                cset.add(c[0])
            for c in ret:
                if c[0] not in cset:
                    completions.append(c)

            return completions

        except:
            import traceback

            traceback.print_exc()
            return []
    def getCompletions(self, text, act_tok):
        # Get completions from IPython and from PyDev and merge the results
        # IPython only gives context free list of completions, while PyDev
        # gives detailed information about completions.
        try:
            TYPE_IPYTHON = "11"
            TYPE_IPYTHON_MAGIC = "12"
            _line, ipython_completions = self.complete(text)

            from _pydev_completer import Completer

            completer = Completer(self.getNamespace(), None)
            ret = completer.complete(act_tok)
            append = ret.append
            ip = self.ipython
            pydev_completions = set([f[0] for f in ret])
            for ipython_completion in ipython_completions:

                # PyCharm was not expecting completions with '%'...
                # Could be fixed in the backend, but it's probably better
                # fixing it at PyCharm.
                # if ipython_completion.startswith('%'):
                #    ipython_completion = ipython_completion[1:]

                if ipython_completion not in pydev_completions:
                    pydev_completions.add(ipython_completion)
                    inf = ip.object_inspect(ipython_completion)
                    if inf["type_name"] == "Magic function":
                        pydev_type = TYPE_IPYTHON_MAGIC
                    else:
                        pydev_type = TYPE_IPYTHON
                    pydev_doc = inf["docstring"]
                    if pydev_doc is None:
                        pydev_doc = ""
                    append((ipython_completion, pydev_doc, "", pydev_type))
            return ret
        except:
            import traceback

            traceback.print_exc()
            return []