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

Camelcade / Perl5-IDEA / #525521635

20 Jul 2025 03:45PM UTC coverage: 82.266% (-0.09%) from 82.355%
#525521635

push

github

hurricup
Build 252.23892.248

30936 of 37605 relevant lines covered (82.27%)

0.82 hits per line

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

95.24
/plugin/backend/src/main/java/com/perl5/lang/perl/psi/references/PerlNamespaceReference.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.references;
18

19
import com.intellij.openapi.project.Project;
20
import com.intellij.openapi.util.TextRange;
21
import com.intellij.psi.PsiElement;
22
import com.intellij.psi.PsiElementResolveResult;
23
import com.intellij.psi.ResolveResult;
24
import com.intellij.util.IncorrectOperationException;
25
import com.perl5.lang.perl.psi.PerlNamespaceElement;
26
import com.perl5.lang.perl.psi.impl.PerlBuiltInNamespaceDefinition;
27
import com.perl5.lang.perl.util.PerlNamespaceUtil;
28
import com.perl5.lang.perl.util.PerlPackageUtilCore;
29
import org.jetbrains.annotations.NotNull;
30

31
public class PerlNamespaceReference extends PerlCachingReference<PsiElement> {
32
  public PerlNamespaceReference(PsiElement psiElement) {
33
    super(psiElement);
1✔
34
  }
1✔
35

36
  public PerlNamespaceReference(@NotNull PsiElement element, TextRange textRange) {
37
    super(element, textRange);
1✔
38
  }
1✔
39

40
  private @NotNull String getNamspaceName() {
41
    if (myElement instanceof PerlNamespaceElement namespaceElement) {
1✔
42
      return namespaceElement.getCanonicalName();
1✔
43
    }
44
    return getRangeInElement().substring(myElement.getText());
1✔
45
  }
46

47
  @Override
48
  protected @NotNull ResolveResult[] resolveInner(boolean incompleteCode) {
49
    String namespaceName = getNamspaceName();
1✔
50
    if (namespaceName.isEmpty()) {
1✔
51
      namespaceName = PerlPackageUtilCore.MAIN_NAMESPACE_NAME;
×
52
    }
53

54
    Project project = myElement.getProject();
1✔
55
    PerlBuiltInNamespaceDefinition builtInNamespaceDefinition =
1✔
56
      PerlBuiltInNamespacesService.getInstance(project).getNamespaceDefinition(namespaceName);
1✔
57
    if (builtInNamespaceDefinition != null) {
1✔
58
      return PsiElementResolveResult.createResults(builtInNamespaceDefinition);
1✔
59
    }
60

61
    return PsiElementResolveResult.createResults(
1✔
62
      PerlNamespaceUtil.getNamespaceDefinitions(project, myElement.getResolveScope(),
1✔
63
                                                PerlPackageUtilCore.getCanonicalNamespaceName(namespaceName)));
1✔
64
  }
65

66
  @Override
67
  public PsiElement handleElementRename(@NotNull String newElementName) throws IncorrectOperationException {
68
    if (myElement instanceof PerlNamespaceElement namespaceElement && namespaceElement.isTag()) {
1✔
69
      return myElement;
1✔
70
    }
71
    return super.handleElementRename(newElementName);
1✔
72
  }
73
}
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