Skip to content

Support for Java 14 switch/yield expression #6615

Closed
@krzyk

Description

@krzyk

Running checkstyle validation on a class that contains switch expression:

        return switch (c.getLocation().toLowerCase()) {                                                                                                                                                                      
            case "query" -> String.format("ARGS_GET:%s", c.getFullPath().get(0));
            case "header" -> String.format("REQUEST_HEADERS:%s", c.getFullPath().get(0));
            case "cookie" -> String.format("REQUEST_COOKIES:%s", c.getFullPath().get(0));
            default -> "";                                                      
        };                                                                      

fails with:

unexpected token: switch

And also

expecting EOF, found 'case'

FIX Summary:
new Tokens are created. Syntax should be supported, Checks will be updated later on, See follow up issues.
see #8449 for more details


Metadata

Metadata

Assignees

No one assigned

    Labels

    antlrapprovedhas bountyissue has some money incentive to fix it, https://www.bountysource.com/teams/checkstyle/issuesnew feature

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions