• 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

81.16
/plugin/common/src/main/java/com/perl5/lang/pod/idea/editor/PodFoldingBuilder.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.pod.idea.editor;
18

19
import com.intellij.lang.ASTNode;
20
import com.intellij.lang.folding.FoldingDescriptor;
21
import com.intellij.openapi.editor.Document;
22
import com.intellij.openapi.project.DumbAware;
23
import com.intellij.openapi.util.text.StringUtil;
24
import com.intellij.psi.PsiElement;
25
import com.intellij.psi.templateLanguages.OuterLanguageElementImpl;
26
import com.perl5.lang.perl.idea.folding.PerlFoldingBuilderBase;
27
import com.perl5.lang.pod.parser.psi.PodRecursiveVisitor;
28
import com.perl5.lang.pod.parser.psi.PodTitledSection;
29
import com.perl5.lang.pod.psi.*;
30
import org.jetbrains.annotations.NotNull;
31
import org.jetbrains.annotations.Nullable;
32

33
import java.util.ArrayList;
34
import java.util.List;
35

36
public class PodFoldingBuilder extends PerlFoldingBuilderBase implements DumbAware {
1✔
37
  @Override
38
  public FoldingDescriptor @NotNull [] buildFoldRegions(@NotNull PsiElement root, @NotNull Document document, boolean quick) {
39
    // @todo handle this
40
    if (root instanceof OuterLanguageElementImpl) {
1!
41
      return FoldingDescriptor.EMPTY_ARRAY;
×
42
    }
43

44
    FoldingRegionsCollector collector = new FoldingRegionsCollector(document);
1✔
45
    root.accept(collector);
1✔
46
    List<FoldingDescriptor> descriptors = collector.getDescriptors();
1✔
47

48
    return descriptors.toArray(FoldingDescriptor.EMPTY_ARRAY);
1!
49
  }
50

51
  @Override
52
  public boolean isCollapsedByDefault(@NotNull ASTNode node) {
53
    return false;
1✔
54
  }
55

56
  @Override
57
  public @Nullable String getPlaceholderText(@NotNull ASTNode node) {
58
    PsiElement psi = node.getPsi();
1✔
59
    if (!(psi instanceof PodTitledSection titledSection)) {
1✔
60
      return null;
1✔
61
    }
62
    String titleText = titledSection.getTitleText();
1✔
63
    if (StringUtil.isEmpty(titleText)) {
1!
64
      return null;
×
65
    }
66
    return " " + StringUtil.shortenTextWithEllipsis(titleText, 80, 0);
1✔
67
  }
68

69

70
  public static class FoldingRegionsCollector extends PodRecursiveVisitor {
71
    protected final Document myDocument;
72
    protected final List<FoldingDescriptor> myDescriptors = new ArrayList<>();
1✔
73

74
    public FoldingRegionsCollector(Document document) {
1✔
75
      myDocument = document;
1✔
76
    }
1✔
77

78
    public List<FoldingDescriptor> getDescriptors() {
79
      return myDescriptors;
1✔
80
    }
81

82

83
    @Override
84
    public void visitForSection(@NotNull PsiForSection o) {
85
      addDescriptorFor(o);
1✔
86
      super.visitForSection(o);
1✔
87
    }
1✔
88

89
    @Override
90
    public void visitHead1Section(@NotNull PsiHead1Section o) {
91
      addDescriptorFor(o);
1✔
92
      super.visitHead1Section(o);
1✔
93
    }
1✔
94

95
    @Override
96
    public void visitHead2Section(@NotNull PsiHead2Section o) {
97
      addDescriptorFor(o);
1✔
98
      super.visitHead2Section(o);
1✔
99
    }
1✔
100

101
    @Override
102
    public void visitHead3Section(@NotNull PsiHead3Section o) {
103
      addDescriptorFor(o);
1✔
104
      super.visitHead3Section(o);
1✔
105
    }
1✔
106

107
    @Override
108
    public void visitHead4Section(@NotNull PsiHead4Section o) {
109
      addDescriptorFor(o);
1✔
110
      super.visitHead4Section(o);
1✔
111
    }
1✔
112

113
    @Override
114
    public void visitItemSection(@NotNull PsiItemSection o) {
115
      if (o.getItemSectionContent() != null) {
1!
116
        addDescriptorFor(o);
×
117
      }
118
      super.visitItemSection(o);
1✔
119
    }
1✔
120

121
    @Override
122
    public void visitOverSection(@NotNull PsiOverSection o) {
123
      addDescriptorFor(o);
1✔
124
      super.visitOverSection(o);
1✔
125
    }
1✔
126

127
    @Override
128
    public void visitUnknownSection(@NotNull PsiUnknownSection o) {
129
      addDescriptorFor(o);
×
130
      super.visitUnknownSection(o);
×
131
    }
×
132

133
    @Override
134
    public void visitPodSection(@NotNull PsiPodSection o) {
135
      addDescriptorFor(o);
1✔
136
      super.visitPodSection(o);
1✔
137
    }
1✔
138

139
    protected void addDescriptorFor(PsiElement element) {
140
      PsiElement firstChild = element.getFirstChild();
1✔
141
      if (firstChild != null) {
1!
142
        int endMargin = StringUtil.endsWith(element.getNode().getChars(), "\n") ? 1 : 0;
1✔
143
        PerlFoldingBuilderBase.addDescriptorFor(myDescriptors, myDocument, element, firstChild.getTextLength(), endMargin, 1, null, false);
1✔
144
      }
145
    }
1✔
146
  }
147
}
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