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

Camelcade / Perl5-IDEA / #525521606

29 Jun 2025 01:34PM UTC coverage: 82.318% (-0.09%) from 82.406%
#525521606

push

github

hurricup
#2842 Properly registered reference providers via contributors

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

41 existing lines in 15 files now uncovered.

30866 of 37496 relevant lines covered (82.32%)

0.82 hits per line

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

95.83
/plugin/backend/src/main/java/com/perl5/lang/pod/parser/psi/mixin/PodFormatterL.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.parser.psi.mixin;
18

19
import com.intellij.lang.ASTNode;
20
import com.intellij.openapi.diagnostic.Logger;
21
import com.intellij.psi.PsiFile;
22
import com.intellij.psi.PsiReference;
23
import com.intellij.psi.util.CachedValueProvider;
24
import com.intellij.psi.util.CachedValuesManager;
25
import com.intellij.psi.util.PsiTreeUtil;
26
import com.perl5.lang.pod.parser.psi.PodFormatter;
27
import com.perl5.lang.pod.parser.psi.PodLinkDescriptor;
28
import com.perl5.lang.pod.parser.psi.PodRenderingContext;
29
import com.perl5.lang.pod.parser.psi.PodSection;
30
import com.perl5.lang.pod.parser.psi.references.PodLinkToFileReference;
31
import com.perl5.lang.pod.parser.psi.util.PodRenderUtil;
32
import com.perl5.lang.pod.psi.PsiLinkName;
33
import com.perl5.lang.pod.psi.PsiLinkSection;
34
import com.perl5.lang.pod.psi.PsiLinkText;
35
import com.perl5.lang.pod.psi.PsiLinkUrl;
36
import org.jetbrains.annotations.NotNull;
37
import org.jetbrains.annotations.Nullable;
38

39
public class PodFormatterL extends PodSectionMixin implements PodFormatter, PodSection {
40
  private static final Logger LOG = Logger.getInstance(PodFormatterL.class);
1✔
41

42
  public PodFormatterL(@NotNull ASTNode node) {
43
    super(node);
1✔
44
  }
1✔
45

46
  @Override
47
  public void renderElementContentAsHTML(StringBuilder builder, PodRenderingContext context) {
48
    PodLinkDescriptor descriptor = getLinkDescriptor();
1✔
49

50
    if (descriptor != null) {
1✔
51
      builder.append(PodRenderUtil.getHTMLLink(descriptor, !isResolvable()));
1✔
52
    }
53
    else {
UNCOV
54
      LOG.warn("Could not create a descriptor for pod link: " + getText());
×
55
    }
56
  }
1✔
57

58
  private boolean isResolvable() {
59
    for (PsiReference reference : getReferences()) {
1✔
60
      if (reference.resolve() == null) {
1✔
61
        return false;
1✔
62
      }
63
    }
64
    return true;
1✔
65
  }
66

67
  @Override
68
  public boolean hasReferences() {
69
    return true;
1✔
70
  }
71

72
  public @Nullable PodLinkDescriptor getLinkDescriptor() {
73
    return CachedValuesManager.getCachedValue(this, () -> CachedValueProvider.Result.create(
1✔
74
      PodLinkDescriptor.create(this), PodFormatterL.this));
1✔
75
  }
76

77
  public @Nullable PsiFile getTargetFile() {
78
    PsiReference[] references = getReferences();
1✔
79

80
    for (PsiReference reference : references) {
1✔
81
      if (reference instanceof PodLinkToFileReference) {
1✔
82
        return (PsiFile)reference.resolve();
1✔
83
      }
84
    }
85

86
    return getContainingFile();
1✔
87
  }
88

89
  public @Nullable PsiLinkText getLinkTextElement() {
90
    return PsiTreeUtil.getChildOfType(getContentBlock(), PsiLinkText.class);
1✔
91
  }
92

93
  public @Nullable PsiLinkName getLinkNameElement() {
94
    return PsiTreeUtil.getChildOfType(getContentBlock(), PsiLinkName.class);
1✔
95
  }
96

97
  public @Nullable PsiLinkSection getLinkSectionElement() {
98
    return PsiTreeUtil.getChildOfType(getContentBlock(), PsiLinkSection.class);
1✔
99
  }
100

101
  public @Nullable PsiLinkUrl getLinkUrlElement() {
102
    return PsiTreeUtil.getChildOfType(getContentBlock(), PsiLinkUrl.class);
1✔
103
  }
104
}
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