Example #1
0
    def _resolve_function(self, matches,
                          args: Optional[cpp.ASTParametersQualifiers],
                          project_info):
        if not matches:
            raise _NoMatchingFunctionError()

        res = []
        candSignatures = []
        for entry in matches:
            text_options = {"no-link": "", "outline": ""}

            # Render the matches to docutils nodes
            target_handler = create_target_handler({"no-link": ""},
                                                   project_info,
                                                   self.state.document)
            filter_ = self.filter_factory.create_outline_filter(text_options)
            mask_factory = MaskFactory({"param": NoParameterNamesMask})

            # Override the directive args for this render
            directive_args = self.directive_args[:]
            directive_args[2] = text_options

            signature = self._create_function_signature(
                entry, project_info, filter_, target_handler, mask_factory,
                directive_args)
            candSignatures.append(signature)

            if args is not None:
                match = re.match(r"([^(]*)(.*)", signature)
                assert match
                _match_args = match.group(2)

                # Parse the text to find the arguments
                # This one should succeed as it came from _create_function_signature
                match_args = self._parse_args(_match_args)

                # Match them against the arg spec
                if args != match_args:
                    continue

            res.append((entry, signature))

        if len(res) == 1:
            return res[0][0]
        else:
            raise _UnableToResolveFunctionError(candSignatures)
Example #2
0
    def resolve_function(self, matches, args, project_info):
        if not matches:
            raise NoMatchingFunctionError()

        if len(matches) == 1:
            return matches[0]

        signatures = []

        # Iterate over the potential matches
        for entry in matches:
            text_options = {'no-link': u'', 'outline': u''}

            # Render the matches to docutils nodes
            target_handler = create_target_handler({'no-link': u''},
                                                   project_info,
                                                   self.state.document)
            filter_ = self.filter_factory.create_outline_filter(text_options)
            mask_factory = MaskFactory({'param': NoParameterNamesMask})

            # Override the directive args for this render
            directive_args = self.directive_args[:]
            directive_args[2] = text_options

            signature = self.create_function_signature(entry, project_info,
                                                       filter_, target_handler,
                                                       mask_factory,
                                                       directive_args)
            signatures.append(signature)

            match = re.match(r"([^(]*)(.*)", signature)
            _match_args = match.group(2)

            # Parse the text to find the arguments
            match_args = self.parse_args(_match_args)

            # Match them against the arg spec
            if args == match_args:
                return entry

        raise UnableToResolveFunctionError(signatures)