1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. |
2 | // |
3 | // SPDX-License-Identifier: GPL-3.0-or-later |
4 | |
5 | #include "extendedproject.h" |
6 | |
7 | #include "common/lsp/protocol/new/basicjsonstructures.h" |
8 | |
9 | #include <QMetaType> |
10 | #include <QHash> |
11 | |
12 | namespace newlsp |
13 | { |
14 | |
15 | uint qHash(const ProjectKey &key, uint seed) |
16 | { |
17 | return ::qHash(QString::fromStdString(key.workspace) |
18 | + QString::fromStdString(key.language), seed); |
19 | } |
20 | |
21 | bool operator ==(const ProjectKey &t1, const ProjectKey &t2) |
22 | { |
23 | return t1.workspace == t2.workspace |
24 | && t2.language == t2.language; |
25 | } |
26 | |
27 | std::string toJsonValueStr(const ProjectKey &val) |
28 | { |
29 | std::string ret; |
30 | ret = json::addValue(ret, json::KV{"language" , val.language}); |
31 | ret = json::addValue(ret, json::KV{"workspace" , val.workspace}); |
32 | return json::addScope(ret); |
33 | } |
34 | |
35 | std::string toJsonValueStr(const LanuchLspServerParams &val) |
36 | { |
37 | std::string ret; |
38 | ret = json::addValue(ret, json::KV{"projectKey" , val.projectKey}); |
39 | return json::addScope(ret); |
40 | } |
41 | |
42 | std::string toJsonValueStr(const SelectLspServerParams &val) |
43 | { |
44 | std::string ret; |
45 | ret = json::addValue(ret, json::KV{"projectKey" , val.projectKey}); |
46 | return json::addScope(ret); |
47 | } |
48 | |
49 | QJsonObject toQJsonObject(const ProjectKey &val) |
50 | { |
51 | QJsonObject ret; |
52 | ret["language" ] = QString::fromStdString(val.language); |
53 | ret["workspace" ] = QString::fromStdString(val.workspace); |
54 | return ret; |
55 | } |
56 | |
57 | ProjectKey::ProjectKey() |
58 | { |
59 | qRegisterMetaType<newlsp::ProjectKey>("newlsp::ProjectKey" ); |
60 | } |
61 | |
62 | ProjectKey::ProjectKey(const std::string &language, const std::string &workspace) |
63 | : language(language), workspace(workspace) |
64 | { |
65 | qRegisterMetaType<newlsp::ProjectKey>("newlsp::ProjectKey" ); |
66 | } |
67 | |
68 | ProjectKey::ProjectKey(const ProjectKey &other) |
69 | : language(other.language), workspace(other.workspace) |
70 | { |
71 | qRegisterMetaType<newlsp::ProjectKey>("newlsp::ProjectKey" ); |
72 | } |
73 | |
74 | } |
75 | |