'Retrieve members from the given hit.
@param hit {tuple} (elem, scoperef)'

def _members_from_hit(self, hit, allowProtected=None, allowPrivate=None):

    (elem, scoperef) = hit
    elem_type = (elem.get('ilk') or elem.tag)
    namespace_cplns = (self.trg.type == 'namespace-members')
    if (namespace_cplns and (elem_type != 'namespace')):
        raise CodeIntelError(('%r    resolves    to    type    %r,    which    is    not    a    namespace' % (self.expr, elem_type)))
    members = set()
    elem_name = elem.get('name')
    static_cplns = (self.trg.type == 'static-members')
    for child in elem:
        if (child.tag == 'import'):
            continue
        name_prefix = ''
        attributes = child.get('attributes', '').split()
        if ('__hidden__' in attributes):
            continue
        if (not allowProtected):
            if ('protected' in attributes):
                if (allowProtected is None):
                    allowProtected = self._isElemInsideScoperef(elem, self.get_start_scoperef())
                if (not allowProtected):
                    allowPrivate = False
                    self.log("hit    '%s.%s'    is    protected,    not    including", elem_name, child.get('name'))
                    continue
        if (not allowPrivate):
            if ('private' in attributes):
                if (allowPrivate is None):
                    allowPrivate = self._isElemInsideScoperef(elem, self.get_start_scoperef())
                if (not allowPrivate):
                    self.log("hit    '%s.%s'    is    private,    not    including", elem_name, child.get('name'))
                    continue
        if (child.tag == 'variable'):
            if static_cplns:
                if ('static' in attributes):
                    name_prefix = '$'
                    child.tag = 'static    property'
                elif (child.get('ilk') != 'constant'):
                    continue
            elif ('static' in attributes):
                continue
            elif ((child.get('ilk') == 'constant') and (not namespace_cplns)):
                continue
        members.update(self._members_from_elem(child, name_prefix))
    elem_ilk = elem.get('ilk')
    if ((elem_ilk == 'class') or (elem_ilk == 'trait')):
        for classref in (elem.get('classrefs', '').split() + elem.get('traitrefs', '').split()):
            ns_elem = self._namespace_elem_from_scoperef(scoperef)
            if (ns_elem is not None):
                classref = ('\\' + self._fqn_for_expression(classref, scoperef))
            self.debug('_members_from_hit:    Getting    members    for    inherited    %r:    %r', elem_ilk, classref)
            try:
                subhit = self._hit_from_citdl(classref, scoperef)
            except CodeIntelError as ex:
                self.warn(str(ex))
            else:
                if (allowProtected is None):
                    allowProtected = self._isElemInsideScoperef(elem, self.get_start_scoperef())
                members.update(self._members_from_hit(subhit, allowProtected, allowPrivate=False))
    return members
