Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 14566 str template mid #107

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/no-exception-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ jobs:
- run: .ci/no-exception-test.sh openjdk17-with-checks-nonjavadoc-error
# this execution should stay on GitHub actions due to time/ memory limits in other CI
no-exception-openjdk19:
if: github.repository == 'checkstyle/checkstyle'
runs-on: ubuntu-latest
steps:
- name: Set up JDK 11
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,12 @@ tokens {

LITERAL_NON_SEALED, LITERAL_SEALED, LITERAL_PERMITS,
PERMITS_CLAUSE, PATTERN_DEF, LITERAL_WHEN,
RECORD_PATTERN_DEF, RECORD_PATTERN_COMPONENTS
RECORD_PATTERN_DEF, RECORD_PATTERN_COMPONENTS,
RECORD_PATTERN_DEF, RECORD_PATTERN_COMPONENTS,
STRING_TEMPLATE_BEGIN, STRING_TEMPLATE_MID, STRING_TEMPLATE_END,
STRING_TEMPLATE_CONTENT, EMBEDDED_EXPRESSION_BEGIN, EMBEDDED_EXPRESSION,
EMBEDDED_EXPRESSION_END

}

@header {
Expand Down Expand Up @@ -148,6 +153,9 @@ import com.puppycrawl.tools.checkstyle.grammar.CrAwareLexerSimulator;

/** Tracks the starting column of a block comment. */
int startCol = -1;

private int stringTemplateDepth = 0;

}

// Keywords and restricted identifiers
Expand Down Expand Up @@ -242,12 +250,14 @@ LITERAL_FALSE: 'false';

CHAR_LITERAL: '\'' (EscapeSequence | ~['\\\r\n]) '\'';

STRING_LITERAL: '"' (EscapeSequence | ~["\\\r\n])* '"';
fragment StringFragment: (EscapeSequence | ~["\\\r\n])*;
STRING_LITERAL: '"' StringFragment '"';

TEXT_BLOCK_LITERAL_BEGIN: '"' '"' '"' -> pushMode(TextBlock);

LITERAL_NULL: 'null';


// Separators

LPAREN: '(';
Expand Down Expand Up @@ -311,6 +321,10 @@ DOUBLE_COLON: '::';
AT: '@';
ELLIPSIS: '...';

STRING_TEMPLATE_MID: {stringTemplateDepth > 0}?
'}' StringFragment '\\' '{'
;

// Whitespace and comments

WS: [ \t\r\n\u000C]+ -> skip;
Expand Down