'Resolve the given CITDL expression (starting at the given
scope) down to a non-import/non-variable hit.
The tokens contain ::\'s and .\'s so we know when we should have
a namespace on the left, and when we should have a class or object.'

def _hits_from_citdl(self, expr, resolve_var=True, only_scoperef=None):

    tokens = self._tokenize_citdl_expr(expr)
    self.debug('_hit_from_citdl:    expr    tokens:    %r,    look    in    %d    scopes', tokens, ((only_scoperef and 1) or len(self._base_scoperefs)))
    hits = self._hits_from_first_part(tokens[0], only_scoperef)
    if (not hits):
        return NO_HITS
    hits_var = []
    prev_tok = first_token = tokens[0]
    if (resolve_var and ((len(tokens) > 1) or (self.trg.form != TRG_FORM_DEFN))):
        first_hit = hits[0]
        if self._hit_helper.is_variable(first_hit):
            hits_var = []
            for h in hits:
                hits_var += (self._hits_from_variable_type_inference(h) or [])
            hits = [h for h in hits_var if (not self._hit_helper.is_variable(h))]
            if (not hits):
                var_name = self._hit_helper.get_name(first_hit)
                self.debug("_hit_from_citdl:    failed    to    resolve    variable    '%r'", var_name)
                return NO_HITS
            prev_tok = (hits[0][0].get('name', None) or tokens[0])
    hits_final = hits
    idx = 1
    lim_sub1 = (len(tokens) - 1)
    if (idx <= lim_sub1):
        if (tokens[1] == '::'):
            hits = [h for h in hits if self._hit_helper.is_compound(h)]
            if (not hits):
                self.debug("_hit_from_citdl:    trying    to    do    namespace    resolution    on    %s    '%r'", self._hit_helper.get_type(hits[0]), self._hit_helper.get_name(hits[0]))
                return NO_HITS
    while ((idx <= lim_sub1) and hits):
        tok = tokens[idx]
        if (tok == '::'):
            filter_type = _NAMESPACE_RESOLUTION
        elif (tok == '.'):
            filter_type = _CLASS_RESOLUTION
        else:
            self.debug("_hit_from_citdl:    got    an    unexpected    resolution    op    of    '%r'", tok)
            return NO_HITS
        idx += 1
        if (idx > lim_sub1):
            break
        tok = tokens[idx]
        new_hits = []
        for hit in hits:
            new_hits += (self._hits_from_getattr(hit, tok, filter_type) or [])
        if (not new_hits):
            break
        hits = [(x[0], (x[1][0], (x[1][1] + [prev_tok]))) for x in new_hits]
        hits_final = hits
        prev_tok = tok
        idx += 1
    return hits_final
