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

Camelcade / Perl5-IDEA / #525521660

24 Aug 2025 01:28PM UTC coverage: 75.89% (-6.3%) from 82.227%
#525521660

push

github

hurricup
Migrated coverage reporting to https://github.com/nbaztec/coveralls-jacoco-gradle-plugin

See: https://github.com/kt3k/coveralls-gradle-plugin/issues/119

14751 of 22639 branches covered (65.16%)

Branch coverage included in aggregate %.

31091 of 37767 relevant lines covered (82.32%)

0.82 hits per line

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

64.71
/plugin/common/src/main/java/com/perl5/lang/perl/psi/PerlFileViewProvider.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.psi;
18

19
import com.intellij.lang.Language;
20
import com.intellij.lang.LanguageParserDefinitions;
21
import com.intellij.lang.ParserDefinition;
22
import com.intellij.openapi.vfs.VirtualFile;
23
import com.intellij.psi.MultiplePsiFilesPerDocumentFileViewProvider;
24
import com.intellij.psi.PsiFile;
25
import com.intellij.psi.PsiManager;
26
import com.intellij.psi.impl.source.PsiFileImpl;
27
import com.intellij.psi.templateLanguages.TemplateLanguageFileViewProvider;
28
import com.intellij.psi.tree.IElementType;
29
import com.intellij.util.containers.ContainerUtil;
30
import com.perl5.lang.perl.PerlLanguage;
31
import com.perl5.lang.pod.PodLanguage;
32
import org.jetbrains.annotations.NotNull;
33
import org.jetbrains.annotations.Nullable;
34

35
import java.util.Collections;
36
import java.util.List;
37
import java.util.Set;
38

39
import static com.perl5.lang.perl.lexer.PerlElementTypes.POD_BLOCK;
40

41

42
public class PerlFileViewProvider extends MultiplePsiFilesPerDocumentFileViewProvider
43
  implements TemplateLanguageFileViewProvider {
44
  private static final Set<Language> myLanguages = Set.of(
1✔
45
    PerlLanguage.INSTANCE,
46
    PodLanguage.INSTANCE
47
  );
48
  private boolean myActAsSingleFile = false;
1✔
49

50
  public PerlFileViewProvider(PsiManager manager, VirtualFile virtualFile, boolean eventSystemEnabled) {
51
    super(manager, virtualFile, eventSystemEnabled);
1✔
52
  }
1✔
53

54
  @Override
55
  protected @Nullable PsiFile createFile(@NotNull Language lang) {
56
    if (lang != PerlLanguage.INSTANCE && lang != PodLanguage.INSTANCE) {
1!
57
      return null;
×
58
    }
59

60
    final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(lang);
1✔
61
    if (parserDefinition != null) {
1!
62

63
      final PsiFileImpl psiFile = (PsiFileImpl)parserDefinition.createFile(this);
1✔
64

65
      if (lang == PodLanguage.INSTANCE) {
1✔
66
        psiFile.setContentElementType(POD_BLOCK);
1✔
67
      }
68

69
      return psiFile;
1✔
70
    }
71

72
    return null;
×
73
  }
74

75
  @Override
76
  public @NotNull Set<Language> getLanguages() {
77
    if (myActAsSingleFile) {
1!
78
      return Collections.singleton(getBaseLanguage());
×
79
    }
80
    else {
81
      return myLanguages;
1!
82
    }
83
  }
84

85
  @Override
86
  public IElementType getContentElementType(@NotNull Language language) {
87
    return language == PodLanguage.INSTANCE ? POD_BLOCK : null;
1✔
88
  }
89

90
  @Override
91
  public @NotNull Language getBaseLanguage() {
92
    return PerlLanguage.INSTANCE;
1!
93
  }
94

95
  @Override
96
  protected @NotNull MultiplePsiFilesPerDocumentFileViewProvider cloneInner(@NotNull VirtualFile fileCopy) {
97
    return new PerlFileViewProvider(getManager(), fileCopy, false);
1✔
98
  }
99

100
  @Override
101
  public @NotNull Language getTemplateDataLanguage() {
102
    return PodLanguage.INSTANCE;
1!
103
  }
104

105
  public void setActAsSingleFile(boolean myActAsSingleFile) {
106
    this.myActAsSingleFile = myActAsSingleFile;
×
107
  }
×
108

109
  @Override
110
  public @NotNull List<PsiFile> getAllFiles() {
111
    if (myActAsSingleFile) {
1!
112
      return ContainerUtil.createMaybeSingletonList(getPsi(getBaseLanguage()));
×
113
    }
114
    else {
115
      return super.getAllFiles();
1!
116
    }
117
  }
118
}
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