• 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

92.68
/plugin/backend/src/main/java/com/perl5/lang/perl/psi/impl/PerlNamespaceElementImpl.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.impl;
18

19
import com.intellij.psi.PsiElement;
20
import com.intellij.psi.PsiElementVisitor;
21
import com.intellij.psi.PsiReference;
22
import com.intellij.psi.ResolveResult;
23
import com.intellij.psi.search.GlobalSearchScope;
24
import com.intellij.psi.tree.IElementType;
25
import com.perl5.lang.perl.psi.PerlNamespaceDefinitionElement;
26
import com.perl5.lang.perl.psi.PerlNamespaceDefinitionWithIdentifier;
27
import com.perl5.lang.perl.psi.PerlNamespaceElement;
28
import com.perl5.lang.perl.psi.PerlVisitor;
29
import com.perl5.lang.perl.psi.references.PerlNamespaceFileReference;
30
import com.perl5.lang.perl.psi.references.PerlNamespaceReference;
31
import com.perl5.lang.perl.util.PerlPackageUtil;
32
import org.jetbrains.annotations.NotNull;
33

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

37
import static com.perl5.lang.perl.parser.PerlElementTypesGenerated.TAG_PACKAGE;
38
import static com.perl5.lang.perl.util.PerlCorePackages.CORE_PACKAGES_PRAGMAS;
39

40

41
public class PerlNamespaceElementImpl extends PerlLeafPsiElementWithReferences implements PerlNamespaceElement {
1✔
42
  public PerlNamespaceElementImpl(@NotNull IElementType type, CharSequence text) {
43
    super(type, text);
1✔
44
  }
1✔
45

46
  @Override
47
  public void accept(@NotNull PsiElementVisitor visitor) {
48
    if (visitor instanceof PerlVisitor perlVisitor) {
1✔
49
      perlVisitor.visitNamespaceElement(this);
1✔
50
    }
51
    else {
52
      super.accept(visitor);
1✔
53
    }
54
  }
1✔
55

56
  @Override
57
  public @NotNull String getName() {
58
    return isTag() ? PerlPackageUtil.getContextNamespaceName(this) : this.getText();
1✔
59
  }
60

61
  @Override
62
  public String getCanonicalName() {
63
    return PerlPackageUtil.getCanonicalNamespaceName(getName());
1✔
64
  }
65

66
  @Override
67
  public boolean isTag() {return getNode().getElementType() == TAG_PACKAGE;}
1✔
68

69
  @Override
70
  public boolean isPragma() {
71
    return CORE_PACKAGES_PRAGMAS.contains(getCanonicalName());
1✔
72
  }
73

74
  @Override
75
  public boolean isSUPER() {
76
    return PerlPackageUtil.isSUPER(getCanonicalName());
1✔
77
  }
78

79
  @Override
80
  public boolean isMain() {
UNCOV
81
    return PerlPackageUtil.isMain(getCanonicalName());
×
82
  }
83

84
  @Override
85
  public boolean isCORE() {
86
    return PerlPackageUtil.isCORE(getCanonicalName());
1✔
87
  }
88

89
  @Override
90
  public boolean isUNIVERSAL() {
UNCOV
91
    return PerlPackageUtil.isUNIVERSAL(getCanonicalName());
×
92
  }
93

94
  @Override
95
  public boolean isDeprecated() {
96
    PsiElement parent = getParent();
1✔
97
    if (parent instanceof PerlNamespaceDefinitionWithIdentifier) {
1✔
UNCOV
98
      return ((PerlNamespaceDefinitionElement)parent).isDeprecated();
×
99
    }
100
    return PerlPackageUtil.isDeprecated(getProject(), GlobalSearchScope.allScope(getProject()), getCanonicalName());
1✔
101
  }
102

103
  @Override
104
  public List<PerlNamespaceDefinitionElement> getNamespaceDefinitions() {
105
    List<PerlNamespaceDefinitionElement> namespaceDefinitions = new ArrayList<>();
1✔
106

107
    PsiReference[] references = getReferences();
1✔
108

109
    for (PsiReference reference : references) {
1✔
110
      if (reference instanceof PerlNamespaceReference namespaceReference) {
1✔
111
        ResolveResult[] results = namespaceReference.multiResolve(false);
1✔
112

113
        for (ResolveResult result : results) {
1✔
114
          PsiElement targetElement = result.getElement();
1✔
115
          assert targetElement != null;
1✔
116
          assert targetElement instanceof PerlNamespaceDefinitionElement;
1✔
117

118
          namespaceDefinitions.add((PerlNamespaceDefinitionElement)targetElement);
1✔
119
        }
120
      }
121
    }
122
    return namespaceDefinitions;
1✔
123
  }
124

125
  @Override
126
  public List<PerlFileImpl> getNamespaceFiles() {
127
    List<PerlFileImpl> namespaceFiles = new ArrayList<>();
1✔
128

129
    PsiReference[] references = getReferences();
1✔
130

131
    for (PsiReference reference : references) {
1✔
132
      if (reference instanceof PerlNamespaceFileReference namespaceFileReference) {
1✔
133
        ResolveResult[] results = namespaceFileReference.multiResolve(false);
1✔
134

135
        for (ResolveResult result : results) {
1✔
136
          PsiElement targetElement = result.getElement();
1✔
137
          assert targetElement != null;
1✔
138

139
          if (targetElement instanceof PerlFileImpl perlFile) {
1✔
140
            namespaceFiles.add(perlFile);
1✔
141
          }
142
        }
143
      }
144
    }
145
    return namespaceFiles;
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