def call_signatures(self):
        """
        Return the function object of the call you're currently in.

        E.g. if the cursor is here::

            abs(# <-- cursor is here

        This would return the ``abs`` function. On the other hand::

            abs()# <-- cursor is here

        This would return an empty list..

        :rtype: list of :class:`classes.CallSignature`
        """
        call_signature_details = \
            helpers.get_call_signature_details(self._get_module(), self._pos)
        if call_signature_details is None:
            return []

        with common.scale_speed_settings(settings.scale_call_signatures):
            definitions = helpers.cache_call_signatures(
                self._evaluator,
                call_signature_details.bracket_leaf,
                self._code_lines,
                self._pos
            )
        debug.speed('func_call followed')

        return [classes.CallSignature(self._evaluator, d.name,
                                      call_signature_details.bracket_leaf.start_pos,
                                      call_signature_details.call_index,
                                      call_signature_details.keyword_name_str)
                for d in definitions if hasattr(d, 'py__call__')]
Exemple #2
0
    def call_signatures(self):
        """
        Return the function object of the call you're currently in.

        E.g. if the cursor is here::

            abs(# <-- cursor is here

        This would return the ``abs`` function. On the other hand::

            abs()# <-- cursor is here

        This would return an empty list..

        :rtype: list of :class:`classes.CallSignature`
        """
        call_details = helpers.get_call_signature_details(
            self._module_node, self._pos)
        if call_details is None:
            return []

        context = self._evaluator.create_context(self._get_module(),
                                                 call_details.bracket_leaf)
        definitions = helpers.cache_call_signatures(self._evaluator, context,
                                                    call_details.bracket_leaf,
                                                    self._code_lines,
                                                    self._pos)
        debug.speed('func_call followed')

        # TODO here we use stubs instead of the actual contexts. We should use
        # the signatures from stubs, but the actual contexts, probably?!
        return [
            classes.CallSignature(self._evaluator, signature, call_details)
            for signature in definitions.get_signatures()
        ]