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

Camelcade / Perl5-IDEA / #525521563

01 Jun 2025 02:15PM UTC coverage: 82.332% (+0.04%) from 82.289%
#525521563

push

github

hurricup
Bounded wildcards

2 of 2 new or added lines in 2 files covered. (100.0%)

69 existing lines in 17 files now uncovered.

30882 of 37509 relevant lines covered (82.33%)

0.82 hits per line

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

86.96
/plugin/core/src/main/java/com/perl5/lang/perl/psi/PerlAnnotationType.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.util.text.StringUtil;
20
import com.intellij.psi.PsiElement;
21
import com.intellij.psi.util.CachedValueProvider;
22
import com.intellij.psi.util.CachedValuesManager;
23
import com.intellij.psi.util.PsiModificationTracker;
24
import com.perl5.lang.perl.psi.utils.PerlVariableAnnotations;
25
import org.jetbrains.annotations.Contract;
26
import org.jetbrains.annotations.NotNull;
27
import org.jetbrains.annotations.Nullable;
28

29
import java.util.ArrayList;
30
import java.util.List;
31

32
public interface PerlAnnotationType extends PerlAnnotationWithValue {
33

34
  @SuppressWarnings("override")
35
  @Nullable
36
  PsiPerlAnnotationVariable getAnnotationVariable();
37

38
  /**
39
   * @return true iff annotation has no variable name and may be applied to any variable in context.
40
   */
41
  default boolean isWildCard() {
42
    return getAnnotationVariable() == null;
1✔
43
  }
44

45
  /**
46
   * @return true iff this {@code #@type} annotation may describe the {@code perlVariable}. Have same type and name.
47
   */
48
  @Contract("null->false")
49
  default boolean accept(@Nullable PerlVariable perlVariable) {
50
    if (perlVariable == null) {
1✔
UNCOV
51
      return false;
×
52
    }
53
    var annotationVariable = getAnnotationVariable();
1✔
54
    if (annotationVariable == null) {
1✔
55
      return true;
1✔
56
    }
57
    var annotationVariableName = annotationVariable.getNode().getChars();
1✔
58
    return perlVariable.getActualType().getSigil() == annotationVariableName.charAt(0) &&
1✔
59
           StringUtil.equal(perlVariable.getName(), annotationVariableName.subSequence(1, annotationVariableName.length()), true);
1✔
60
  }
61

62
  /**
63
   * @return collection of declarations this annotation applies to
64
   */
65
  default @NotNull List<PerlVariableDeclarationElement> getTargets() {
66
    return CachedValuesManager.getCachedValue(
1✔
67
      this,
68
      () -> CachedValueProvider.Result.create(computeTargets(this), PsiModificationTracker.MODIFICATION_COUNT));
1✔
69
  }
70

71
  /**
72
   * @return wrapping comment {@link PsiElement}
73
   */
74
  default @NotNull PerlAnnotationContainer getAnnotationContainer() {
75
    var parent = getParent();
1✔
76
    if (parent instanceof PerlAnnotationContainer annotationContainer) {
1✔
77
      return annotationContainer;
1✔
78
    }
79
    throw new IllegalStateException(
×
UNCOV
80
      "Type annotation is expected to be inside " + PerlAnnotationContainer.class.getSimpleName() + ", not " + parent);
×
81
  }
82

83
  /**
84
   * @return list of variable declarations {@code typeAnnotation} applies to
85
   */
86
  static @NotNull List<PerlVariableDeclarationElement> computeTargets(@NotNull PerlAnnotationType typeAnnotation) {
87
    var result = new ArrayList<PerlVariableDeclarationElement>();
1✔
88
    PerlVariableAnnotations.processPotentialTargets(typeAnnotation, it -> PerlVariableAnnotations.processAnnotations(it,
1✔
89
                                                                                                                     new PerlVariableAnnotations.VariableAnnotationProcessor() {
1✔
90
                                                                                                                       @Override
91
                                                                                                                       public boolean processType(
92
                                                                                                                         @NotNull PerlAnnotationType annotationType) {
93
                                                                                                                         if (annotationType.equals(
1✔
94
                                                                                                                           typeAnnotation)) {
95
                                                                                                                           result.add(it);
1✔
96
                                                                                                                         }
97
                                                                                                                         return true;
1✔
98
                                                                                                                       }
99
                                                                                                                     }));
100
    return result;
1✔
101
  }
102
}
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