def visit_cursor(libclang, cursor):
    try:
        kind = cursor.kind.name
    except:
        return None
    if (kind not in ALL_KINDS):
        return None
    if (not libclang.clang_Location_isFromMainFile(cursor.location)):
        return None
    params = None
    tparams = None
    children = None
    name = cursor.spelling
    cursor_type = (cursor.type.spelling if (kind in VAR_KINDS) else None)
    if (kind in FUNCTION_KINDS):
        params = []
        tparams = []
        for child in cursor.get_children():
            if (child.kind == CursorKind.PARM_DECL):
                params.append((child.spelling or child.type.spelling))
            elif (child.kind == CursorKind.TEMPLATE_TYPE_PARAMETER):
                tparams.append(child.spelling)
    if (kind in MEMBER_KINDS):
        if (cursor.semantic_parent != cursor.lexical_parent):
            name = ((cursor.semantic_parent.spelling + '::') + name)
    elif (kind in CLASS_KINDS):
        name = cursor.displayname
        children = []
        for child in cursor.get_children():
            child_outline = visit_cursor(libclang, child)
            if (child_outline is not None):
                children.append(child_outline)
    if (kind == MACRO_INSTANTIATION):
        params = []
        if (name in GTEST_MACROS):
            tokens = list(itertools.islice(cursor.get_tokens(), 1, 6))
            if ((len(tokens) == 5) and ((tokens[0].kind == TokenKind.PUNCTUATION) and (tokens[1].kind == TokenKind.IDENTIFIER) and (tokens[2].kind == TokenKind.PUNCTUATION) and (tokens[3].kind == TokenKind.IDENTIFIER) and (tokens[4].kind == TokenKind.PUNCTUATION))):
                params = [tokens[1].spelling, tokens[3].spelling]
            else:
                return None
        else:
            return None
    ret = {'name': name, 'cursor_kind': kind, 'cursor_type': cursor_type, 'extent': range_dict_relative(cursor.extent), 'params': params, 'tparams': tparams, 'children': children}
    return {k: v for (k, v) in ret.items() if (v is not None)}
def visit_cursor(libclang, cursor):
    try:
        kind = cursor.kind.name
    except:
        return None
    if (kind not in ALL_KINDS):
        return None
    if (not libclang.clang_Location_isFromMainFile(cursor.location)):
        return None
    params = None
    tparams = None
    children = None
    name = cursor.spelling
    cursor_type = (cursor.type.spelling if (kind in VAR_KINDS) else None)
    if (kind in FUNCTION_KINDS):
        params = []
        tparams = []
        for child in cursor.get_children():
            if (child.kind == CursorKind.PARM_DECL):
                params.append((child.spelling or child.type.spelling))
            elif (child.kind == CursorKind.TEMPLATE_TYPE_PARAMETER):
                tparams.append(child.spelling)
    if (kind in MEMBER_KINDS):
        if (cursor.semantic_parent != cursor.lexical_parent):
            name = ((cursor.semantic_parent.spelling + '::') + name)
    elif (kind in CLASS_KINDS):
        name = cursor.displayname
        children = []
        for child in cursor.get_children():
            child_outline = visit_cursor(libclang, child)
            if (child_outline is not None):
                children.append(child_outline)
    if (kind == MACRO_INSTANTIATION):
        params = []
        if (name in GTEST_MACROS):
            tokens = list(itertools.islice(cursor.get_tokens(), 1, 6))
            if ((len(tokens) == 5) and ((tokens[0].kind == TokenKind.PUNCTUATION) and (tokens[1].kind == TokenKind.IDENTIFIER) and (tokens[2].kind == TokenKind.PUNCTUATION) and (tokens[3].kind == TokenKind.IDENTIFIER) and (tokens[4].kind == TokenKind.PUNCTUATION))):
                params = [tokens[1].spelling, tokens[3].spelling]
            else:
                return None
        else:
            return None
    ret = {'name': name, 'cursor_kind': kind, 'cursor_type': cursor_type, 'extent': range_dict_relative(cursor.extent), 'params': params, 'tparams': tparams, 'children': children}
    return {k: v for (k, v) in ret.items() if (v is not None)}