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

Camelcade / Perl5-IDEA / #525521767

01 Mar 2026 03:30PM UTC coverage: 75.972% (+0.05%) from 75.922%
#525521767

push

github

hurricup
[qodana] Migrated restart() method to the one with a reason

14768 of 22632 branches covered (65.25%)

Branch coverage included in aggregate %.

2 of 2 new or added lines in 2 files covered. (100.0%)

15 existing lines in 3 files now uncovered.

31092 of 37732 relevant lines covered (82.4%)

0.82 hits per line

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

77.27
/plugin/common/src/main/java/com/perl5/lang/perl/fileTypes/PerlFileTypeService.java
1
/*
2
 * Copyright 2015-2026 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.fileTypes.PlainTextFileType;
25
import com.intellij.openapi.project.Project;
26
import com.intellij.openapi.project.ProjectManager;
27
import com.intellij.openapi.util.NotNullLazyValue;
28
import com.intellij.openapi.vfs.VirtualFile;
29
import com.intellij.openapi.vfs.newvfs.impl.FakeVirtualFile;
30
import com.intellij.util.indexing.LightDirectoryIndex;
31
import org.jetbrains.annotations.Nullable;
32

33
import java.util.function.Function;
34

35

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

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

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

70
  @Override
71
  public void dispose() {
72

UNCOV
73
  }
×
74

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

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

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