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

Camelcade / Perl5-IDEA / #525521586

19 Jun 2025 10:27AM UTC coverage: 82.376% (+0.03%) from 82.349%
#525521586

push

github

hurricup
Migrated to NioFiles.deleteRecursively

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

54 existing lines in 7 files now uncovered.

30872 of 37477 relevant lines covered (82.38%)

0.82 hits per line

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

79.31
/plugin/core/src/main/java/com/perl5/lang/perl/fileTypes/PerlFileTypeService.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.fileTypes;
18

19
import com.intellij.openapi.Disposable;
20
import com.intellij.openapi.application.ApplicationManager;
21
import com.intellij.openapi.application.ReadAction;
22
import com.intellij.openapi.diagnostic.Logger;
23
import com.intellij.openapi.fileTypes.FileType;
24
import com.intellij.openapi.project.Project;
25
import com.intellij.openapi.project.ProjectManager;
26
import com.intellij.openapi.util.NotNullLazyValue;
27
import com.intellij.openapi.vfs.VirtualFile;
28
import com.intellij.openapi.vfs.newvfs.impl.FakeVirtualFile;
29
import com.intellij.util.indexing.LightDirectoryIndex;
30
import org.jetbrains.annotations.Nullable;
31

32
import java.util.function.Function;
33

34

35
public class PerlFileTypeService implements Disposable {
36
  private static final Logger LOG = Logger.getInstance(PerlFileTypeService.class);
1✔
37

38
  private final NotNullLazyValue<LightDirectoryIndex<Function<VirtualFile, FileType>>> myDirectoryIndexProvider =
1✔
39
    NotNullLazyValue.createValue(() -> new LightDirectoryIndex<>(
1✔
40
      this,
41
      virtualFile -> null,
1✔
42
      directoryIndex -> ReadAction.run(() -> {
1✔
43
        for (Project project : ProjectManager.getInstance().getOpenProjects()) {
1✔
44
          if (project.isDisposed()) {
1✔
45
            continue;
×
46
          }
47
          for (PerlFileTypeProvider fileTypeProvider : PerlFileTypeProvider.EP_NAME.getExtensionList()) {
1✔
48
            fileTypeProvider.addRoots(project, (root, function) -> {
1✔
49
              if (!root.isValid()) {
1✔
50
                LOG.warn("Attempt to create a descriptor for invalid file for " + root);
×
51
                return;
×
52
              }
53
              if (!root.isDirectory()) {
1✔
54
                LOG.warn("Attempt to create root for non-directory: " + root);
×
55
                return;
×
56
              }
57
              directoryIndex.putInfo(root, function);
1✔
58
            });
1✔
59
          }
1✔
60
        }
61
      })
1✔
62
    ));
63

64
  public PerlFileTypeService() {
1✔
65
    //noinspection deprecation
66
    PerlFileTypeProvider.EP_NAME.addChangeListener(this::reset, this);
1✔
67
  }
1✔
68

69
  @Override
70
  public void dispose() {
71

UNCOV
72
  }
×
73

74
  void reset() {
75
    myDirectoryIndexProvider.get().resetIndex();
1✔
76
  }
1✔
77

78
  public static PerlFileTypeService getInstance() {
79
    return ApplicationManager.getApplication().getService(PerlFileTypeService.class);
1✔
80
  }
81

82
  public static @Nullable FileType getFileType(@Nullable VirtualFile virtualFile) {
83
    VirtualFile fileForAncestryCheck = virtualFile instanceof FakeVirtualFile ? virtualFile.getParent() : virtualFile;
1✔
84
    return getInstance().myDirectoryIndexProvider.get().getInfoForFile(fileForAncestryCheck).apply(virtualFile);
1✔
85
  }
86
}
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