summaryrefslogtreecommitdiff
path: root/Userland/DevTools/HackStudio/ToDoEntries.cpp
blob: 9c81dce40d33df28f86fbe3dc466a085e6532fd3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
 * 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(DeprecatedString 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();
}

}