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

Camelcade / Perl5-IDEA / #525521639

21 Jul 2025 03:09PM UTC coverage: 82.304% (-0.04%) from 82.347%
#525521639

push

github

hurricup
#2842 Moved MasonFoldingBuilder to the common

68 of 98 new or added lines in 14 files covered. (69.39%)

67 existing lines in 12 files now uncovered.

30962 of 37619 relevant lines covered (82.3%)

0.82 hits per line

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

93.75
/mason/framework/backend/src/main/java/com/perl5/lang/htmlmason/MasonCoreUtil.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.htmlmason;
18

19
import com.intellij.openapi.vfs.VfsUtilCore;
20
import com.intellij.openapi.vfs.VirtualFile;
21
import com.intellij.openapi.vfs.newvfs.impl.FakeVirtualFile;
22
import com.intellij.psi.PsiFile;
23
import com.intellij.testFramework.LightVirtualFile;
24
import com.intellij.util.indexing.IndexingDataKeys;
25
import com.perl5.lang.htmlmason.idea.configuration.AbstractMasonSettings;
26
import com.perl5.lang.perl.idea.project.PerlProjectManager;
27
import org.jetbrains.annotations.NotNull;
28
import org.jetbrains.annotations.Nullable;
29

30

31
public final class MasonCoreUtil {
32
  private MasonCoreUtil() {
33
  }
34

35
  public static @Nullable VirtualFile getComponentRoot(@NotNull AbstractMasonSettings masonSettings, @Nullable VirtualFile file) {
36
    if (file != null) {
1✔
37
      if (file instanceof FakeVirtualFile) {
1✔
UNCOV
38
        file = file.getParent();
×
39
      }
40

41
      for (VirtualFile componentRoot : PerlProjectManager.getInstance(masonSettings.getProject())
1✔
42
        .getModulesRootsOfType(masonSettings.getSourceRootType())) {
1✔
43
        if (VfsUtilCore.isAncestor(componentRoot, file, false)) {
1✔
44
          return componentRoot;
1✔
45
        }
46
      }
1✔
47
    }
48
    return null;
1✔
49
  }
50

51
  /**
52
   * Returns a real containing virtual file, not the Light one
53
   *
54
   * @return virtual file or null
55
   */
56
  public static @Nullable VirtualFile getContainingVirtualFile(PsiFile psiFile) {
57
    VirtualFile originalFile = psiFile.getViewProvider().getVirtualFile();
1✔
58

59
    if (originalFile instanceof LightVirtualFile lightVirtualFile) {
1✔
60
      if (psiFile.getUserData(IndexingDataKeys.VIRTUAL_FILE) != null) {
1✔
61
        originalFile = psiFile.getUserData(IndexingDataKeys.VIRTUAL_FILE);
1✔
62
      }
63
      else if (lightVirtualFile.getOriginalFile() != null) {
1✔
64
        originalFile = lightVirtualFile.getOriginalFile();
1✔
65
      }
66
    }
67
    return originalFile instanceof LightVirtualFile || originalFile == null || !originalFile.exists() ? null : originalFile;
1✔
68
  }
69
}
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