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

Camelcade / Perl5-IDEA / #525521660

24 Aug 2025 01:28PM UTC coverage: 75.89% (-6.3%) from 82.227%
#525521660

push

github

hurricup
Migrated coverage reporting to https://github.com/nbaztec/coveralls-jacoco-gradle-plugin

See: https://github.com/kt3k/coveralls-gradle-plugin/issues/119

14751 of 22639 branches covered (65.16%)

Branch coverage included in aggregate %.

31091 of 37767 relevant lines covered (82.32%)

0.82 hits per line

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

67.5
/plugin/backend/src/main/java/com/perl5/lang/perl/util/PerlScalarUtil.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.util;
18

19
import com.intellij.openapi.project.Project;
20
import com.intellij.psi.search.GlobalSearchScope;
21
import com.intellij.util.Processor;
22
import com.intellij.util.SmartList;
23
import com.perl5.lang.perl.psi.PerlVariableDeclarationElement;
24
import com.perl5.lang.perl.psi.references.PerlImplicitDeclarationsService;
25
import org.jetbrains.annotations.NotNull;
26
import org.jetbrains.annotations.Nullable;
27

28
import java.util.Collection;
29
import java.util.Collections;
30
import java.util.List;
31

32
import static com.perl5.lang.perl.psi.stubs.variables.PerlScalarNamespaceStubIndex.KEY_SCALAR_IN_NAMESPACE;
33
import static com.perl5.lang.perl.psi.stubs.variables.PerlScalarStubIndex.KEY_SCALAR;
34

35

36
public final class PerlScalarUtil {
37
  private PerlScalarUtil() {
38
  }
39

40
  /**
41
   * Searching project files for global scalar definitions by specific package and variable name
42
   *
43
   * @param project       project to search in
44
   * @param canonicalName canonical variable name package::name
45
   * @return Collection of found definitions
46
   */
47
  public static Collection<PerlVariableDeclarationElement> getGlobalScalarDefinitions(Project project, String canonicalName) {
48
    return getGlobalScalarDefinitions(project, canonicalName, GlobalSearchScope.allScope(project));
1✔
49
  }
50

51
  public static @NotNull Collection<PerlVariableDeclarationElement> getGlobalScalarDefinitions(@NotNull Project project,
52
                                                                                               @Nullable String canonicalName,
53
                                                                                               @NotNull GlobalSearchScope scope) {
54
    if (canonicalName == null) {
1!
55
      return Collections.emptyList();
×
56
    }
57
    List<PerlVariableDeclarationElement> result = new SmartList<>();
1✔
58
    processGlobalScalarsByName(project, scope, canonicalName, true, it -> {
1✔
59
      result.add(it);
1✔
60
      return true;
1✔
61
    });
62
    return result;
1!
63
  }
64

65

66
  /**
67
   * Returns list of defined global scalars
68
   *
69
   * @param project project to search in
70
   * @return collection of variable canonical names
71
   */
72
  @SuppressWarnings("StaticMethodOnlyUsedInOneClass")
73
  public static Collection<String> getDefinedGlobalScalarNames(Project project) {
74
    return PerlStubUtil.getAllKeys(KEY_SCALAR, GlobalSearchScope.allScope(project));
1✔
75
  }
76

77
  @SuppressWarnings("UnusedReturnValue")
78
  public static boolean processGlobalScalarsByName(@NotNull Project project,
79
                                                   @NotNull GlobalSearchScope scope,
80
                                                   @NotNull String canonicalName,
81
                                                   boolean processAll,
82
                                                   @NotNull Processor<? super PerlVariableDeclarationElement> processor) {
83
    return PerlImplicitDeclarationsService.getInstance(project).processScalars(canonicalName, processor) &&
1!
84
           PerlVariableUtil.processGlobalVariables(KEY_SCALAR, project, scope, processor, canonicalName, !processAll);
1!
85
  }
86

87
  @SuppressWarnings("StaticMethodOnlyUsedInOneClass")
88
  public static boolean processGlobalScalars(@NotNull Project project,
89
                                             @NotNull GlobalSearchScope scope,
90
                                             @Nullable String namespaceName,
91
                                             boolean processAll,
92
                                             @NotNull Processor<? super PerlVariableDeclarationElement> processor) {
93
    if (namespaceName == null) {
1✔
94
      return PerlImplicitDeclarationsService.getInstance(project).processScalars(processor) &&
1!
95
             PerlVariableUtil.processGlobalVariables(KEY_SCALAR, project, scope, processor, processAll);
1!
96
    }
97
    return PerlImplicitDeclarationsService.getInstance(project).processScalarsInNamespace(namespaceName, processor) &&
1!
98
           PerlVariableUtil.processGlobalVariables(
1!
99
             KEY_SCALAR_IN_NAMESPACE, project, scope, processor, namespaceName, !processAll);
100
  }
101
}
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