summaryrefslogtreecommitdiff
path: root/Userland/DevTools/HackStudio/Language.cpp
blob: 074c9cce1d69f5b535808d23134a8acb32dce8b6 (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
40
/*
 * Copyright (c) 2020, the SerenityOS developers.
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#include "Language.h"

namespace HackStudio {

Language language_from_file_extension(const String& extension)
{
    VERIFY(!extension.starts_with("."));
    if (extension == "cpp" || extension == "h")
        return Language::Cpp;
    else if (extension == "js")
        return Language::JavaScript;
    else if (extension == "gml")
        return Language::GML;
    else if (extension == "ini")
        return Language::Ini;
    else if (extension == "sh")
        return Language::Shell;

    return Language::Unknown;
}

Language language_from_name(const String& name)
{
    if (name == "Cpp")
        return Language::Cpp;
    if (name == "Javascript")
        return Language::JavaScript;
    if (name == "Shell")
        return Language::Shell;

    return Language::Unknown;
}

}