• 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

85.37
/mason/htmlmason/common/src/main/java/com/perl5/lang/htmlmason/lexer/HTMLMasonBaseLexer.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.htmlmason.lexer;
18

19
import com.intellij.openapi.project.Project;
20
import com.intellij.openapi.util.text.StringUtil;
21
import com.intellij.psi.tree.IElementType;
22
import com.perl5.lang.htmlmason.idea.configuration.HTMLMasonCustomTag;
23
import com.perl5.lang.htmlmason.idea.configuration.HTMLMasonCustomTagRole;
24
import com.perl5.lang.htmlmason.idea.configuration.HTMLMasonSettings;
25
import com.perl5.lang.perl.lexer.PerlTemplatingLexer;
26
import org.jetbrains.annotations.Nullable;
27

28
import java.util.Map;
29

30
import static com.perl5.lang.htmlmason.HTMLMasonSyntaxElements.KEYWORD_BLOCK_CLOSER;
31
import static com.perl5.lang.htmlmason.elementType.HTMLMasonElementTypes.*;
32
import static com.perl5.lang.htmlmason.lexer.HTMLMasonLexer.*;
33

34

35
public abstract class HTMLMasonBaseLexer extends PerlTemplatingLexer {
1✔
36
  private final CommentEndCalculator COMMENT_END_CALCULATOR = commentText ->
1✔
37
  {
38
    int realLexicalState = getRealLexicalState();
1✔
39
    if (realLexicalState == PERL_EXPR || realLexicalState == PERL_EXPR_FILTER) {
1!
40
      return StringUtil.indexOf(commentText, KEYWORD_BLOCK_CLOSER);
1✔
41
    }
42
    return -1;
1✔
43
  };
44
  protected @Nullable Map<String, HTMLMasonCustomTag> myCustomTagsMap;
45

46
  @Override
47
  protected @Nullable CommentEndCalculator getCommentEndCalculator() {
48
    return COMMENT_END_CALCULATOR;
1✔
49
  }
50

51
  @Override
52
  public HTMLMasonBaseLexer withProject(@Nullable Project project) {
53
    myCustomTagsMap = project == null ? null : HTMLMasonSettings.getInstance(project).getCustomTagsMap();
1!
54
    myPerlLexer.withProject(project);
1✔
55
    return this;
1✔
56
  }
57

58
  @SuppressWarnings("SameReturnValue")
59
  protected IElementType processCloseTagFallback() {
60
    yybegin(NON_CLEAR_LINE);
1✔
61
    return HTML_MASON_TEMPLATE_BLOCK_HTML;
1✔
62
  }
63

64
  @SuppressWarnings("SameReturnValue")
65
  protected IElementType processMethodCloseTag() {
66
    yybegin(AFTER_PERL_BLOCK);
1✔
67
    setPerlToInitial();
1✔
68
    return HTML_MASON_METHOD_CLOSER;
1✔
69
  }
70

71
  @SuppressWarnings("SameReturnValue")
72
  protected IElementType processDefCloseTag() {
73
    yybegin(AFTER_PERL_BLOCK);
1✔
74
    setPerlToInitial();
1✔
75
    return HTML_MASON_DEF_CLOSER;
1✔
76
  }
77

78
  protected IElementType processCustomCloseTag() {
79
    CharSequence tokenText = yytext();
1✔
80
    CharSequence tokenKey = tokenText.subSequence(0, tokenText.length() - 1);
1✔
81
    assert myCustomTagsMap != null;
1!
82
    HTMLMasonCustomTag customTag = myCustomTagsMap.get(tokenKey.toString());
1✔
83
    if (customTag != null) {
1!
84
      HTMLMasonCustomTagRole tagRole = customTag.getRole();
1✔
85
      if (tagRole == HTMLMasonCustomTagRole.METHOD) {
1✔
86
        return processMethodCloseTag();
1✔
87
      }
88
      else if (tagRole == HTMLMasonCustomTagRole.DEF) {
1!
89
        return processDefCloseTag();
1✔
90
      }
91
    }
92
    return processCloseTagFallback();
×
93
  }
94

95
  @SuppressWarnings("SameReturnValue")
96
  protected IElementType processArgsOpenTag(int state) {
97
    yybegin(state);
1✔
98
    startPerlExpression();
1✔
99
    return HTML_MASON_ARGS_OPENER;
1✔
100
  }
101

102
  @SuppressWarnings("SameReturnValue")
103
  protected IElementType processPerlOpenTag(int state) {
104
    yybegin(state);
1✔
105
    return HTML_MASON_PERL_OPENER;
1✔
106
  }
107

108
  @SuppressWarnings("SameReturnValue")
109
  protected IElementType processArgsCloser() {
110
    endPerlExpression();
1✔
111
    yybegin(AFTER_PERL_BLOCK);
1✔
112
    return HTML_MASON_ARGS_CLOSER;
1✔
113
  }
114

115
  protected IElementType processCustomArgsCloser() {
116
    CharSequence tokenText = yytext();
1✔
117
    CharSequence tokenKey = tokenText.subSequence(3, tokenText.length() - 1);
1✔
118
    assert myCustomTagsMap != null;
1!
119
    HTMLMasonCustomTag customTag = myCustomTagsMap.get(tokenKey.toString());
1✔
120
    if (customTag != null && customTag.getRole() == HTMLMasonCustomTagRole.ARGS) {
1!
121
      return processArgsCloser();
1✔
122
    }
123
    return delegateLexing();
×
124
  }
125

126
  @SuppressWarnings("SameReturnValue")
127
  protected IElementType processPerlCloser() {
128
    yybegin(AFTER_PERL_BLOCK);
1✔
129
    return HTML_MASON_PERL_CLOSER;
1✔
130
  }
131

132
  protected IElementType processCustomPerlCloser() {
133
    CharSequence tokenText = yytext();
1✔
134
    CharSequence tokenKey = tokenText.subSequence(3, tokenText.length() - 1);
1✔
135
    assert myCustomTagsMap != null;
1!
136
    HTMLMasonCustomTag customTag = myCustomTagsMap.get(tokenKey.toString());
1✔
137
    if (customTag != null && customTag.getRole() == HTMLMasonCustomTagRole.PERL) {
1!
138
      return processPerlCloser();
1✔
139
    }
140
    return delegateLexing();
×
141
  }
142

143
  @SuppressWarnings("SameReturnValue")
144
  protected IElementType processMethodOpenTag() {
145
    yybegin(PARAMETRIZED_OPENER);
1✔
146
    return HTML_MASON_METHOD_OPENER;
1✔
147
  }
148

149
  @SuppressWarnings("SameReturnValue")
150
  protected IElementType processDefOpenTag() {
151
    yybegin(PARAMETRIZED_OPENER);
1✔
152
    return HTML_MASON_DEF_OPENER;
1✔
153
  }
154

155
  protected IElementType processCustomSimpleOpenTag() {
156
    CharSequence tokenText = yytext();
1✔
157
    CharSequence tokenKey = tokenText.subSequence(0, tokenText.length() - 1);
1✔
158
    assert myCustomTagsMap != null;
1!
159
    HTMLMasonCustomTag customTag = myCustomTagsMap.get(tokenKey.toString());
1✔
160
    if (customTag != null) {
1✔
161
      HTMLMasonCustomTagRole tagRole = customTag.getRole();
1✔
162
      if (tagRole == HTMLMasonCustomTagRole.ARGS) {
1✔
163
        return processArgsOpenTag(ARGS_WITH_CUSTOM_CLOSER);
1✔
164
      }
165
      else if (tagRole == HTMLMasonCustomTagRole.PERL) {
1!
166
        return processPerlOpenTag(PERL_WITH_CUSTOM_CLOSER);
1✔
167
      }
168
    }
169
    return processOpenTagFallback();
1✔
170
  }
171

172
  protected IElementType processCustomComplexOpenTag() {
173
    assert myCustomTagsMap != null;
1!
174
    HTMLMasonCustomTag customTag = myCustomTagsMap.get(yytext().toString());
1✔
175
    if (customTag != null) {
1✔
176
      HTMLMasonCustomTagRole tagRole = customTag.getRole();
1✔
177
      if (tagRole == HTMLMasonCustomTagRole.METHOD) {
1✔
178
        return processMethodOpenTag();
1✔
179
      }
180
      else if (tagRole == HTMLMasonCustomTagRole.DEF) {
1!
181
        return processDefOpenTag();
1✔
182
      }
183
    }
184

185
    return processOpenTagFallback();
1✔
186
  }
187

188
  @SuppressWarnings("SameReturnValue")
189
  protected IElementType processOpenTagFallback() {
190
    pushback();
1✔
191
    startPerlExpression();
1✔
192
    yybegin(PERL_EXPR);
1✔
193
    return HTML_MASON_BLOCK_OPENER;
1✔
194
  }
195
}
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