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

Camelcade / Perl5-IDEA / #525521559

30 May 2025 06:24AM UTC coverage: 82.248% (-0.03%) from 82.275%
#525521559

push

github

hurricup
Suppressed SameParameterValue warning

30866 of 37528 relevant lines covered (82.25%)

0.82 hits per line

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

96.3
/mason/htmlmason/core/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.PerlElementTypes;
26
import com.perl5.lang.perl.lexer.PerlTemplatingLexer;
27
import org.jetbrains.annotations.Nullable;
28

29
import java.util.Map;
30

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

35

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

186
    return processOpenTagFallback();
1✔
187
  }
188

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