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

Camelcade / Perl5-IDEA / #525521578

05 Jun 2025 08:31AM UTC coverage: 82.354% (+0.06%) from 82.298%
#525521578

push

github

hurricup
Redundant throws

30858 of 37470 relevant lines covered (82.35%)

0.82 hits per line

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

75.51
/plugin/core/src/main/java/com/perl5/lang/perl/idea/run/prove/PerlTestRunConfigurationEditor.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.idea.run.prove;
18

19
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
20
import com.intellij.openapi.fileChooser.FileChooserDialog;
21
import com.intellij.openapi.fileChooser.FileChooserFactory;
22
import com.intellij.openapi.project.Project;
23
import com.intellij.openapi.ui.LabeledComponent;
24
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
25
import com.intellij.openapi.util.NlsContexts;
26
import com.intellij.openapi.util.text.StringUtil;
27
import com.intellij.openapi.vfs.VirtualFile;
28
import com.intellij.ui.RawCommandLineEditor;
29
import com.intellij.ui.components.fields.ExpandableTextField;
30
import com.intellij.util.containers.ContainerUtil;
31
import com.perl5.PerlBundle;
32
import com.perl5.lang.perl.idea.run.GenericPerlRunConfiguration;
33
import com.perl5.lang.perl.idea.run.GenericPerlRunConfigurationEditor;
34
import com.perl5.lang.perl.idea.run.GenericPerlRunConfigurationEditorPanel;
35
import org.jetbrains.annotations.NotNull;
36

37
import javax.swing.*;
38
import java.awt.*;
39
import java.util.ArrayList;
40
import java.util.List;
41

42
import static com.perl5.lang.perl.idea.run.GenericPerlRunConfiguration.FILES_JOINER;
43
import static com.perl5.lang.perl.idea.run.GenericPerlRunConfiguration.FILES_PARSER;
44

45
class PerlTestRunConfigurationEditor extends GenericPerlRunConfigurationEditor<PerlAbstractTestRunConfiguration> {
46
  private final @NotNull PerlAbstractTestRunConfigurationProducer<? extends PerlAbstractTestRunConfiguration> myProducer;
47

48
  public PerlTestRunConfigurationEditor(@NotNull Project project,
49
                                        @NotNull PerlAbstractTestRunConfigurationProducer<? extends PerlAbstractTestRunConfiguration> producer) {
50
    super(project);
1✔
51
    myProducer = producer;
1✔
52
  }
1✔
53

54
  @Override
55
  protected @NotNull PerlTestRunConfigurationEditor.ArgumentsPanel createCommonArgumentsPanel() {
56
    return new ArgumentsPanel(myProject);
1✔
57
  }
58

59

60
  protected class ArgumentsPanel extends GenericPerlRunConfigurationEditorPanel<PerlAbstractTestRunConfiguration> {
61
    private JComboBox<Integer> myJobsCombobox;
62
    private LabeledComponent<JComboBox<Integer>> myLabeledJobsCombobox;
63

64
    private RawCommandLineEditor myTestScriptArgumentsEditor;
65
    private LabeledComponent<RawCommandLineEditor> myLabeledTestScriptArgumentsEditor;
66

67
    protected ArgumentsPanel(@NotNull Project project) {
1✔
68
      super(project);
1✔
69
    }
1✔
70

71
    @Override
72
    protected @NotNull String getProgramArgumentsLabel() {
73
      return PerlBundle.message("perl.run.test.runner.arguemnts");
1✔
74
    }
75

76
    @Override
77
    protected void createLabeledComponents() {
78
      super.createLabeledComponents();
1✔
79

80
      ArrayList<Integer> jobs = new ArrayList<>();
1✔
81
      for (int i = 1; i <= 32; i++) {
1✔
82
        jobs.add(i);
1✔
83
      }
84

85
      myJobsCombobox = new JComboBox<>(jobs.toArray(new Integer[0]));
1✔
86
      myLabeledJobsCombobox = LabeledComponent.create(myJobsCombobox, PerlBundle.message("perl.run.option.jobs.number"));
1✔
87
      myLabeledJobsCombobox.setLabelLocation(BorderLayout.WEST);
1✔
88

89
      myTestScriptArgumentsEditor = new RawCommandLineEditor();
1✔
90
      myLabeledTestScriptArgumentsEditor =
1✔
91
        LabeledComponent.create(myTestScriptArgumentsEditor, PerlBundle.message("perl.run.option.test.script.arguments"));
1✔
92
      myLabeledTestScriptArgumentsEditor.setLabelLocation(BorderLayout.WEST);
1✔
93
    }
1✔
94

95
    @Override
96
    protected void reset(PerlAbstractTestRunConfiguration runConfiguration) {
97
      super.reset(runConfiguration);
1✔
98
      myJobsCombobox.setSelectedItem(runConfiguration.getJobsNumber());
1✔
99
      myTestScriptArgumentsEditor.setText(runConfiguration.getTestScriptParameters());
1✔
100
    }
1✔
101

102
    @Override
103
    protected void applyTo(PerlAbstractTestRunConfiguration runConfiguration) {
104
      super.applyTo(runConfiguration);
1✔
105
      Object item = myJobsCombobox.getSelectedItem();
1✔
106
      runConfiguration.setJobsNumber(item instanceof Integer integer ? integer : PerlTestRunConfiguration.DEFAULT_JOBS_NUMBER);
1✔
107
      runConfiguration.setTestScriptParameters(myTestScriptArgumentsEditor.getText());
1✔
108
    }
1✔
109

110
    @Override
111
    protected @NotNull List<LabeledComponent<?>> getLabeledComponents() {
112
      List<LabeledComponent<?>> parentComponents = new ArrayList<>(super.getLabeledComponents());
1✔
113
      parentComponents.add(myLabeledJobsCombobox);
1✔
114
      parentComponents.add(myLabeledTestScriptArgumentsEditor);
1✔
115
      return parentComponents;
1✔
116
    }
117

118
    @Override
119
    protected @NotNull @NlsContexts.Label String getScriptFieldLabelText() {
120
      return PerlBundle.message("perl.run.prove.option.script.label");
1✔
121
    }
122

123
    @Override
124
    protected @NotNull TextFieldWithBrowseButton createTextFieldForScript() {
125
      TextFieldWithBrowseButton fieldWithBrowseButton = new TextFieldWithBrowseButton(new ExpandableTextField(FILES_PARSER, FILES_JOINER));
1✔
126
      fieldWithBrowseButton.addActionListener(e -> {
1✔
127
        var fileChooserDescriptor = createFileChooserDescriptor();
×
128

129
        List<VirtualFile> filesToSelect = GenericPerlRunConfiguration.computeVirtualFilesFromPaths(fieldWithBrowseButton.getText());
×
130
        final FileChooserDialog chooser =
131
          FileChooserFactory.getInstance().createFileChooser(fileChooserDescriptor, myProject, fieldWithBrowseButton);
×
132
        VirtualFile[] choosenFiles = chooser.choose(myProject, filesToSelect.toArray(VirtualFile.EMPTY_ARRAY));
×
133
        fieldWithBrowseButton.setText(StringUtil.join(ContainerUtil.map(choosenFiles, VirtualFile::getPath), " "));
×
134
      });
×
135
      return fieldWithBrowseButton;
1✔
136
    }
137

138
    private @NotNull FileChooserDescriptor createFileChooserDescriptor() {
139
      FileChooserDescriptor fileChooserDescriptor = new FileChooserDescriptor(true, true, false, false, false, true) {
×
140
        @SuppressWarnings("deprecation")
141
        @Override
142
        public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
143
          return getRunConfigurationProducer().isOurFile(file);
×
144
        }
145
      };
146
      fileChooserDescriptor.setTitle(PerlBundle.message("perl.run.prove.config.select.script.header"));
×
147
      fileChooserDescriptor.setDescription(PerlBundle.message("perl.run.prove.config.select.script.prompt"));
×
148
      return fileChooserDescriptor;
×
149
    }
150

151
    @Override
152
    protected final @NotNull PerlAbstractTestRunConfigurationProducer<? extends PerlAbstractTestRunConfiguration> getRunConfigurationProducer() {
153
      return myProducer;
×
154
    }
155
  }
156
}
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