• 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

78.57
/plugin/profiler/src/main/java/com/perl5/lang/perl/profiler/parser/frames/PerlTryStackElement.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.profiler.parser.frames;
18

19
import com.intellij.openapi.progress.ProgressManager;
20
import com.intellij.openapi.project.Project;
21
import com.intellij.openapi.projectRoots.Sdk;
22
import com.intellij.psi.NavigatablePsiElement;
23
import com.intellij.psi.PsiFile;
24
import com.intellij.psi.search.GlobalSearchScope;
25
import com.perl5.lang.perl.psi.PerlRecursiveVisitor;
26
import com.perl5.lang.perl.psi.PsiPerlTryExpr;
27
import com.perl5.lang.perl.psi.PsiPerlTrycatchCompound;
28
import com.perl5.lang.perl.util.PerlNamespaceUtil;
29
import com.perl5.lang.perl.util.PerlPackageUtilCore;
30
import org.jetbrains.annotations.NotNull;
31

32
import java.util.*;
33

34
/**
35
 * Frame created by Try::Tiny {@code Foo::Bar::try {...} }
36
 *
37
 * @implNote it's not possible to deduce exact try in the namespace. So, for now we are iterating all files up to {@link #MAX_FILE_TO_OPEN},
38
 * parsing them, traversing and collecting all try expressions and compounds.
39
 */
40
class PerlTryStackElement extends PerlCallStackElement {
41
  private final @NotNull String myNamespaceName;
42

43
  PerlTryStackElement(@NotNull String frameText) {
44
    super(frameText);
1✔
45
    var cleanedFrameText = getFrameText();
1✔
46
    var tryTinySuffixIndex = cleanedFrameText.indexOf(TRY_TINY_SUFFIX);
1✔
47

48
    if (tryTinySuffixIndex < 0) {
1✔
49
      LOG.error("Attempting to create try frame from non-try text: " + frameText);
×
50
    }
51
    myNamespaceName = PerlPackageUtilCore.getCanonicalName(cleanedFrameText.substring(0, tryTinySuffixIndex));
1✔
52
  }
1✔
53

54
  @Override
55
  public @NotNull String fullName() {
56
    return "try in " + myNamespaceName;
1✔
57
  }
58

59
  @Override
60
  protected @NotNull List<NavigatablePsiElement> computeNavigatables(@NotNull Project project, @NotNull Sdk perlSdk) {
61
    if (PerlPackageUtilCore.MAIN_NAMESPACE_NAME.equals(myNamespaceName)) {
1✔
62
      return Collections.emptyList();
×
63
    }
64
    List<NavigatablePsiElement> result = new ArrayList<>();
1✔
65
    Set<PsiFile> processedFiles = new HashSet<>();
1✔
66
    PerlNamespaceUtil.processNamespaces(
1✔
67
      myNamespaceName, project, GlobalSearchScope.allScope(project),
1✔
68
      it -> {
69
        var psiFile = it.getContainingFile();
1✔
70
        if (processedFiles.add(psiFile)) {
1✔
71
          ProgressManager.checkCanceled();
1✔
72
          psiFile.accept(new PerlRecursiveVisitor() {
1✔
73
            @Override
74
            public void visitTrycatchCompound(@NotNull PsiPerlTrycatchCompound o) {
75
              if (o instanceof NavigatablePsiElement navigatablePsiElement) {
×
76
                result.add(new PerlTargetElementWrapper(navigatablePsiElement));
×
77
              }
78
              super.visitTrycatchCompound(o);
×
79
            }
×
80

81
            @Override
82
            public void visitTryExpr(@NotNull PsiPerlTryExpr o) {
83
              if (o instanceof NavigatablePsiElement navigatablePsiElement) {
1✔
84
                result.add(new PerlTargetElementWrapper(navigatablePsiElement));
1✔
85
              }
86
              super.visitTryExpr(o);
1✔
87
            }
1✔
88
          });
89
        }
90
        return processedFiles.size() < MAX_FILE_TO_OPEN;
1✔
91
      });
92
    return result;
1✔
93
  }
94
}
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