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

Camelcade / Perl5-IDEA / #525521600

27 Jun 2025 03:55PM UTC coverage: 82.369% (+0.009%) from 82.36%
#525521600

push

github

hurricup
Build 252.23591.19

30871 of 37479 relevant lines covered (82.37%)

0.82 hits per line

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

51.72
/plugin/core/src/main/java/com/perl5/lang/perl/idea/actions/PerlMarkSourceRootAction.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.openapi.actionSystem.AnActionEvent;
20
import com.intellij.openapi.actionSystem.Presentation;
21
import com.intellij.openapi.module.Module;
22
import com.intellij.openapi.module.ModuleUtilCore;
23
import com.intellij.openapi.project.Project;
24
import com.intellij.openapi.project.ProjectBundle;
25
import com.intellij.openapi.projectRoots.impl.PerlModuleExtension;
26
import com.intellij.openapi.roots.ui.configuration.ModuleSourceRootEditHandler;
27
import com.intellij.openapi.vfs.VirtualFile;
28
import com.perl5.lang.perl.idea.modules.PerlSourceRootType;
29
import com.perl5.lang.perl.idea.project.PerlProjectManager;
30
import org.jetbrains.annotations.NotNull;
31
import org.jetbrains.annotations.Nullable;
32

33
import java.util.Arrays;
34
import java.util.List;
35
import java.util.Locale;
36

37
public abstract class PerlMarkSourceRootAction extends PerlSourceRootAction {
38
  private final @NotNull PerlSourceRootType myType;
39

40
  public PerlMarkSourceRootAction(@NotNull PerlSourceRootType type) {
1✔
41
    myType = type;
1✔
42
    ModuleSourceRootEditHandler<?> editHandler = type.getEditHandler();
1✔
43
    Presentation presentation = getTemplatePresentation();
1✔
44
    presentation.setText(editHandler.getMarkRootButtonText());
1✔
45
    presentation.setDescription(ProjectBundle.message("module.toggle.sources.action.description",
1✔
46
                                                      editHandler.getFullRootTypeName().toLowerCase(Locale.getDefault())));
1✔
47
    presentation.setIcon(editHandler.getRootIcon());
1✔
48
  }
1✔
49

50
  public @NotNull PerlSourceRootType getType() {
51
    return myType;
×
52
  }
53

54

55
  @Override
56
  protected boolean isEnabled(@NotNull List<? extends VirtualFile> files, @NotNull Module module) {
57
    if (files.isEmpty() || !PerlProjectManager.isPerlEnabled(module)) {
×
58
      return false;
×
59
    }
60
    return !myType.equals(PerlModuleExtension.getInstance(module).getRootType(files.getFirst()));
×
61
  }
62

63
  @Override
64
  protected final void modifyRoots(@NotNull AnActionEvent e, @NotNull Module module, VirtualFile @NotNull [] files) {
65
    markRoot(module, files);
×
66
  }
×
67

68
  public final void markRoot(@NotNull Project project, @Nullable VirtualFile virtualFile) {
69
    if (virtualFile == null || !virtualFile.isValid()) {
×
70
      return;
×
71
    }
72
    Module module = ModuleUtilCore.findModuleForFile(virtualFile, project);
×
73
    if (module != null) {
×
74
      markRoot(module, virtualFile);
×
75
    }
76
  }
×
77

78
  public final void markRoot(@NotNull Module module, @NotNull VirtualFile... files) {
79
    markRoot(module, Arrays.asList(files));
×
80
  }
×
81
  public final void markRoot(@NotNull Module module, @NotNull List<? extends VirtualFile> files) {
82
    PerlModuleExtension.modify(module, it -> {
1✔
83
      for (VirtualFile virtualFile : files) {
1✔
84
        it.setRoot(virtualFile, myType);
1✔
85
      }
1✔
86
    });
1✔
87
  }
1✔
88
}
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