• 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

83.33
/plugin/common/src/main/java/com/perl5/lang/perl/psi/mixins/PerlStringMixin.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.mixins;
18

19
import com.intellij.lang.ASTNode;
20
import com.intellij.psi.ElementManipulators;
21
import com.intellij.psi.LiteralTextEscaper;
22
import com.intellij.psi.PsiElement;
23
import com.intellij.psi.PsiLanguageInjectionHost;
24
import com.intellij.psi.tree.IElementType;
25
import com.intellij.psi.util.PsiUtilCore;
26
import com.perl5.lang.perl.idea.intellilang.PerlStringLiteralEscaper;
27
import com.perl5.lang.perl.lexer.PerlTokenSets;
28
import com.perl5.lang.perl.psi.PsiPerlStringSq;
29
import com.perl5.lang.perl.psi.PsiPerlStringXq;
30
import org.jetbrains.annotations.NotNull;
31
import org.jetbrains.annotations.Nullable;
32

33
import static com.perl5.lang.perl.parser.PerlElementTypesGenerated.COMMA_SEQUENCE_EXPR;
34
import static com.perl5.lang.perl.parser.PerlElementTypesGenerated.HASH_INDEX;
35

36

37
public abstract class PerlStringMixin extends PerlStringBareMixin implements PsiLanguageInjectionHost {
38
  public PerlStringMixin(@NotNull ASTNode node) {
39
    super(node);
1✔
40
  }
1✔
41

42
  @Override
43
  public PsiLanguageInjectionHost updateText(@NotNull String text) {
44
    return ElementManipulators.handleContentChange(this, text);
×
45
  }
46

47
  @Override
48
  public @NotNull LiteralTextEscaper<? extends PsiLanguageInjectionHost> createLiteralTextEscaper() {
49
    return new PerlStringLiteralEscaper(this);
1✔
50
  }
51

52
  @Override
53
  public boolean isValidHost() {
54
    PsiElement parent = getParent();
1✔
55
    IElementType parentType = PsiUtilCore.getElementType(parent);
1✔
56
    if (parentType == HASH_INDEX) {
1✔
57
      return false;
1✔
58
    }
59

60
    if (parentType == COMMA_SEQUENCE_EXPR) {
1✔
61
      IElementType grandParentType = PsiUtilCore.getElementType(parent.getParent());
1✔
62
      return grandParentType != HASH_INDEX;
1!
63
    }
64

65
    return true;
1✔
66
  }
67

68
  @Override
69
  public @Nullable PsiElement getFirstContentToken() {
70
    PsiElement openQuote = getOpenQuoteElement();
1✔
71
    if (openQuote == null) {
1!
72
      return null;
×
73
    }
74
    PsiElement nextSibling = openQuote.getNextSibling();
1✔
75
    if (nextSibling == null || nextSibling.equals(getCloseQuoteElement())) {
1!
76
      return null;
1✔
77
    }
78
    return nextSibling;
1✔
79
  }
80

81
  // fixme see #1981
82
  @Override
83
  public @Nullable PsiElement getOpenQuoteElement() {
84
    PsiElement run = getFirstChild();
1✔
85

86
    while (run != null) {
1!
87
      if (PerlTokenSets.OPEN_QUOTES.contains(PsiUtilCore.getElementType(run))) {
1✔
88
        return run;
1✔
89
      }
90
      run = run.getNextSibling();
1✔
91
    }
92
    return null;
×
93
  }
94

95
  // fixme see #1981
96
  @Override
97
  public @Nullable PsiElement getCloseQuoteElement() {
98
    PsiElement lastChild = getLastChild();
1✔
99
    return lastChild != null && PerlTokenSets.CLOSE_QUOTES.contains(PsiUtilCore.getElementType(lastChild)) ? lastChild : null;
1!
100
  }
101

102
  /**
103
   * @return true iff content of the string supports only escapes of quotes and escape symbol
104
   */
105
  public boolean isRestricted() {
106
    return this instanceof PsiPerlStringSq || this instanceof PsiPerlStringXq && getOpenQuote() == '\'';
1!
107
  }
108
}
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