File indexing completed on 2024-05-26 05:51:58

0001 /*
0002     SPDX-FileCopyrightText: 2022 Waqar Ahmed <waqar.17a@gmail.com>
0003     SPDX-License-Identifier: LGPL-2.0-or-later
0004 */
0005 #pragma once
0006 
0007 #include <QString>
0008 
0009 enum class Formatters {
0010     ClangFormat = 0,
0011     DartFmt,
0012     Prettier,
0013     Jq,
0014     RustFmt,
0015     XmlLint,
0016     GoFmt,
0017     ZigFmt,
0018     CMakeFormat,
0019     Autopep8
0020 };
0021 
0022 inline Formatters formatterForName(const QString &name, Formatters defaultValue)
0023 {
0024     auto eq = [&](const char *s) {
0025         return name.compare(QLatin1String(s), Qt::CaseInsensitive) == 0;
0026     };
0027     if (eq("clangformat") || eq("clang-format")) {
0028         return Formatters::ClangFormat;
0029     }
0030     if (eq("dart") || eq("dartfmt")) {
0031         return Formatters::DartFmt;
0032     }
0033     if (eq("prettier")) {
0034         return Formatters::Prettier;
0035     }
0036     if (eq("jq")) {
0037         return Formatters::Jq;
0038     }
0039     if (eq("rustfmt")) {
0040         return Formatters::RustFmt;
0041     }
0042     if (eq("xmllint")) {
0043         return Formatters::XmlLint;
0044     }
0045     if (eq("gofmt")) {
0046         return Formatters::GoFmt;
0047     }
0048     if (eq("zig") || eq("zigfmt")) {
0049         return Formatters::ZigFmt;
0050     }
0051     if (eq("cmake-format") || eq("cmakeformat")) {
0052         return Formatters::CMakeFormat;
0053     }
0054     if (eq("autopep8")) {
0055         return Formatters::Autopep8;
0056     }
0057     return defaultValue;
0058 }