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

Camelcade / Perl5-IDEA / #525521519

21 Apr 2025 01:57PM UTC coverage: 82.17% (+0.01%) from 82.156%
#525521519

push

github

hurricup
CAMELCADE-22634 Cleanup

8 of 8 new or added lines in 2 files covered. (100.0%)

102 existing lines in 15 files now uncovered.

30868 of 37566 relevant lines covered (82.17%)

0.82 hits per line

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

94.74
/mason/htmlmason/core/src/main/java/com/perl5/lang/htmlmason/HTMLMasonParserDefinition.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;
18

19
import com.intellij.lang.ASTNode;
20
import com.intellij.lang.PsiParser;
21
import com.intellij.lexer.Lexer;
22
import com.intellij.openapi.project.Project;
23
import com.intellij.openapi.util.text.StringUtil;
24
import com.intellij.psi.FileViewProvider;
25
import com.intellij.psi.PsiElement;
26
import com.intellij.psi.PsiFile;
27
import com.intellij.psi.impl.source.DummyHolder;
28
import com.intellij.psi.impl.source.tree.TreeUtil;
29
import com.intellij.psi.tree.IElementType;
30
import com.intellij.psi.tree.IFileElementType;
31
import com.intellij.psi.tree.TokenSet;
32
import com.perl5.lang.htmlmason.elementType.HTMLMasonTokenSets;
33
import com.perl5.lang.htmlmason.lexer.HTMLMasonLexer;
34
import com.perl5.lang.htmlmason.lexer.HTMLMasonLexerAdapter;
35
import com.perl5.lang.htmlmason.parser.psi.impl.HTMLMasonFileImpl;
36
import com.perl5.lang.perl.PerlParserDefinition;
37
import com.perl5.lang.perl.lexer.PerlTemplatingLexer;
38
import com.perl5.lang.perl.parser.HTMLMasonParserImpl;
39
import org.jetbrains.annotations.NotNull;
40

41
import java.util.Objects;
42

43
import static com.perl5.lang.htmlmason.elementType.HTMLMasonElementTypes.*;
44

45
public class HTMLMasonParserDefinition extends PerlParserDefinition {
1✔
46
  @Override
47
  public @NotNull Lexer createLexer(Project project) {
48
    return new HTMLMasonLexerAdapter(project, false);
1✔
49
  }
50

51
  @Override
52
  public @NotNull IFileElementType getFileNodeType() {
53
    return FILE;
1✔
54
  }
55

56
  @Override
57
  public @NotNull PsiFile createFile(@NotNull FileViewProvider viewProvider) {
58
    return new HTMLMasonFileImpl(viewProvider);
1✔
59
  }
60

61
  @Override
62
  public @NotNull TokenSet getCommentTokens() {
63
    return HTMLMasonTokenSets.COMMENTS;
1✔
64
  }
65

66
  @Override
67
  public @NotNull PsiParser createParser(Project project) {
68
    return new HTMLMasonParserImpl();
1✔
69
  }
70

71
  @Override
72
  public int getLexerStateFor(@NotNull ASTNode contextNode, @NotNull IElementType elementType) {
73
    return PerlTemplatingLexer.packState(super.getLexerStateFor(contextNode, elementType),
1✔
74
                                         getTemplatingState(contextNode, elementType));
1✔
75
  }
76

77
  private int getTemplatingState(@NotNull ASTNode contextNode, @NotNull IElementType elementType) {
78
    if (elementType == HTML_MASON_TEMPLATE_BLOCK_HTML) {
1✔
79
      return HTMLMasonLexer.YYINITIAL;
1✔
80
    }
81
    PsiElement parent = contextNode.getPsi().getParent();
1✔
82
    ASTNode run = parent instanceof DummyHolder ? Objects.requireNonNull(parent.getContext()).getNode() : contextNode;
1✔
83

84
    while (run != null) {
1✔
85
      if (StringUtil.containsLineBreak(run.getChars())) {
1✔
86
        return HTMLMasonLexer.PERL;
1✔
87
      }
88
      else if (run.getElementType() == HTML_MASON_LINE_OPENER) {
1✔
89
        return HTMLMasonLexer.PERL_LINE;
1✔
90
      }
91
      run = TreeUtil.prevLeaf(run);
1✔
92
    }
93

UNCOV
94
    return HTMLMasonLexer.YYINITIAL;
×
95
  }
96
}
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