• 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
/mojo/core/src/main/java/com/perl5/lang/mojolicious/MojoliciousParserDefinition.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.mojolicious;
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.mojolicious.lexer.MojoliciousLexer;
33
import com.perl5.lang.mojolicious.lexer.MojoliciousLexerAdapter;
34
import com.perl5.lang.mojolicious.psi.impl.MojoliciousFileImpl;
35
import com.perl5.lang.perl.PerlParserDefinition;
36
import com.perl5.lang.perl.lexer.PerlTemplatingLexer;
37
import com.perl5.lang.perl.parser.MojoliciousParser;
38
import org.jetbrains.annotations.NotNull;
39

40
import java.util.Objects;
41

42
import static com.perl5.lang.mojolicious.MojoliciousElementTypes.FILE;
43

44

45
public class MojoliciousParserDefinition extends PerlParserDefinition {
1✔
46
  @Override
47
  public @NotNull TokenSet getCommentTokens() {
48
    return MojoTokenSets.COMMENTS;
1✔
49
  }
50

51
  @Override
52
  public @NotNull Lexer createLexer(Project project) {
53
    return new MojoliciousLexerAdapter(project, false);
1✔
54
  }
55

56
  @Override
57
  public @NotNull IFileElementType getFileNodeType() {
58
    return FILE;
1✔
59
  }
60

61
  @Override
62
  public @NotNull PsiFile createFile(@NotNull FileViewProvider viewProvider) {
63
    return new MojoliciousFileImpl(viewProvider);
1✔
64
  }
65

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

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

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

85
    while (run != null) {
1✔
86
      if (StringUtil.containsLineBreak(run.getChars())) {
1✔
87
        return MojoliciousLexer.PERL_BLOCK;
1✔
88
      }
89
      else if (MojoTokenSets.LINE_OPENERS.contains(run.getElementType())) {
1✔
90
        return MojoliciousLexer.PERL_LINE;
1✔
91
      }
92
      run = TreeUtil.prevLeaf(run);
1✔
93
    }
94

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