-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathSettingsState.java
More file actions
304 lines (243 loc) · 9.08 KB
/
SettingsState.java
File metadata and controls
304 lines (243 loc) · 9.08 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
package org.overengineer.inlineproblems.settings;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.intellij.util.xmlb.XmlSerializerUtil;
import com.intellij.util.xmlb.annotations.OptionTag;
import com.intellij.util.xmlb.annotations.Transient;
import lombok.Getter;
import lombok.Setter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.overengineer.inlineproblems.entities.enums.Listener;
import org.overengineer.inlineproblems.utils.ColorConverter;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@Getter
@Setter
@State(
name = "org.overengineer.inlineproblems.settings.SettingsState",
storages = @Storage("OverEngineer_InlineProblems.xml")
)
public class SettingsState implements PersistentStateComponent<SettingsState> {
private boolean showErrors = true;
private boolean highlightErrors = false;
private boolean showErrorsInGutter = false;
private boolean showWarnings = true;
private boolean highlightWarnings = false;
private boolean showWarningsInGutter = false;
private boolean showWeakWarnings = false;
private boolean highlightWeakWarnings = false;
private boolean showWeakWarningsInGutter = false;
private boolean showInfos = false;
private boolean highlightInfos = false;
private boolean showInfosInGutter = false;
/**
* Colors renamed from '<NAME>Color' to '<NAME>Col' to solve
* the compatibility issue with old version persisted xml setting file.
*
* @see <a href="https://github.com/0verEngineer/InlineProblems/pull/10">Github discussion</a>
*/
@OptionTag(converter = ColorConverter.class)
private Color errorBackgroundCol = new Color(0x654243);
@OptionTag(converter = ColorConverter.class)
private Color errorTextCol = new Color(0xEC5151);
@OptionTag(converter = ColorConverter.class)
private Color errorHighlightCol = errorBackgroundCol;
@OptionTag(converter = ColorConverter.class)
private Color warningTextCol = new Color(0xEC821F);
@OptionTag(converter = ColorConverter.class)
private Color warningBackgroundCol = new Color(0x815125);
@OptionTag(converter = ColorConverter.class)
private Color warningHighlightCol = warningBackgroundCol;
@OptionTag(converter = ColorConverter.class)
private Color weakWarningTextCol= new Color(0xC07937);
@OptionTag(converter = ColorConverter.class)
private Color weakWarningBackgroundCol = new Color(0xA47956);
@OptionTag(converter = ColorConverter.class)
private Color weakWarningHighlightCol = weakWarningBackgroundCol;
@OptionTag(converter = ColorConverter.class)
private Color infoTextCol = new Color(0x3BB1CE);
@OptionTag(converter = ColorConverter.class)
private Color infoBackgroundCol = new Color(0x1E5664);
@OptionTag(converter = ColorConverter.class)
private Color infoHighlightCol = infoBackgroundCol;
private int manualScannerDelay = 200;
private boolean drawBoxesAroundErrorLabels = true;
private boolean roundedCornerBoxes = true;
private boolean forceProblemsInSameLine = true;
private boolean useEditorFont = false;
private int inlayFontSizeDelta = 0;
private boolean fillProblemLabels = false;
private boolean boldProblemLabels = false;
private boolean italicProblemLabels = false;
private int problemLineLengthOffsetPixels = 50;
private int enabledListener = Listener.MARKUP_MODEL_LISTENER;
private String problemFilterList = "todo;fixme;open in browser";
private String fileExtensionBlacklist = "";
private List<Integer> additionalErrorSeverities = new ArrayList<>();
private List<Integer> additionalWarningSeverities = new ArrayList<>();
private List<Integer> additionalWeakWarningSeverities = new ArrayList<>();
private List<Integer> additionalInfoSeverities = new ArrayList<>();
private boolean showOnlyHighestSeverityPerLine = false;
private boolean enableHtmlStripping = true;
private boolean enableXmlUnescaping = true;
// migration booleans
private boolean highlightProblemListenerDeprecateMigrationDone = false;
private boolean filterListMigrationDone01 = false;
public static SettingsState getInstance() {
return ApplicationManager.getApplication().getService(SettingsState.class);
}
@Override
public @Nullable SettingsState getState() {
return this;
}
@Override
public void loadState(@NotNull SettingsState state) {
XmlSerializerUtil.copyBean(state, this);
migrateState();
}
@Override
public void noStateLoaded() {
migrateState();
}
private void migrateState() {
// filter list
if (!filterListMigrationDone01) {
List<String> newFilterListEntries = List.of("Consider unknown contexts non-blocking");
for (String entry : newFilterListEntries) {
if (!problemFilterList.contains(entry)) {
problemFilterList += ";" + entry;
}
}
filterListMigrationDone01 = true;
}
// listener
if (!highlightProblemListenerDeprecateMigrationDone) {
if (enabledListener == Listener.HIGHLIGHT_PROBLEMS_LISTENER) {
enabledListener = Listener.MARKUP_MODEL_LISTENER;
}
highlightProblemListenerDeprecateMigrationDone = true;
}
}
public String getAdditionalInfoSeveritiesAsString() {
return getSeverityListAsString(additionalInfoSeverities);
}
public String getAdditionalErrorSeveritiesAsString() {
return getSeverityListAsString(additionalErrorSeverities);
}
public String getAdditionalWarningSeveritiesAsString() {
return getSeverityListAsString(additionalWarningSeverities);
}
public String getAdditionalWeakWarningSeveritiesAsString() {
return getSeverityListAsString(additionalWeakWarningSeverities);
}
private String getSeverityListAsString(List<Integer> severityList) {
return severityList.stream().map(String::valueOf).collect(Collectors.joining("; "));
}
//<editor-fold desc="Handwritten Colors getter/setter to compatible with external callers.">
@Transient
public Color getErrorTextColor() {
return errorTextCol;
}
@Transient
public void setErrorTextColor(Color color) {
this.errorTextCol = color;
}
@Transient
public Color getErrorBackgroundColor() {
return errorBackgroundCol;
}
@Transient
public void setErrorBackgroundColor(Color color) {
this.errorBackgroundCol = color;
}
@Transient
public Color getErrorHighlightColor() {
return errorHighlightCol;
}
@Transient
public void setErrorHighlightColor(Color color) {
this.errorHighlightCol = color;
}
@Transient
public Color getWarningTextColor() {
return warningTextCol;
}
@Transient
public void setWarningTextColor(Color color) {
this.warningTextCol = color;
}
@Transient
public Color getWarningBackgroundColor() {
return warningBackgroundCol;
}
@Transient
public void setWarningBackgroundColor(Color color) {
this.warningBackgroundCol = color;
}
@Transient
public Color getWarningHighlightColor() {
return warningHighlightCol;
}
@Transient
public void setWarningHighlightColor(Color color) {
this.warningHighlightCol = color;
}
@Transient
public Color getWeakWarningTextColor() {
return weakWarningTextCol;
}
@Transient
public void setWeakWarningTextColor(Color color) {
this.weakWarningTextCol = color;
}
@Transient
public Color getWeakWarningBackgroundColor() {
return weakWarningBackgroundCol;
}
@Transient
public void setWeakWarningBackgroundColor(Color color) {
this.weakWarningBackgroundCol = color;
}
@Transient
public Color getWeakWarningHighlightColor() {
return weakWarningHighlightCol;
}
@Transient
public void setWeakWarningHighlightColor(Color color) {
this.weakWarningHighlightCol = color;
}
@Transient
public Color getInfoTextColor() {
return infoTextCol;
}
@Transient
public void setInfoTextColor(Color color) {
this.infoTextCol = color;
}
@Transient
public Color getInfoBackgroundColor() {
return infoBackgroundCol;
}
@Transient
public void setInfoBackgroundColor(Color color) {
this.infoBackgroundCol = color;
}
@Transient
public Color getInfoHighlightColor() {
return infoHighlightCol;
}
@Transient
public void setInfoHighlightColor(Color color) {
this.infoHighlightCol = color;
}
//</editor-fold>
@Transient
public boolean isShowAnyGutterIcons() {
return showErrorsInGutter || showWarningsInGutter || showWeakWarningsInGutter || showInfosInGutter;
}
}