• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Camelcade / Perl5-IDEA / #525521551

26 May 2025 11:24AM UTC coverage: 82.32% (+0.001%) from 82.319%
#525521551

push

github

hurricup
Migrated to the presentation property

1 of 1 new or added line in 1 file covered. (100.0%)

148 existing lines in 15 files now uncovered.

30897 of 37533 relevant lines covered (82.32%)

0.82 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

58.62
/plugin/debugger/src/main/java/com/perl5/lang/perl/debugger/PerlDebuggerSettings.java
1
/*
2
 * Copyright 2015-2025 Alexandr Evstigneev
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 * http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16

17
package com.perl5.lang.perl.debugger;
18

19
import com.intellij.openapi.options.Configurable;
20
import com.intellij.openapi.options.SearchableConfigurable;
21
import com.intellij.openapi.ui.VerticalFlowLayout;
22
import com.intellij.openapi.util.text.StringUtil;
23
import com.intellij.ui.TableUtil;
24
import com.intellij.ui.ToolbarDecorator;
25
import com.intellij.ui.table.JBTable;
26
import com.intellij.util.containers.ContainerUtil;
27
import com.intellij.util.ui.ColumnInfo;
28
import com.intellij.util.ui.FormBuilder;
29
import com.intellij.util.ui.ListTableModel;
30
import com.intellij.util.xmlb.annotations.Attribute;
31
import com.intellij.util.xmlb.annotations.Tag;
32
import com.intellij.xdebugger.settings.DebuggerSettingsCategory;
33
import com.intellij.xdebugger.settings.XDebuggerSettings;
34
import com.perl5.PerlBundle;
35
import org.jetbrains.annotations.Nls;
36
import org.jetbrains.annotations.NotNull;
37
import org.jetbrains.annotations.Nullable;
38
import org.jetbrains.annotations.TestOnly;
39

40
import javax.swing.*;
41
import javax.swing.table.TableCellEditor;
42
import java.util.*;
43

44
public class PerlDebuggerSettings extends XDebuggerSettings<PerlDebuggerSettings> {
45
  @Tag("dataRenderers")
1✔
46
  private List<Item> myDataRenderers = new ArrayList<>();
47

48
  public PerlDebuggerSettings() {
49
    super("perl5");
1✔
50
  }
1✔
51

52
  @Override
53
  public @NotNull Collection<? extends Configurable> createConfigurables(@NotNull DebuggerSettingsCategory category) {
54
    if (category == DebuggerSettingsCategory.DATA_VIEWS) {
1✔
55
      return Collections.singletonList(new DataViewsConfigurable());
1✔
56
    }
UNCOV
57
    return super.createConfigurables(category);
×
58
  }
59

60
  @Override
61
  public @Nullable PerlDebuggerSettings getState() {
UNCOV
62
    return this;
×
63
  }
64

65
  public List<Item> getDataRenderers() {
66
    return new ArrayList<>(ContainerUtil.map(myDataRenderers, Item::new));
1✔
67
  }
68

69
  @Override
70
  public void loadState(@NotNull PerlDebuggerSettings state) {
UNCOV
71
    myDataRenderers = new ArrayList<>(ContainerUtil.filter(state.myDataRenderers, Item::isValid));
×
UNCOV
72
  }
×
73

74
  @TestOnly
75
  public void setDataRenderers(@NotNull List<? extends Item> renderers) {
76
    myDataRenderers = new ArrayList<>(renderers);
1✔
77
  }
1✔
78

79
  public static @NotNull PerlDebuggerSettings getInstance() {
80
    return getInstance(PerlDebuggerSettings.class);
1✔
81
  }
82

83
  @Tag("entry")
84
  public static class Item {
85
    @Attribute("package")
86
    String namespaceName;
87
    @Attribute("expression")
88
    String renderExpression;
89

UNCOV
90
    public Item() {
×
UNCOV
91
    }
×
92

93
    public Item(@NotNull String namespaceName, @NotNull String renderExpression) {
1✔
94
      this.namespaceName = namespaceName;
1✔
95
      this.renderExpression = renderExpression;
1✔
96
    }
1✔
97

98
    public Item(Item copy) {
1✔
99
      this.namespaceName = copy.namespaceName;
1✔
100
      this.renderExpression = copy.renderExpression;
1✔
101
    }
1✔
102

103
    public boolean isValid() {
104
      return StringUtil.isNotEmpty(namespaceName) && StringUtil.isNotEmpty(renderExpression);
1✔
105
    }
106

107
    @Override
108
    public boolean equals(Object o) {
109
      if (this == o) {
1✔
UNCOV
110
        return true;
×
111
      }
112
      if (o == null || getClass() != o.getClass()) {
1✔
113
        return false;
×
114
      }
115

116
      Item item = (Item)o;
1✔
117

118
      if (!Objects.equals(namespaceName, item.namespaceName)) {
1✔
UNCOV
119
        return false;
×
120
      }
121
      return Objects.equals(renderExpression, item.renderExpression);
1✔
122
    }
123

124
    @Override
125
    public int hashCode() {
UNCOV
126
      int result = namespaceName != null ? namespaceName.hashCode() : 0;
×
UNCOV
127
      result = 31 * result + (renderExpression != null ? renderExpression.hashCode() : 0);
×
UNCOV
128
      return result;
×
129
    }
130
  }
131

132
  private static class MyModel extends ListTableModel<Item> {
133
    public MyModel() {
134
      super(new ClassColumnInfo(), new RendererColumnInfo());
1✔
135
      setSortable(true);
1✔
136
    }
1✔
137
  }
138

139
  private static class ClassColumnInfo extends ColumnInfo<Item, String> {
140
    public ClassColumnInfo() {
141
      super(PerlBundle.message("perl.debugger.settings.class.column.title"));
1✔
142
    }
1✔
143

144
    @Override
145
    public @Nullable String valueOf(Item item) {
UNCOV
146
      return item.namespaceName;
×
147
    }
148

149
    @Override
150
    public void setValue(Item item, String value) {
UNCOV
151
      item.namespaceName = value;
×
UNCOV
152
    }
×
153

154
    @Override
155
    public boolean isCellEditable(Item item) {
UNCOV
156
      return true;
×
157
    }
158
  }
159

160
  private static class RendererColumnInfo extends ColumnInfo<Item, String> {
161
    public RendererColumnInfo() {
162
      super(PerlBundle.message("perl.debugger.settings.renderer.column.title"));
1✔
163
    }
1✔
164

165
    @Override
166
    public @Nullable String valueOf(Item entry) {
UNCOV
167
      return entry.renderExpression;
×
168
    }
169

170
    @Override
171
    public void setValue(Item item, String value) {
UNCOV
172
      item.renderExpression = value;
×
UNCOV
173
    }
×
174

175
    @Override
176
    public boolean isCellEditable(Item item) {
UNCOV
177
      return true;
×
178
    }
179
  }
180

181
  private class DataViewsConfigurable extends JBTable implements SearchableConfigurable {
182
    public DataViewsConfigurable() {
1✔
183
      super(new MyModel());
1✔
184
    }
1✔
185

186
    @Override
187
    public @NotNull String getId() {
UNCOV
188
      return "perl5.debugger.type.renderers";
×
189
    }
190

191
    @Override
192
    public @Nls(capitalization = Nls.Capitalization.Title) String getDisplayName() {
UNCOV
193
      return PerlBundle.message("perl.debugger.settings.type.renderers.title");
×
194
    }
195

196
    @Override
197
    public @Nullable JComponent createComponent() {
198
      JTextPane textPane = new JTextPane();
1✔
199
      textPane.setText(PerlBundle.message("perl.debugger.settings.type.renderers.explanation"));
1✔
200
      JPanel panel = FormBuilder.createFormBuilder()
1✔
201
        .addComponent(textPane)
1✔
202
        .addComponent(ToolbarDecorator.createDecorator(this).setAddAction(action -> {
1✔
UNCOV
203
          final TableCellEditor cellEditor = getCellEditor();
×
UNCOV
204
          if (cellEditor != null) {
×
UNCOV
205
            cellEditor.stopCellEditing();
×
206
          }
207
          MyModel model = getModel();
×
208

UNCOV
209
          int indexToEdit = -1;
×
210

UNCOV
211
          for (Item item : model.getItems()) {
×
212
            if (StringUtil.isEmpty(item.namespaceName)) {
×
UNCOV
213
              indexToEdit = model.indexOf(item);
×
214
              break;
×
215
            }
216
          }
×
217

UNCOV
218
          if (indexToEdit == -1) {
×
219
            model.addRow(new Item("Foo::Bar", "$it->to_string()"));
×
UNCOV
220
            indexToEdit = model.getRowCount() - 1;
×
221
          }
222

223
          TableUtil.editCellAt(this, indexToEdit, 0);
×
224
        }).createPanel())
1✔
225
        .getPanel();
1✔
226
      panel.setLayout(new VerticalFlowLayout());
1✔
227

228
      getColumnModel().getColumn(0).setPreferredWidth(200);
1✔
229
      getColumnModel().getColumn(1).setPreferredWidth(600);
1✔
230

231
      return panel;
1✔
232
    }
233

234
    @Override
235
    public boolean isModified() {
236
      return !myDataRenderers.equals(getModelState());
1✔
237
    }
238

239
    @Override
240
    public void apply() {
241
      myDataRenderers = new ArrayList<>(ContainerUtil.map(getModelState(), Item::new));
1✔
242
    }
1✔
243

244
    private List<Item> getModelState() {
245
      return new ArrayList<>(ContainerUtil.filter(getModel().getItems(), Item::isValid));
1✔
246
    }
247

248
    @Override
249
    public MyModel getModel() {
250
      return (MyModel)super.getModel();
1✔
251
    }
252

253
    @Override
254
    public void reset() {
255
      getModel().setItems(getDataRenderers());
1✔
256
    }
1✔
257
  }
258
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc