ladybird/Userland/DevTools/HackStudio/ToDoEntries.cpp
Itamar b35293d945 LibCodeComprehension: Re-organize code comprehension related code
This moves all code comprehension-related code to a new library,
LibCodeComprehension.

This also moves some types related to code comprehension tasks (such as
autocomplete, find declaration) out of LibGUI and into
LibCodeComprehension.
2022-05-21 18:15:58 +02:00

40 lines
863 B
C++

/*
* Copyright (c) 2021, Federico Guerinoni <guerinoni.federico@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "ToDoEntries.h"
namespace HackStudio {
ToDoEntries& HackStudio::ToDoEntries::the()
{
static ToDoEntries s_instance;
return s_instance;
}
void ToDoEntries::set_entries(String const& filename, Vector<CodeComprehension::TodoEntry> const&& entries)
{
m_document_to_entries.set(filename, move(entries));
if (on_update)
on_update();
}
Vector<CodeComprehension::TodoEntry> ToDoEntries::get_entries()
{
Vector<CodeComprehension::TodoEntry> ret;
for (auto& it : m_document_to_entries) {
for (auto& entry : it.value)
ret.append({ entry.content, it.key, entry.line, entry.column });
}
return ret;
}
void ToDoEntries::clear_entries()
{
m_document_to_entries.clear();
}
}