'Resolve the given CITDL expression (starting at the given
scope) down to a non-import/non-variable hit.'

def _hit_from_citdl(self, expr, scoperef, defn_only=False):

    self.eval_depth += 1
    self.log('_hit_from_citdl::    expr:    %r,    scoperef:    %r', expr, scoperef)
    try:
        self._check_infinite_recursion(expr)
    except EvalError:
        scoperef = self.parent_scoperef_from_scoperef(scoperef)
        if (scoperef is None):
            raise
        self.debug("_hit_from_citdl:    recursion    found    for    '%s',    moving    to    parent    scope    %r", expr, scoperef)
    tokens = list(self._tokenize_citdl_expr(expr))
    self.log('_hit_from_citdl::    expr    tokens:    %r', tokens)
    (hits, nconsumed) = self._hits_from_first_part(tokens, scoperef)
    if (not hits):
        if (self.trg.type == 'namespace-members'):
            return (None, None)
        raise CodeIntelError(("could    not    resolve    first    part    of    '%s'" % expr))
    self.debug('_hit_from_citdl::    first    part:    %r    ->    %r', tokens[:nconsumed], hits)
    remaining_tokens = tokens[nconsumed:]
    while remaining_tokens:
        new_hits = []
        for hit in hits:
            new_hit = None
            try:
                self.debug('_hit_from_citdl::    resolve    %r    on    %r    in    %r', remaining_tokens, *hit)
                if (remaining_tokens[0] == '()'):
                    new_hit = self._hit_from_call(*hit)
                    nconsumed = 1
                else:
                    (new_hit, nconsumed) = self._hit_from_getattr(remaining_tokens, *hit)
                remaining_tokens = remaining_tokens[nconsumed:]
            except CodeIntelError as ex:
                self.debug('error    %s', ex)
            if new_hit:
                new_hits.append(new_hit)
        if (not new_hits):
            break
        hits = new_hits
    if (not hits):
        raise CodeIntelError(("could    not    resolve    first    part    of    '%s'" % expr))
    if (len(hits) > 2):
        self.debug('_hit_from_citdl::    multiple    hits    found,    returning    the    first    hit')
    hit = hits[0]
    (elem, scoperef) = hit
    if ((elem.tag == 'variable') and (not defn_only)):
        (elem, scoperef) = self._hit_from_variable_type_inference(elem, scoperef)
    self.info("_hit_from_citdl::    found    '%s'    =>    %s    on    %s", expr, elem, scoperef)
    return (elem, scoperef)
