• 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

71.43
/plugin/backend/src/main/java/com/perl5/lang/perl/util/PerlGlobUtil.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.progress.ProgressManager;
20
import com.intellij.openapi.project.Project;
21
import com.intellij.psi.search.GlobalSearchScope;
22
import com.intellij.psi.stubs.StubIndex;
23
import com.intellij.util.Processor;
24
import com.perl5.lang.perl.psi.PerlGlobVariableElement;
25
import com.perl5.lang.perl.psi.PsiPerlGlobVariable;
26
import com.perl5.lang.perl.psi.stubs.globs.PerlGlobStubIndex;
27
import org.jetbrains.annotations.NotNull;
28
import org.jetbrains.annotations.Nullable;
29

30
import java.util.Collection;
31
import java.util.Collections;
32
import java.util.HashSet;
33
import java.util.Set;
34

35
import static com.perl5.lang.perl.psi.stubs.globs.PerlGlobNamespaceStubIndex.KEY_GLOB_NAMESPACE;
36

37

38
public final class PerlGlobUtil {
39
  private PerlGlobUtil() {
40
  }
41

42
  /**
43
   * Searching project files for sub definitions by specific package and function name
44
   *
45
   * @param project       project to search in
46
   * @param canonicalName canonical function name package::name
47
   * @return collection of found definitions
48
   */
49
  public static Collection<PsiPerlGlobVariable> getGlobsDefinitions(@NotNull Project project, @Nullable String canonicalName) {
50
    return getGlobsDefinitions(project, canonicalName, GlobalSearchScope.allScope(project));
1✔
51
  }
52

53
  public static Collection<PsiPerlGlobVariable> getGlobsDefinitions(@NotNull Project project,
54
                                                                    @Nullable String canonicalName,
55
                                                                    @NotNull GlobalSearchScope scope) {
56
    if (canonicalName == null) {
1!
57
      return Collections.emptyList();
×
58
    }
59
    return StubIndex.getElements(PerlGlobStubIndex.KEY_GLOB, canonicalName, project, scope, PsiPerlGlobVariable.class);
1✔
60
  }
61

62
  public static @NotNull Collection<PsiPerlGlobVariable> getGlobsDefinitionsInNamespace(@NotNull Project project,
63
                                                                                        @Nullable String namespaceName) {
64
    return getGlobsDefinitionsInNamespace(project, namespaceName, GlobalSearchScope.allScope(project));
1✔
65
  }
66

67
  public static @NotNull Collection<PsiPerlGlobVariable> getGlobsDefinitionsInNamespace(@NotNull Project project,
68
                                                                                        @Nullable String namespaceName,
69
                                                                                        @NotNull GlobalSearchScope scope) {
70
    if (namespaceName == null) {
1!
71
      return Collections.emptyList();
×
72
    }
73
    return StubIndex.getElements(KEY_GLOB_NAMESPACE, namespaceName, project, scope, PsiPerlGlobVariable.class);
1!
74
  }
75

76
  /**
77
   * Returns list of known stubbed globs
78
   *
79
   * @param project project to search in
80
   * @return collection of globs names
81
   */
82
  public static Collection<String> getDefinedGlobsNames(Project project) {
83
    return PerlStubUtil.getAllKeys(PerlGlobStubIndex.KEY_GLOB, GlobalSearchScope.allScope(project));
1✔
84
  }
85

86
  @SuppressWarnings("StaticMethodOnlyUsedInOneClass")
87
  public static boolean processGlobs(@NotNull Project project,
88
                                     @NotNull GlobalSearchScope scope,
89
                                     @Nullable String namespaceName,
90
                                     boolean processAll,
91
                                     @NotNull Processor<? super PerlGlobVariableElement> processor) {
92
    Set<String> namespacesToProcess;
93
    if (namespaceName == null) {
1✔
94
      namespacesToProcess = new HashSet<>(getDefinedGlobsNames(project));
1✔
95
    }
96
    else {
97
      namespacesToProcess = Collections.singleton(namespaceName);
1✔
98
    }
99
    Set<String> processedNames = processAll ? null : new HashSet<>();
1!
100
    for (String namespace : namespacesToProcess) {
1✔
101
      if (!StubIndex.getInstance().processElements(KEY_GLOB_NAMESPACE, namespace, project, scope, PsiPerlGlobVariable.class, it -> {
1!
102
        ProgressManager.checkCanceled();
1✔
103
        String canonicalName = it.getCanonicalName();
1✔
104
        if (processAll || processedNames.add(canonicalName)) {
1!
105
          return processor.process(it);
1✔
106
        }
107
        return true;
1✔
108
      })){
109
        return false;
×
110
      }
111
    }
1✔
112
    return true;
1✔
113
  }
114

115
  @SuppressWarnings({"StaticMethodOnlyUsedInOneClass", "UnusedReturnValue"})
116
  public static boolean processGlobsByName(@NotNull Project project,
117
                                           @NotNull GlobalSearchScope scope,
118
                                           @NotNull String canonicalName,
119
                                           @NotNull Processor<? super PerlGlobVariableElement> processor,
120
                                           boolean processAll) {
121
    Set<String> processedNames = processAll ? null : new HashSet<>();
1!
122
    return StubIndex.getInstance().processElements(PerlGlobStubIndex.KEY_GLOB, canonicalName, project, scope, PsiPerlGlobVariable.class, it -> {
1✔
123
      ProgressManager.checkCanceled();
1✔
124
      String globName = it.getCanonicalName();
1✔
125
      if (processAll || processedNames.add(globName)) {
1!
126
        return processor.process(it);
1✔
127
      }
128
      return true;
×
129
    });
130
  }
131
}
132

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