1// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#include "stylelspjava.h"
6#include "textedittabwidget/textedit.h"
7#include "textedittabwidget/style/stylecolor.h"
8#include "textedittabwidget/style/stylejsonfile.h"
9
10StyleLspJava::StyleLspJava(TextEdit *parent)
11 : StyleLsp (parent)
12{
13
14}
15
16
17StyleLsp::IndicStyleExt StyleLspJava::symbolIndic(lsp::SemanticTokenType::type_value token,
18 QList<lsp::SemanticTokenModifier::type_index> modifier)
19{
20 Q_UNUSED(modifier);
21 IndicStyleExt result;
22
23 auto jsonFile = edit()->getStyleFile();
24 if (jsonFile->setTheme(StyleJsonFile::Theme::get()->Dark)) {
25 QJsonObject tempObj;
26 int tempFore = 0;
27 tempObj = jsonFile->value(StyleJsonFile::Key_1::get()->Self).toObject();
28 tempFore = StyleColor::color(tempObj.value(StyleJsonFile::Key_2::get()->Foreground).toString().toInt(nullptr, 16));
29 if (lsp::SemanticTokenType::get()->Namespace == token) {
30 tempObj = jsonFile->value(StyleJsonFile::Key_1::get()->Namespace).toObject();
31 tempFore = StyleColor::color(tempObj.value(StyleJsonFile::Key_2::get()->Foreground).toString().toInt(nullptr, 16));
32 }
33 if (lsp::SemanticTokenType::get()->Type == token) {
34 tempObj = jsonFile->value(StyleJsonFile::Key_1::get()->Type).toObject();
35 tempFore = StyleColor::color(tempObj.value(StyleJsonFile::Key_2::get()->Foreground).toString().toInt(nullptr, 16));
36 }
37 if (lsp::SemanticTokenType::get()->Class == token) {
38 tempObj = jsonFile->value(StyleJsonFile::Key_1::get()->Class).toObject();
39 tempFore = StyleColor::color(tempObj.value(StyleJsonFile::Key_2::get()->Foreground).toString().toInt(nullptr, 16));
40 }
41 if (lsp::SemanticTokenType::get()->Enum == token) {
42 tempObj = jsonFile->value(StyleJsonFile::Key_1::get()->Enumeration).toObject();
43 tempFore = StyleColor::color(tempObj.value(StyleJsonFile::Key_2::get()->Foreground).toString().toInt(nullptr, 16));
44 }
45 if (lsp::SemanticTokenType::get()->Interface == token) {
46 tempObj = jsonFile->value(StyleJsonFile::Key_1::get()->Text).toObject();
47 tempFore = StyleColor::color(tempObj.value(StyleJsonFile::Key_2::get()->Foreground).toString().toInt(nullptr, 16));
48 }
49 if (lsp::SemanticTokenType::get()->Struct == token) {
50 tempObj = jsonFile->value(StyleJsonFile::Key_1::get()->Text).toObject();
51 tempFore = StyleColor::color(tempObj.value(StyleJsonFile::Key_2::get()->Foreground).toString().toInt(nullptr, 16));
52 }
53 if (lsp::SemanticTokenType::get()->TypeParameter == token) {
54 tempObj = jsonFile->value(StyleJsonFile::Key_1::get()->Variable).toObject();
55 tempFore = StyleColor::color(tempObj.value(StyleJsonFile::Key_2::get()->Foreground).toString().toInt(nullptr, 16));
56 }
57 if (lsp::SemanticTokenType::get()->Parameter == token){
58 tempObj = jsonFile->value(StyleJsonFile::Key_1::get()->Text).toObject();
59 tempFore = StyleColor::color(tempObj.value(StyleJsonFile::Key_2::get()->Foreground).toString().toInt(nullptr, 16));
60 }
61 if (lsp::SemanticTokenType::get()->Variable == token){
62 tempObj = jsonFile->value(StyleJsonFile::Key_1::get()->Variable).toObject();
63 tempFore = StyleColor::color(tempObj.value(StyleJsonFile::Key_2::get()->Foreground).toString().toInt(nullptr, 16));
64 }
65 if (lsp::SemanticTokenType::get()->Property == token){
66 tempObj = jsonFile->value(StyleJsonFile::Key_1::get()->Property).toObject();
67 tempFore = StyleColor::color(tempObj.value(StyleJsonFile::Key_2::get()->Foreground).toString().toInt(nullptr, 16));
68 }
69 if (lsp::SemanticTokenType::get()->EnumMember == token){
70 tempObj = jsonFile->value(StyleJsonFile::Key_1::get()->Enumeration).toObject();
71 tempFore = StyleColor::color(tempObj.value(StyleJsonFile::Key_2::get()->Foreground).toString().toInt(nullptr, 16));
72 }
73 if (lsp::SemanticTokenType::get()->Event == token){
74 tempObj = jsonFile->value(StyleJsonFile::Key_1::get()->Text).toObject();
75 tempFore = StyleColor::color(tempObj.value(StyleJsonFile::Key_2::get()->Foreground).toString().toInt(nullptr, 16));
76 }
77 if (lsp::SemanticTokenType::get()->Function == token){
78 tempObj = jsonFile->value(StyleJsonFile::Key_1::get()->Function).toObject();
79 tempFore = StyleColor::color(tempObj.value(StyleJsonFile::Key_2::get()->Foreground).toString().toInt(nullptr, 16));
80 }
81 if (lsp::SemanticTokenType::get()->Method == token){
82 tempObj = jsonFile->value(StyleJsonFile::Key_1::get()->FunctionDeclaration).toObject();
83 tempFore = StyleColor::color(tempObj.value(StyleJsonFile::Key_2::get()->Foreground).toString().toInt(nullptr, 16));
84 }
85 if (lsp::SemanticTokenType::get()->Macro == token){
86 tempObj = jsonFile->value(StyleJsonFile::Key_1::get()->Macro).toObject();
87 tempFore = StyleColor::color(tempObj.value(StyleJsonFile::Key_2::get()->Foreground).toString().toInt(nullptr, 16));
88 }
89 if (lsp::SemanticTokenType::get()->Keyword == token){
90 tempObj = jsonFile->value(StyleJsonFile::Key_1::get()->Keyword).toObject();
91 tempFore = StyleColor::color(tempObj.value(StyleJsonFile::Key_2::get()->Foreground).toString().toInt(nullptr, 16));
92 }
93 if (lsp::SemanticTokenType::get()->Modifier == token){
94 tempObj = jsonFile->value(StyleJsonFile::Key_1::get()->Keyword).toObject();
95 tempFore = StyleColor::color(tempObj.value(StyleJsonFile::Key_2::get()->Foreground).toString().toInt(nullptr, 16));
96 }
97 if (lsp::SemanticTokenType::get()->Comment == token){
98 tempObj = jsonFile->value(StyleJsonFile::Key_1::get()->Comment).toObject();
99 tempFore = StyleColor::color(tempObj.value(StyleJsonFile::Key_2::get()->Foreground).toString().toInt(nullptr, 16));
100 }
101 if (lsp::SemanticTokenType::get()->String == token){
102 tempObj = jsonFile->value(StyleJsonFile::Key_1::get()->String).toObject();
103 tempFore = StyleColor::color(tempObj.value(StyleJsonFile::Key_2::get()->Foreground).toString().toInt(nullptr, 16));
104 }
105 if (lsp::SemanticTokenType::get()->Number == token){
106 tempObj = jsonFile->value(StyleJsonFile::Key_1::get()->Number).toObject();
107 tempFore = StyleColor::color(tempObj.value(StyleJsonFile::Key_2::get()->Foreground).toString().toInt(nullptr, 16));
108 }
109 if (lsp::SemanticTokenType::get()->Regexp == token){
110 tempObj = jsonFile->value(StyleJsonFile::Key_1::get()->String).toObject();
111 tempFore = StyleColor::color(tempObj.value(StyleJsonFile::Key_2::get()->Foreground).toString().toInt(nullptr, 16));
112 }
113 if (lsp::SemanticTokenType::get()->Operator == token){
114 tempObj = jsonFile->value(StyleJsonFile::Key_1::get()->Operators).toObject();
115 tempFore = StyleColor::color(tempObj.value(StyleJsonFile::Key_2::get()->Foreground).toString().toInt(nullptr, 16));
116 }
117 result.fore[INDIC_TEXTFORE] = tempFore;
118 }
119 return result;
120}
121