• 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

89.66
/plugin/common/src/main/java/com/perl5/lang/perl/parser/elementTypes/PerlBracedBlockElementType.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.parser.elementTypes;
18

19
import com.intellij.lang.ASTNode;
20
import com.intellij.lang.Language;
21
import com.intellij.lang.PsiBuilderUtil;
22
import com.intellij.lexer.Lexer;
23
import com.intellij.openapi.project.Project;
24
import com.intellij.psi.tree.IElementType;
25
import com.perl5.lang.perl.util.PerlTimeLogger;
26
import org.jetbrains.annotations.NotNull;
27

28
import java.util.Stack;
29

30
public abstract class PerlBracedBlockElementType extends PerlReparseableElementType {
31
  public PerlBracedBlockElementType(@NotNull String debugName) {
32
    super(debugName);
1✔
33
  }
1✔
34

35
  @Override
36
  protected boolean isReparseableOld(@NotNull ASTNode parent,
37
                                     @NotNull CharSequence buffer,
38
                                     @NotNull Language fileLanguage,
39
                                     @NotNull Project project) {
40
    Lexer lexer = createLexer(parent, this);
1✔
41
    boolean result = hasProperBraceBalance(buffer, lexer, getOpeningBraceType());
1✔
42
    if (LOG.isDebugEnabled()) {
1!
43
      LOG.debug(this + " reparseable: ", result && isLexerStateOk(lexer.getState()),
1✔
44
                "; size: ", PerlTimeLogger.kb(buffer.length()), " kb",
1✔
45
                "; balanced: ", result,
1✔
46
                "; lexer state: ", lexer.getState());
1✔
47
    }
48
    return result && isLexerStateOk(lexer.getState());
1✔
49
  }
50

51
  protected abstract @NotNull IElementType getOpeningBraceType();
52

53
  protected abstract boolean isLexerStateOk(int lexerState);
54

55
  /**
56
   * Improved copy of {@link PsiBuilderUtil#hasProperBraceBalance(CharSequence, com.intellij.lexer.Lexer, IElementType, IElementType)}
57
   * Checks that all perl braces within range are balanced and properly nested
58
   */
59
  private static boolean hasProperBraceBalance(@NotNull CharSequence text,
60
                                               @NotNull Lexer lexer,
61
                                               @NotNull IElementType openBrace) {
62
    lexer.start(text);
1✔
63

64
    if (lexer.getTokenType() != openBrace) {
1!
65
      return false;
×
66
    }
67

68
    Stack<IElementType> bracesStack = new Stack<>();
1✔
69
    bracesStack.push(openBrace);
1✔
70
    lexer.advance();
1✔
71

72
    return checkBracesBalance(lexer, bracesStack);
1✔
73
  }
74
}
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