• 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

52.94
/plugin/backend/src/main/java/com/perl5/lang/perl/psi/references/PerlNamespaceFileReference.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.util.text.StringUtil;
20
import com.intellij.psi.PsiElement;
21
import com.intellij.psi.PsiElementResolveResult;
22
import com.intellij.psi.PsiFile;
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.util.PerlPackageUtil;
27
import com.perl5.lang.perl.util.PerlPackageUtilCore;
28
import org.jetbrains.annotations.NotNull;
29

30
public class PerlNamespaceFileReference extends PerlCachingReference<PerlNamespaceElement> {
31
  public PerlNamespaceFileReference(PerlNamespaceElement psiElement) {
32
    super(psiElement);
1✔
33
  }
1✔
34

35
  public String getPackageName() {
36
    return myElement.getCanonicalName();
1✔
37
  }
38

39
  @Override
40
  protected @NotNull ResolveResult[] resolveInner(boolean incompleteCode) {
41
    PerlNamespaceElement myElement = getElement();
1✔
42
    PsiFile file = myElement.getContainingFile();
1✔
43
    PsiFile targetFile;
44

45
    targetFile = PerlPackageUtil.resolvePackageNameToPsi(file, getPackageName());
1✔
46

47
    return targetFile == null
1✔
48
           ? ResolveResult.EMPTY_ARRAY
1✔
49
           : new ResolveResult[]{new PsiElementResolveResult(targetFile)};
1✔
50
  }
51

52
  @Override
53
  public PsiElement handleElementRename(@NotNull String newElementName) throws IncorrectOperationException {
54
    String currentName = myElement.getCanonicalName();
×
55
    if (currentName != null && newElementName.endsWith(".pm")) {
×
56
      String[] nameChunks = currentName.split(PerlPackageUtilCore.NAMESPACE_SEPARATOR);
×
57
      nameChunks[nameChunks.length - 1] = newElementName.replaceFirst("\\.pm$", "");
×
58
      newElementName = StringUtil.join(nameChunks, PerlPackageUtilCore.NAMESPACE_SEPARATOR);
×
59

60
      return super.handleElementRename(newElementName);
×
61
    }
62

63
    throw new IncorrectOperationException("Can't bind package use/require to a non-pm file: " + newElementName);
×
64
  }
65

66
  @Override
67
  public PsiElement bindToElement(@NotNull PsiElement element) throws IncorrectOperationException {
68
    // fixme this is a stub to avoid exception
69
    return myElement;
×
70
  }
71
}
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