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

Camelcade / Perl5-IDEA / #525521819

12 Apr 2026 11:03AM UTC coverage: 76.189% (+0.1%) from 76.061%
#525521819

push

github

hurricup
[qodana] Suppressed a warning on the api method

14764 of 22542 branches covered (65.5%)

Branch coverage included in aggregate %.

31091 of 37644 relevant lines covered (82.59%)

0.83 hits per line

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

77.03
/plugin/common/src/main/java/com/perl5/lang/perl/lexer/PerlLexerWithCustomStatesAdapter.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.lexer;
18

19
import com.intellij.lexer.LexerBase;
20
import com.intellij.psi.tree.IElementType;
21
import org.jetbrains.annotations.NotNull;
22

23
import java.io.IOException;
24

25

26
public class PerlLexerWithCustomStatesAdapter extends LexerBase {
1✔
27
  private final PerlLexerWithCustomStates myFlex;
28
  private IElementType myTokenType = null;
1✔
29
  private CharSequence myText;
30

31
  private int myEnd;
32
  private int myState;
33

34
  public PerlLexerWithCustomStatesAdapter(PerlLexerWithCustomStates lexer) {
1✔
35
    myFlex = lexer;
1✔
36
  }
1✔
37

38
  @Override
39
  public void start(final @NotNull CharSequence buffer, int startOffset, int endOffset, int initialState) {
40
    myText = buffer;
1✔
41
    myEnd = endOffset;
1✔
42

43
    if (startOffset == 0 && initialState == PerlLexer.YYINITIAL)    // beginning of doc
1✔
44
    {
45
      myFlex.setCustomState(myFlex.getInitialCustomState());
1✔
46
    }
47
    else if (initialState > 0xFFFF)    // properly packed state
1!
48
    {
49
      myFlex.setCustomState(PerlTemplatingLexer.getTemplateLexerState(initialState));
1✔
50
      initialState = PerlTemplatingLexer.getPerlLexerState(initialState);
1✔
51
    }
52
    else {
53
      throw new RuntimeException("Shouldn't be here, inproperly packed state");
×
54
    }
55

56
    myFlex.reset(myText, startOffset, endOffset, initialState);
1✔
57
    myTokenType = null;
1✔
58
  }
1✔
59

60
  @Override
61
  public int getState() {
62
    if (myTokenType == null) {
1✔
63
      locateToken();
1✔
64
    }
65
    return myState;
1✔
66
  }
67

68
  @Override
69
  public IElementType getTokenType() {
70
    if (myTokenType == null) {
1✔
71
      locateToken();
1✔
72
    }
73
    return myTokenType;
1✔
74
  }
75

76
  @Override
77
  public int getTokenStart() {
78
    if (myTokenType == null) {
1✔
79
      locateToken();
1✔
80
    }
81
    return myFlex.getTokenStart();
1✔
82
  }
83

84
  @Override
85
  public int getTokenEnd() {
86
    if (myTokenType == null) {
1!
87
      locateToken();
×
88
    }
89
    return myFlex.getTokenEnd();
1✔
90
  }
91

92
  @Override
93
  public void advance() {
94
    if (myTokenType == null) {
1!
95
      locateToken();
×
96
    }
97
    myTokenType = null;
1✔
98
  }
1✔
99

100
  @Override
101
  public @NotNull CharSequence getBufferSequence() {
102
    return myText;
1!
103
  }
104

105
  @Override
106
  public int getBufferEnd() {
107
    return myEnd;
×
108
  }
109

110
  protected void compileState() {
111
    int customState = myFlex.getCustomState();
1✔
112
    int lexerState = myFlex.yystate();
1✔
113

114
    assert customState < 0x10000 && lexerState < 0x10000 : "Custom state: " + customState + "; lexerState: " + lexerState;
1!
115
    myState = PerlTemplatingLexer.packState(lexerState, customState);
1✔
116
  }
1✔
117

118
  protected void locateToken() {
119
    if (myTokenType != null) {
1!
120
      return;
×
121
    }
122
    try {
123
      compileState();
1✔
124
      myTokenType = myFlex.advance();
1✔
125
    }
126
    catch (IOException e) { /*Can't happen*/ }
×
127
    catch (Error e) {
×
128
      // add lexer class name to the error
129
      final Error error = new Error(myFlex.getClass().getName() + ": " + e.getMessage());
×
130
      error.setStackTrace(e.getStackTrace());
×
131
      throw error;
×
132
    }
1✔
133
  }
1✔
134
}
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