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

Support Java 21 String Template Syntax (Text Blocks) #14195

Closed
nrmancuso opened this issue Dec 28, 2023 · 6 comments · May be fixed by #14390
Closed

Support Java 21 String Template Syntax (Text Blocks) #14195

nrmancuso opened this issue Dec 28, 2023 · 6 comments · May be fixed by #14390
Assignees

Comments

@nrmancuso
Copy link
Member

nrmancuso commented Dec 28, 2023

Continuation of #13830, we need to add support for text block syntax.

➜  src cat Test.java         
public class Test {
    void m0() {
        // string template
        String s = STR."x"; // added in #13830
    }

    void m1() {
        String s = "x";
    }

    void m2() {
        // text block string  template
        String s = STR."""
                x
                """;
    }
}
➜  src javac --enable-preview --release 21 Test.java
Note: Test.java uses preview features of Java SE 21.
Note: Recompile with -Xlint:preview for details.
➜  src java -jar checkstyle-10.12.8-SNAPSHOT-all.jar -t Test.java
com.puppycrawl.tools.checkstyle.api.CheckstyleException: IllegalStateException occurred while parsing file Test.java.
        at com.puppycrawl.tools.checkstyle.JavaParser.parse(JavaParser.java:104)
        at com.puppycrawl.tools.checkstyle.JavaParser.parseFileText(JavaParser.java:121)
        at com.puppycrawl.tools.checkstyle.JavaParser.parseFile(JavaParser.java:141)
        at com.puppycrawl.tools.checkstyle.AstTreeStringPrinter.printFileAst(AstTreeStringPrinter.java:65)
        at com.puppycrawl.tools.checkstyle.Main.runCli(Main.java:291)
        at com.puppycrawl.tools.checkstyle.Main.execute(Main.java:195)
        at com.puppycrawl.tools.checkstyle.Main.main(Main.java:130)
Caused by: java.lang.IllegalStateException: 13:22: mismatched input '.' expecting ';'
        at com.puppycrawl.tools.checkstyle.JavaParser$CheckstyleErrorListener.syntaxError(JavaParser.java:254)
...
Caused by: org.antlr.v4.runtime.InputMismatchException
        ... 20 more
Checkstyle ends with 1 errors.


Link to grammar: https://docs.oracle.com/javase/specs/jls/se21/preview/specs/string-templates-jls.html

TextBlockTemplateBegin:
    """ { TextBlockWhiteSpace } LineTerminator TextBlockFragment \{

TextBlockTemplateMid:
    } TextBlockFragment \{

TextBlockTemplateEnd:
    } TextBlockFragment """

TextBlockFragment:
    { TextBlockCharacter }
@nrmancuso nrmancuso self-assigned this Dec 28, 2023
@romani romani added the antlr label Dec 28, 2023
@nrmancuso nrmancuso changed the title Support Java 21 String Template Syntax (Text Blocks) [WIP] Support Java 21 String Template Syntax (Text Blocks) Jan 18, 2024
@checkstyle checkstyle deleted a comment from nrmancuso Jan 18, 2024
nrmancuso added a commit to nrmancuso/checkstyle that referenced this issue Jan 30, 2024
nrmancuso added a commit to nrmancuso/checkstyle that referenced this issue Jan 30, 2024
nrmancuso added a commit to nrmancuso/checkstyle that referenced this issue Jan 31, 2024
nrmancuso added a commit to nrmancuso/checkstyle that referenced this issue Jan 31, 2024
nrmancuso added a commit to nrmancuso/checkstyle that referenced this issue Feb 1, 2024
nrmancuso added a commit to nrmancuso/checkstyle that referenced this issue Feb 1, 2024
nrmancuso added a commit to nrmancuso/checkstyle that referenced this issue Feb 1, 2024
nrmancuso added a commit to nrmancuso/checkstyle that referenced this issue Feb 1, 2024
nrmancuso added a commit to nrmancuso/checkstyle that referenced this issue Feb 1, 2024
nrmancuso added a commit to nrmancuso/checkstyle that referenced this issue Feb 5, 2024
nrmancuso added a commit to nrmancuso/checkstyle that referenced this issue Feb 7, 2024
nrmancuso added a commit to nrmancuso/checkstyle that referenced this issue Feb 8, 2024
nrmancuso added a commit to nrmancuso/checkstyle that referenced this issue Feb 12, 2024
nrmancuso added a commit to nrmancuso/checkstyle that referenced this issue Feb 12, 2024
nrmancuso added a commit to nrmancuso/checkstyle that referenced this issue Feb 20, 2024
nrmancuso added a commit to nrmancuso/checkstyle that referenced this issue Feb 20, 2024
nrmancuso added a commit to nrmancuso/checkstyle that referenced this issue Feb 20, 2024
nrmancuso added a commit to nrmancuso/checkstyle that referenced this issue Mar 4, 2024
nrmancuso added a commit to nrmancuso/checkstyle that referenced this issue Mar 4, 2024
nrmancuso added a commit to nrmancuso/checkstyle that referenced this issue Mar 4, 2024
nrmancuso added a commit to nrmancuso/checkstyle that referenced this issue Mar 4, 2024
nrmancuso added a commit to nrmancuso/checkstyle that referenced this issue Mar 4, 2024
nrmancuso added a commit to nrmancuso/checkstyle that referenced this issue Mar 4, 2024
nrmancuso added a commit to nrmancuso/checkstyle that referenced this issue Mar 5, 2024
nrmancuso added a commit to nrmancuso/checkstyle that referenced this issue Mar 5, 2024
nrmancuso added a commit to nrmancuso/checkstyle that referenced this issue Mar 15, 2024
nrmancuso added a commit to nrmancuso/checkstyle that referenced this issue Mar 15, 2024
nrmancuso added a commit to nrmancuso/checkstyle that referenced this issue Mar 15, 2024
@nrmancuso
Copy link
Member Author

I am removing approved label from this issue. Java is not supporting this syntax any longer, nor should we.

#14805

@romani
Copy link
Member

romani commented Apr 17, 2024

We can close issue, it is delayed for long time. We can reopen it later on or create new without old context that might be confusing in future.

@romani
Copy link
Member

romani commented Apr 17, 2024

Removal of this syntax support will be done at #14805

@romani
Copy link
Member

romani commented Apr 18, 2024

Reopened as we need to remove some suppression of validation in code.
We need to change referenced issue to issue where we remove template support

#14807 (comment)

@MANISH-K-07
Copy link
Contributor

Reopened as we need to remove some suppression of validation in code. We need to change referenced issue to issue where we remove template support

@romani , @nrmancuso , can I help in anyway regarding this?

@nrmancuso
Copy link
Member Author

#14809

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants