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

Camelcade / Perl5-IDEA / #525521817

11 Apr 2026 04:54PM UTC coverage: 76.061% (+0.07%) from 75.988%
#525521817

push

github

hurricup
Disabled idempotence checking in tests.

I guess we can't achieve that because of names cache.

14772 of 22606 branches covered (65.35%)

Branch coverage included in aggregate %.

31104 of 37709 relevant lines covered (82.48%)

0.82 hits per line

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

80.65
/plugin/common/src/main/java/com/perl5/lang/perl/psi/light/PerlLightSubDefinitionElement.java
1
/*
2
 * Copyright 2015-2026 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.light;
18

19
import com.intellij.navigation.ItemPresentation;
20
import com.intellij.openapi.util.AtomicNotNullLazyValue;
21
import com.intellij.openapi.util.NotNullFactory;
22
import com.intellij.openapi.util.NotNullLazyValue;
23
import com.intellij.openapi.util.NullableLazyValue;
24
import com.intellij.psi.PsiElement;
25
import com.intellij.psi.PsiElementVisitor;
26
import com.intellij.psi.tree.IElementType;
27
import com.perl5.PerlIcons;
28
import com.perl5.lang.perl.idea.codeInsight.typeInference.value.PerlValue;
29
import com.perl5.lang.perl.idea.codeInsight.typeInference.value.PerlValuesManager;
30
import com.perl5.lang.perl.idea.presentations.PerlItemPresentationSimpleDynamicLocation;
31
import com.perl5.lang.perl.psi.*;
32
import com.perl5.lang.perl.psi.impl.PerlPolyNamedElement;
33
import com.perl5.lang.perl.psi.stubs.subsdefinitions.PerlSubDefinitionStub;
34
import com.perl5.lang.perl.psi.utils.PerlResolveUtilCore;
35
import com.perl5.lang.perl.psi.utils.PerlSubAnnotations;
36
import com.perl5.lang.perl.psi.utils.PerlSubArgument;
37
import org.jetbrains.annotations.NotNull;
38
import org.jetbrains.annotations.Nullable;
39

40
import javax.swing.*;
41
import java.util.List;
42

43
import static com.intellij.openapi.util.NullableLazyValue.atomicLazyNullable;
44

45
public class PerlLightSubDefinitionElement<Delegate extends PerlPolyNamedElement<?>> extends PerlDelegatingLightNamedElement<Delegate>
46
  implements PerlSubDefinitionElement {
47
  private final @Nullable String myNamespaceName;
48
  private final @NotNull NullableLazyValue<PerlSubAnnotations> myAnnotationsProvider;
49
  private @NotNull NotNullLazyValue<List<PerlSubArgument>> mySubArgumentsProvider;
50
  private @NotNull NotNullLazyValue<? extends PerlValue> myReturnValueFromCodeProvider;
51
  // fixme should we actualize this on fly, like identifier?
52
  private @Nullable PsiPerlBlock mySubDefinitionBody;
53

54
  public PerlLightSubDefinitionElement(@NotNull Delegate delegate,
55
                                       @NotNull String name,
56
                                       @NotNull IElementType elementType,
57
                                       @Nullable PsiElement nameIdentifier,
58
                                       @Nullable String namespaceName,
59
                                       @NotNull List<PerlSubArgument> subArguments,
60
                                       @Nullable PerlSubAnnotations annotations,
61
                                       @NotNull NotNullLazyValue<? extends PerlValue> returnValueFromCodeProvider,
62
                                       @Nullable PsiPerlBlock subDefinitionBody) {
63
    super(delegate, name, elementType, nameIdentifier);
1✔
64
    myNamespaceName = namespaceName;
1✔
65
    myAnnotationsProvider = atomicLazyNullable(() -> annotations);
1✔
66
    mySubArgumentsProvider = AtomicNotNullLazyValue.createValue(() -> subArguments);
1✔
67
    myReturnValueFromCodeProvider = returnValueFromCodeProvider;
1✔
68
    mySubDefinitionBody = subDefinitionBody;
1✔
69
  }
1✔
70

71
  public PerlLightSubDefinitionElement(@NotNull Delegate delegate,
72
                                       @NotNull String name,
73
                                       @NotNull IElementType elementType,
74
                                       @NotNull PsiElement nameIdentifier,
75
                                       @Nullable String namespaceName,
76
                                       @NotNull PerlSubExpr elementSub) {
77
    super(delegate, name, elementType, nameIdentifier);
1✔
78
    myNamespaceName = namespaceName;
1✔
79
    mySubDefinitionBody = elementSub.getBlock();
1✔
80
    myAnnotationsProvider = atomicLazyNullable(
1✔
81
      () -> PerlSubAnnotations.computeForLightElement(delegate, nameIdentifier));
1✔
82
    mySubArgumentsProvider = AtomicNotNullLazyValue.createValue(
1✔
83
      () -> PerlSubDefinitionElement.getPerlSubArgumentsFromBody(mySubDefinitionBody));
1✔
84
    myReturnValueFromCodeProvider = PerlResolveUtilCore.computeReturnValueFromControlFlowLazy(elementSub);
1✔
85
  }
1✔
86

87
  public PerlLightSubDefinitionElement(@NotNull Delegate delegate, @NotNull PerlSubDefinitionStub stub) {
88
    super(delegate, stub.getSubName(), stub.getElementType());
1✔
89
    myNamespaceName = stub.getNamespaceName();
1✔
90
    mySubArgumentsProvider = AtomicNotNullLazyValue.createValue(stub::getSubArgumentsList);
1✔
91
    myAnnotationsProvider = atomicLazyNullable(stub::getAnnotations);
1✔
92
    myReturnValueFromCodeProvider = AtomicNotNullLazyValue.createValue(stub::getReturnValueFromCode);
1✔
93
  }
1✔
94

95
  protected final void setSubArgumentsProvider(@NotNull NotNullFactory<? extends List<PerlSubArgument>> provider) {
96
    mySubArgumentsProvider = AtomicNotNullLazyValue.createValue(provider);
1✔
97
  }
1✔
98

99
  @Override
100
  public @Nullable String getNamespaceName() {
101
    return myNamespaceName;
1✔
102
  }
103

104
  @Override
105
  public @NotNull List<PerlSubArgument> getSubArgumentsList() {
106
    return mySubArgumentsProvider.getValue();
1!
107
  }
108

109
  @Override
110
  public String getSubName() {
111
    return myName;
1✔
112
  }
113

114
  @Override
115
  public @Nullable PerlSubAnnotations getAnnotations() {
116
    return myAnnotationsProvider.getValue();
1✔
117
  }
118

119
  @Override
120
  public @Nullable String getExplicitNamespaceName() {
121
    return myNamespaceName;
×
122
  }
123

124
  @Override
125
  public boolean equals(Object o) {
126
    if (this == o) {
1✔
127
      return true;
1✔
128
    }
129
    if (!(o instanceof PerlLightSubDefinitionElement<?> element)) {
1✔
130
      return false;
1✔
131
    }
132
    if (!super.equals(o)) {
1✔
133
      return false;
1✔
134
    }
135

136
    if (getNamespaceName() != null ? !getNamespaceName().equals(element.getNamespaceName()) : element.getNamespaceName() != null) {
1!
137
      return false;
×
138
    }
139
    if (!getSubArgumentsList().equals(element.getSubArgumentsList())) {
1!
140
      return false;
×
141
    }
142
    return getAnnotations() != null ? getAnnotations().equals(element.getAnnotations()) : element.getAnnotations() == null;
1!
143
  }
144

145
  @Override
146
  public int hashCode() {
147
    int result = super.hashCode();
1✔
148
    result = 31 * result + (getNamespaceName() != null ? getNamespaceName().hashCode() : 0);
1!
149
    result = 31 * result + getSubArgumentsList().hashCode();
1✔
150
    result = 31 * result + (getAnnotations() != null ? getAnnotations().hashCode() : 0);
1✔
151
    return result;
1✔
152
  }
153

154
  @Override
155
  public @Nullable Icon getIcon(int flags) {
156
    if (isMethod()) {
1!
157
      return PerlIcons.METHOD_GUTTER_ICON;
×
158
    }
159
    else {
160
      return PerlIcons.SUB_GUTTER_ICON;
1✔
161
    }
162
  }
163

164
  @Override
165
  public void accept(@NotNull PsiElementVisitor visitor) {
166
    if (visitor instanceof PerlVisitor perlVisitor) {
1!
167
      perlVisitor.visitPerlSubDefinitionElement(this);
1✔
168
    }
169
    else {
170
      super.accept(visitor);
×
171
    }
172
  }
1✔
173

174
  @Override
175
  public ItemPresentation getPresentation() {
176
    return new PerlItemPresentationSimpleDynamicLocation(this, getSubName());
1✔
177
  }
178

179
  @Override
180
  public @Nullable PsiPerlBlock getSubDefinitionBody() {
181
    return mySubDefinitionBody;
1✔
182
  }
183

184
  @Override
185
  public String toString() {
186
    return "PerlLightSubDefinitionElement{" +
1✔
187
           "myName='" + myName + '\'' +
188
           ", myNamespaceName='" + myNamespaceName + '\'' +
189
           ", myAnnotations=" + getAnnotations() +
1✔
190
           ", mySubArguments=" + getSubArgumentsList() +
1✔
191
           ", myReturnValueFromCode=" + getReturnValueFromCode() +
1✔
192
           '}';
193
  }
194

195
  @Override
196
  public @NotNull PerlValue getReturnValueFromCode() {
197
    return myReturnValueFromCodeProvider.getValue();
1!
198
  }
199

200
  public void setReturnValueFromCode(@NotNull PerlValue returnValueFromCode) {
201
    myReturnValueFromCodeProvider = PerlValuesManager.lazy(returnValueFromCode);
1✔
202
  }
1✔
203

204
  @Override
205
  public @Nullable PsiElement getControlFlowElement() {
206
    return getSubDefinitionBody();
×
207
  }
208

209
  @Override
210
  public @Nullable PsiPerlSignatureContent getSignatureContent() {
211
    return null;
×
212
  }
213
}
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