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

Camelcade / Perl5-IDEA / #525521705

10 Nov 2025 08:49AM UTC coverage: 75.92% (-0.05%) from 75.97%
#525521705

push

github

hurricup
Passed the reason to the daemon code analyzer

14750 of 22633 branches covered (65.17%)

Branch coverage included in aggregate %.

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

82 existing lines in 10 files now uncovered.

31070 of 37720 relevant lines covered (82.37%)

0.82 hits per line

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

31.48
/plugin/backend/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.application.ModalityState;
22
import com.intellij.openapi.application.ReadAction;
23
import com.intellij.openapi.module.Module;
24
import com.intellij.openapi.module.ModuleUtilCore;
25
import com.intellij.openapi.project.Project;
26
import com.intellij.openapi.project.ProjectBundle;
27
import com.intellij.openapi.projectRoots.impl.PerlModuleExtension;
28
import com.intellij.openapi.roots.ui.configuration.ModuleSourceRootEditHandler;
29
import com.intellij.openapi.vfs.VirtualFile;
30
import com.intellij.util.concurrency.AppExecutorUtil;
31
import com.perl5.lang.perl.idea.modules.PerlSourceRootType;
32
import com.perl5.lang.perl.idea.project.PerlProjectManager;
33
import com.perl5.lang.perl.util.PerlPluginUtil;
34
import org.jetbrains.annotations.NotNull;
35
import org.jetbrains.annotations.Nullable;
36

37
import java.util.Arrays;
38
import java.util.List;
39
import java.util.Locale;
40

41
public abstract class PerlMarkSourceRootAction extends PerlSourceRootAction {
42
  private final @NotNull PerlSourceRootType myType;
43

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

54
  public @NotNull PerlSourceRootType getType() {
55
    return myType;
×
56
  }
57

58

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

67
  @Override
68
  protected final void modifyRoots(@NotNull AnActionEvent e, @NotNull Module module, VirtualFile @NotNull [] files) {
69
    markRoot(module, files);
×
70
  }
×
71

72
  public final void markRoot(@NotNull Project project, @Nullable VirtualFile virtualFile) {
UNCOV
73
    if (virtualFile == null) {
×
74
      return;
×
75
    }
UNCOV
76
    ReadAction.nonBlocking(() -> {
×
UNCOV
77
        if (!virtualFile.isValid()) {
×
78
          return null;
×
79
        }
UNCOV
80
        return ModuleUtilCore.findModuleForFile(virtualFile, project);
×
UNCOV
81
      }).finishOnUiThread(ModalityState.current(), (module) -> {
×
UNCOV
82
        if (module != null && PerlPluginUtil.isUnloaded(module.getProject())) {
×
83
          markRoot(module, virtualFile);
×
84
        }
UNCOV
85
      }).expireWith(PerlPluginUtil.getUnloadAwareDisposable(project))
×
UNCOV
86
      .coalesceBy(project, virtualFile)
×
UNCOV
87
      .submit(AppExecutorUtil.getAppExecutorService());
×
UNCOV
88
  }
×
89

90
  public final void markRoot(@NotNull Module module, @NotNull VirtualFile... files) {
91
    markRoot(module, Arrays.asList(files));
×
92
  }
×
93
  public final void markRoot(@NotNull Module module, @NotNull List<? extends VirtualFile> files) {
94
    PerlModuleExtension.modify(module, it -> {
1✔
95
      for (VirtualFile virtualFile : files) {
1✔
96
        it.setRoot(virtualFile, myType);
1✔
97
      }
1✔
98
    });
1✔
99
  }
1✔
100
}
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