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

Camelcade / Perl5-IDEA / #525521543

22 May 2025 09:13AM UTC coverage: 82.34% (+0.1%) from 82.228%
#525521543

push

github

hurricup
Improved localization handling

Still imperfect, but good enough

0 of 2 new or added lines in 1 file covered. (0.0%)

113 existing lines in 7 files now uncovered.

30912 of 37542 relevant lines covered (82.34%)

0.82 hits per line

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

0.0
/plugin/core/src/main/java/com/perl5/lang/perl/idea/actions/PerlUnmarkSourceRootAction.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.actions;
18

19
import com.intellij.icons.AllIcons;
20
import com.intellij.openapi.actionSystem.AnActionEvent;
21
import com.intellij.openapi.actionSystem.Presentation;
22
import com.intellij.openapi.module.Module;
23
import com.intellij.openapi.projectRoots.impl.PerlModuleExtension;
24
import com.intellij.openapi.roots.ui.configuration.ModuleSourceRootEditHandler;
25
import com.intellij.openapi.vfs.VirtualFile;
26
import com.intellij.ui.LayeredIcon;
27
import com.perl5.PerlBundle;
28
import com.perl5.PerlIcons;
29
import com.perl5.lang.perl.idea.modules.PerlSourceRootType;
30
import org.jetbrains.annotations.NotNull;
31

32
import javax.swing.*;
33
import java.util.List;
34

35
public class PerlUnmarkSourceRootAction extends PerlSourceRootAction {
36

37
  public PerlUnmarkSourceRootAction() {
×
38
    getTemplatePresentation().setText(PerlBundle.message("perl.action.unmark.default"));
×
UNCOV
39
  }
×
40

41
  @Override
42
  public void update(@NotNull AnActionEvent e) {
43
    Presentation presentation = e.getPresentation();
×
44
    RootsSelection selection = getSelection(e);
×
45
    if (selection.myModule == null) {
×
46
      presentation.setEnabledAndVisible(false);
×
UNCOV
47
      return;
×
48
    }
49
    boolean enabled = isEnabled(selection, selection.myModule);
×
50
    presentation.setEnabledAndVisible(enabled);
×
51
    if (!enabled) {
×
UNCOV
52
      return;
×
53
    }
54
    List<VirtualFile> virtualFiles = getFilesFromSelection(selection);
×
55
    PerlModuleExtension perlModuleExtension = PerlModuleExtension.getInstance(selection.myModule);
×
56
    if (perlModuleExtension == null || virtualFiles.isEmpty()) {
×
UNCOV
57
      return;
×
58
    }
59

60
    if (virtualFiles.size() == 1) {
×
61
      PerlSourceRootType type = perlModuleExtension.getRootType(virtualFiles.getFirst());
×
62
      if (type == null) {
×
UNCOV
63
        return;
×
64
      }
65

66
      ModuleSourceRootEditHandler<?> handler = type.getEditHandler();
×
67
      presentation.setText(handler.getUnmarkRootButtonText());
×
68
      presentation.setIcon(
×
UNCOV
69
        LayeredIcon.layeredIcon(() -> new Icon[]{handler.getRootIcon(), AllIcons.RunConfigurations.InvalidConfigurationLayer}));
×
70
    }
×
71
    else {
UNCOV
72
      presentation.setText(PerlBundle.message("perl.action.unmark.multi"));
×
73
      presentation.setIcon(
×
UNCOV
74
        LayeredIcon.layeredIcon(() -> new Icon[]{PerlIcons.PERL_LANGUAGE_ICON, AllIcons.RunConfigurations.InvalidConfigurationLayer}));
×
75
    }
UNCOV
76
  }
×
77

78
  @Override
79
  public void actionPerformed(@NotNull AnActionEvent e) {
80
    RootsSelection selection = getSelection(e);
×
81
    PerlModuleExtension.modify(selection.myModule, it -> {
×
82
      for (VirtualFile virtualFile : getFilesFromSelection(selection)) {
×
83
        it.removeRoot(virtualFile);
×
UNCOV
84
      }
×
UNCOV
85
    });
×
UNCOV
86
  }
×
87

88
  @Override
89
  protected boolean isEnabled(@NotNull List<VirtualFile> files, @NotNull Module module) {
90
    PerlModuleExtension perlModuleExtension = PerlModuleExtension.getInstance(module);
×
UNCOV
91
    for (VirtualFile file : files) {
×
92
      if (perlModuleExtension.getRootType(file) != null) {
×
93
        return true;
×
94
      }
UNCOV
95
    }
×
UNCOV
96
    return false;
×
97
  }
98
}
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