def _resolve_xref_inner(self, env: BuildEnvironment, fromdocname: str, builder: Builder, typ: str, target: str, node: pending_xref, contnode: Element) -> Tuple[(Element, str)]:
    if ((typ == 'any') or (typ == 'func')):
        target += '()'
    parser = DefinitionParser(target, location=node, config=env.config)
    try:
        (ast, isShorthand) = parser.parse_xref_object()
    except DefinitionError as e:

        def findWarning(e: Exception) -> Tuple[(str, Exception)]:
            if ((typ != 'any') and (typ != 'func')):
                return (target, e)
            parser2 = DefinitionParser(target[:(- 2)], location=node, config=env.config)
            try:
                parser2.parse_xref_object()
            except DefinitionError as e2:
                return (target[:(- 2)], e2)
            return (target, e)
        (t, ex) = findWarning(e)
        logger.warning('Unparseable C++ cross-reference: %r\n%s', t, ex, location=node)
        return (None, None)
    parentKey = node.get('cpp:parent_key', None)
    rootSymbol = self.data['root_symbol']
    if parentKey:
        parentSymbol = rootSymbol.direct_lookup(parentKey)
        if (not parentSymbol):
            print('Target: ', target)
            print('ParentKey: ', parentKey.data)
            print(rootSymbol.dump(1))
        assert parentSymbol
    else:
        parentSymbol = rootSymbol
    if isShorthand:
        assert isinstance(ast, ASTNamespace)
        ns = ast
        name = ns.nestedName
        if ns.templatePrefix:
            templateDecls = ns.templatePrefix.templates
        else:
            templateDecls = []
        searchInSiblings = ((not name.rooted) and (len(name.names) == 1))
        (symbols, failReason) = parentSymbol.find_name(name, templateDecls, typ, templateShorthand=True, matchSelf=True, recurseInAnon=True, searchInSiblings=searchInSiblings)
        if (symbols is None):
            if (typ == 'identifier'):
                if (failReason == 'templateParamInQualified'):
                    raise NoUri(str(name), typ)
            s = None
        else:
            s = symbols[0]
    else:
        assert isinstance(ast, ASTDeclaration)
        decl = ast
        name = decl.name
        s = parentSymbol.find_declaration(decl, typ, templateShorthand=True, matchSelf=True, recurseInAnon=True)
    if ((s is None) or (s.declaration is None)):
        txtName = str(name)
        if (txtName.startswith('std::') or (txtName == 'std')):
            raise NoUri(txtName, typ)
        return (None, None)
    if typ.startswith('cpp:'):
        typ = typ[4:]
    origTyp = typ
    if (typ == 'func'):
        typ = 'function'
    if (typ == 'struct'):
        typ = 'class'
    declTyp = s.declaration.objectType

    def checkType() -> bool:
        if ((typ == 'any') or (typ == 'identifier')):
            return True
        if (declTyp == 'templateParam'):
            return True
        if (declTyp == 'functionParam'):
            if ((typ == 'var') or (typ == 'member')):
                return True
        objtypes = self.objtypes_for_role(typ)
        if objtypes:
            return (declTyp in objtypes)
        print(('Type is %s (originally: %s), declType is %s' % (typ, origTyp, declTyp)))
        assert False
    if (not checkType()):
        logger.warning('cpp:%s targets a %s (%s).', origTyp, s.declaration.objectType, s.get_full_nested_name(), location=node)
    declaration = s.declaration
    if isShorthand:
        fullNestedName = s.get_full_nested_name()
        displayName = fullNestedName.get_display_string().lstrip(':')
    else:
        displayName = decl.get_display_string()
    docname = s.docname
    assert docname
    if (typ != 'identifier'):
        title = contnode.pop(0).astext()
        addParen = 0
        if ((not node.get('refexplicit', False)) and (declaration.objectType == 'function')):
            if isShorthand:
                if (env.config.add_function_parentheses and (typ == 'any')):
                    addParen += 1
                if (env.config.add_function_parentheses and (typ == 'function') and title.endswith('operator()')):
                    addParen += 1
                if (((typ == 'any') or (typ == 'function')) and title.endswith('operator') and displayName.endswith('operator()')):
                    addParen += 1
            elif env.config.add_function_parentheses:
                if ((typ == 'any') and displayName.endswith('()')):
                    addParen += 1
                elif (typ == 'function'):
                    if (title.endswith('()') and (not displayName.endswith('()'))):
                        title = title[:(- 2)]
            elif displayName.endswith('()'):
                addParen += 1
        if (addParen > 0):
            title += ('()' * addParen)
        contnode += nodes.Text(title)
    return (make_refnode(builder, fromdocname, docname, declaration.get_newest_id(), contnode, displayName), declaration.objectType)
def _resolve_xref_inner(self, env: BuildEnvironment, fromdocname: str, builder: Builder, typ: str, target: str, node: pending_xref, contnode: Element) -> Tuple[(Element, str)]:
    if ((typ == 'any') or (typ == 'func')):
        target += '()'
    parser = DefinitionParser(target, location=node, config=env.config)
    try:
        (ast, isShorthand) = parser.parse_xref_object()
    except DefinitionError as e:

        def findWarning(e: Exception) -> Tuple[(str, Exception)]:
            if ((typ != 'any') and (typ != 'func')):
                return (target, e)
            parser2 = DefinitionParser(target[:(- 2)], location=node, config=env.config)
            try:
                parser2.parse_xref_object()
            except DefinitionError as e2:
                return (target[:(- 2)], e2)
            return (target, e)
        (t, ex) = findWarning(e)
        logger.warning('Unparseable C++ cross-reference: %r\n%s', t, ex, location=node)
        return (None, None)
    parentKey = node.get('cpp:parent_key', None)
    rootSymbol = self.data['root_symbol']
    if parentKey:
        parentSymbol = rootSymbol.direct_lookup(parentKey)
        if (not parentSymbol):
            print('Target: ', target)
            print('ParentKey: ', parentKey.data)
            print(rootSymbol.dump(1))
        assert parentSymbol
    else:
        parentSymbol = rootSymbol
    if isShorthand:
        assert isinstance(ast, ASTNamespace)
        ns = ast
        name = ns.nestedName
        if ns.templatePrefix:
            templateDecls = ns.templatePrefix.templates
        else:
            templateDecls = []
        searchInSiblings = ((not name.rooted) and (len(name.names) == 1))
        (symbols, failReason) = parentSymbol.find_name(name, templateDecls, typ, templateShorthand=True, matchSelf=True, recurseInAnon=True, searchInSiblings=searchInSiblings)
        if (symbols is None):
            if (typ == 'identifier'):
                if (failReason == 'templateParamInQualified'):
                    raise NoUri(str(name), typ)
            s = None
        else:
            s = symbols[0]
    else:
        assert isinstance(ast, ASTDeclaration)
        decl = ast
        name = decl.name
        s = parentSymbol.find_declaration(decl, typ, templateShorthand=True, matchSelf=True, recurseInAnon=True)
    if ((s is None) or (s.declaration is None)):
        txtName = str(name)
        if (txtName.startswith('std::') or (txtName == 'std')):
            raise NoUri(txtName, typ)
        return (None, None)
    if typ.startswith('cpp:'):
        typ = typ[4:]
    origTyp = typ
    if (typ == 'func'):
        typ = 'function'
    if (typ == 'struct'):
        typ = 'class'
    declTyp = s.declaration.objectType

    def checkType() -> bool:
        if ((typ == 'any') or (typ == 'identifier')):
            return True
        if (declTyp == 'templateParam'):
            return True
        if (declTyp == 'functionParam'):
            if ((typ == 'var') or (typ == 'member')):
                return True
        objtypes = self.objtypes_for_role(typ)
        if objtypes:
            return (declTyp in objtypes)
        print(('Type is %s (originally: %s), declType is %s' % (typ, origTyp, declTyp)))
        assert False
    if (not checkType()):
        logger.warning('cpp:%s targets a %s (%s).', origTyp, s.declaration.objectType, s.get_full_nested_name(), location=node)
    declaration = s.declaration
    if isShorthand:
        fullNestedName = s.get_full_nested_name()
        displayName = fullNestedName.get_display_string().lstrip(':')
    else:
        displayName = decl.get_display_string()
    docname = s.docname
    assert docname
    if (typ != 'identifier'):
        title = contnode.pop(0).astext()
        addParen = 0
        if ((not node.get('refexplicit', False)) and (declaration.objectType == 'function')):
            if isShorthand:
                if (env.config.add_function_parentheses and (typ == 'any')):
                    addParen += 1
                if (env.config.add_function_parentheses and (typ == 'function') and title.endswith('operator()')):
                    addParen += 1
                if (((typ == 'any') or (typ == 'function')) and title.endswith('operator') and displayName.endswith('operator()')):
                    addParen += 1
            elif env.config.add_function_parentheses:
                if ((typ == 'any') and displayName.endswith('()')):
                    addParen += 1
                elif (typ == 'function'):
                    if (title.endswith('()') and (not displayName.endswith('()'))):
                        title = title[:(- 2)]
            elif displayName.endswith('()'):
                addParen += 1
        if (addParen > 0):
            title += ('()' * addParen)
        contnode += nodes.Text(title)
    return (make_refnode(builder, fromdocname, docname, declaration.get_newest_id(), contnode, displayName), declaration.objectType)