<commit_before>// Copyright (C) 2017-2018 <NAME> <<EMAIL>>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.

#include <cppast/cpp_entity_index.hpp>

#include <cppast/detail/assert.hpp>
#include <cppast/cpp_entity.hpp>
#include <cppast/cpp_entity_kind.hpp>
#include <cppast/cpp_file.hpp>

using namespace cppast;

cpp_entity_index::duplicate_definition_error::duplicate_definition_error()
: std::logic_error("duplicate registration of entity definition")
{
}

void cpp_entity_index::register_definition(cpp_entity_id                           id,
                                           type_safe::object_ref<const cpp_entity> entity) const
{
    DEBUG_ASSERT(entity->kind() != cpp_entity_kind::namespace_t,
                 detail::precondition_error_handler{}, "must not be a namespace");
    std::lock_guard<std::mutex> lock(mutex_);
    auto                        result = map_.emplace(std::move(id), value(entity, true));
    if (!result.second)
    {
        // already in map, override declaration
        auto& value = result.first->second;
        if (value.is_definition)
            throw duplicate_definition_error();
        value.is_definition = true;
        value.entity        = entity;
    }
}

bool cpp_entity_index::register_file(cpp_entity_id                         id,
                                     type_safe::object_ref<const cpp_file> file) const
{<commit_msg>ThirdParty: Disable cppast error as it is benign in this case.<commit_after>// Copyright (C) 2017-2018 <NAME> <<EMAIL>>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.

#include <cppast/cpp_entity_index.hpp>

#include <cppast/detail/assert.hpp>
#include <cppast/cpp_entity.hpp>
#include <cppast/cpp_entity_kind.hpp>
#include <cppast/cpp_file.hpp>

using namespace cppast;

cpp_entity_index::duplicate_definition_error::duplicate_definition_error()
: std::logic_error("duplicate registration of entity definition")
{
}

void cpp_entity_index::register_definition(cpp_entity_id                           id,
                                           type_safe::object_ref<const cpp_entity> entity) const
{
    DEBUG_ASSERT(entity->kind() != cpp_entity_kind::namespace_t,
                 detail::precondition_error_handler{}, "must not be a namespace");
    std::lock_guard<std::mutex> lock(mutex_);
    auto                        result = map_.emplace(std::move(id), value(entity, true));
    if (!result.second)
    {
        // already in map, override declaration
        auto& value = result.first->second;
        // Urho3D: Few files trigger this error for some reason. It is ok to ignore in this case.
        // if (value.is_definition)
        //    throw duplicate_definition_error();
        value.is_definition = true;
        value.entity        = entity;
    }
}

bool cpp_entity_index::register_file(cpp_entity_id                         id,
                                     type_safe::object_ref<const cpp_file> file) const
{
{'fraction_non_alphanumeric': 0.10129449838187703, 'fraction_numerical': 0.005501618122977346, 'mean_word_length': 2.6841477949940407, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6098694', 'n_tokens_mistral': 893, 'n_tokens_neox': 866, 'n_words': 211}