

def get_code_element(self, scode_reference, code_elements, simple, fqn, log, insensitive=False):
    log.reset_variables()
    return_code_element = None
    potentials = code_elements
    if (code_elements is None):
        size = 0
    else:
        size = len(code_elements)
    if (size > 0):
        if (size == 1):
            return_code_element = code_elements[0]
            potentials = [return_code_element]
            log.one = True
        elif ((fqn == simple) or (fqn.find(UNKNOWN_PACKAGE) != (- 1)) or (fqn.find(SNIPPET_PACKAGE) != (- 1))):
            return_code_element = code_elements[0]
            log.arbitrary = True
        elif insensitive:
            fqn_lower = fqn.lower()
            sims = [su.pairwise_simil(fqn_lower, code_element.fqn.lower()) for code_element in code_elements]
            max_sim = max(sims)
            index = sims.index(max_sim)
            return_code_element = code_elements[index]
            del potentials[index]
            potentials.insert(0, return_code_element)
            if (max_sim >= FQN_SIMILARITY_THRESHOLD):
                potentials = [return_code_element]
            log.insensitive = True
        else:
            sims = [su.pairwise_simil(fqn, code_element.fqn) for code_element in code_elements]
            max_sim = max(sims)
            index = sims.index(max_sim)
            return_code_element = code_elements[index]
            del potentials[index]
            potentials.insert(0, return_code_element)
            if (max_sim >= FQN_SIMILARITY_THRESHOLD):
                potentials = [return_code_element]
            log.sensitive = True
    filter_results = []
    for afilter in self.class_filters:
        finput = filters.FilterInput(scode_reference, potentials, fqn, log, None, None, filter_results)
        result = afilter.filter(finput)
        potentials = result.potentials
        filter_results.append(result)
    potentials_size = len(potentials)
    if (potentials_size > 0):
        return_code_element = potentials[0]
    else:
        return_code_element = None
    log.custom_filtered = filters.custom_filtered(filter_results)
    log.log_type(simple, fqn, scode_reference, return_code_element, potentials, size, filter_results)
    return (return_code_element, potentials)

dataset/ETHPy150Open bartdag/recodoc2/recodoc2/apps/codebase/linker/java_linkers.py JavaClassLinker.get_code_element/original