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

Camelcade / Perl5-IDEA / #525521553

27 May 2025 10:24AM UTC coverage: 82.286% (-0.03%) from 82.32%
#525521553

push

github

hurricup
Removed redundant implementations, moved up to the abstract class

1 of 1 new or added line in 1 file covered. (100.0%)

128 existing lines in 30 files now uncovered.

30886 of 37535 relevant lines covered (82.29%)

0.82 hits per line

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

91.3
/plugin/core/src/main/java/com/perl5/lang/perl/psi/PerlSubElement.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;
18

19
import com.intellij.openapi.project.Project;
20
import com.intellij.openapi.util.Ref;
21
import com.intellij.openapi.util.text.StringUtil;
22
import com.intellij.util.Processor;
23
import com.perl5.lang.perl.psi.mro.PerlMro;
24
import com.perl5.lang.perl.util.PerlPackageUtil;
25
import com.perl5.lang.perl.util.PerlSubUtil;
26
import org.jetbrains.annotations.NotNull;
27
import org.jetbrains.annotations.Nullable;
28

29
import java.util.*;
30

31
public interface PerlSubElement extends PerlSub, PerlCallableElement {
32
  default @Nullable PerlSubElement getDirectSuperMethod() {
33
    if (!isMethod()) {
1✔
34
      return null;
×
35
    }
36

37
    Ref<PerlSubElement> resultRef = Ref.create();
1✔
38
    PerlMro.processCallables(
1✔
39
      getProject(), getResolveScope(), getNamespaceName(), Collections.singleton(getSubName()), true,
1✔
40
      it -> {
41
        if (it instanceof PerlSubElement subElement) {
1✔
42
          resultRef.set(subElement);
1✔
43
          return false;
1✔
44
        }
45
        return true;
×
46
      },
47
      true);
48

49
    return resultRef.get();
1✔
50
  }
51

52
  default @NotNull PerlSubElement getTopmostSuperMethod() {
53
    Set<String> classRecursion = new HashSet<>();
1✔
54

55
    PerlSubElement run = this;
1✔
56
    while (true) {
57
      String packageName = run.getNamespaceName();
1✔
58
      if (StringUtil.isEmpty(packageName) || classRecursion.contains(packageName)) {
1✔
59
        return run;
×
60
      }
61
      classRecursion.add(packageName);
1✔
62
      PerlSubElement newRun = run.getDirectSuperMethod();
1✔
63
      if (newRun == null) {
1✔
64
        return run;
1✔
65
      }
66
      run = newRun;
1✔
67
    }
1✔
68
  }
69

70
  default List<PerlSubDefinitionElement> getDirectOverridingSubs() {
71
    List<PerlSubDefinitionElement> result = new ArrayList<>();
1✔
72
    processDirectOverridingSubs(result::add);
1✔
73
    return result;
1✔
74
  }
75

76
  default boolean isBuiltIn() {
77
    return false;
1✔
78
  }
79

80
  @SuppressWarnings("UnusedReturnValue")
81
  default boolean processDirectOverridingSubs(@NotNull Processor<PerlSubDefinitionElement> processor) {
82
    String packageName = getNamespaceName();
1✔
83
    String subName = getSubName();
1✔
84
    if (packageName == null || subName == null) {
1✔
UNCOV
85
      return true;
×
86
    }
87
    Set<String> recursionSet = new HashSet<>();
1✔
88
    Project project = getProject();
1✔
89
    Queue<String> packagesToProcess = new ArrayDeque<>(5);
1✔
90
    packagesToProcess.add(packageName);
1✔
91

92
    while (!packagesToProcess.isEmpty()) {
1✔
93
      packageName = packagesToProcess.poll();
1✔
94
      NAMESPACE:
95
      for (PerlNamespaceDefinitionElement childNamespace : PerlPackageUtil.getChildNamespaces(project, packageName)) {
1✔
96
        String childNamespaceName = childNamespace.getNamespaceName();
1✔
97
        if (StringUtil.isNotEmpty(childNamespaceName) && recursionSet.add(childNamespaceName)) {
1✔
98
          for (PerlSubDefinitionElement subDefinition : PerlSubUtil.getSubDefinitionsInPackage(project, childNamespaceName)) {
1✔
99
            if (subName.equals(subDefinition.getSubName()) && subDefinition.getDirectSuperMethod() == this) {
1✔
100
              processor.process(subDefinition);
1✔
101
              continue NAMESPACE;
1✔
102
            }
103
          }
1✔
104
          packagesToProcess.add(childNamespaceName);
1✔
105
        }
106
      }
1✔
107
    }
108
    return true;
1✔
109
  }
110

111
  @Nullable PsiPerlSignatureContent getSignatureContent();
112
}
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