top | item 41211776

(no title)

tofflos | 1 year ago

I would have loved to see Java introduce something similar to the IntelliJ @Language-annotation in the standard library but maybe they'll figure out the sweet spot in a future String Templating JEP.

  @Language("application/sql")
  String query = "SELECT 1";

  @Language("application/graphql+json")
  String query = """
                 query HeroNameAndFriends {
                   hero {
                     name
                     friends {
                       name
                     }
                   }
                  }
                  """;

discuss

order

neonsunset|1 year ago

This is exactly how raw string literals together with StringSyntaxAttribute work in C#. It is very useful in e.g Regex syntax highlighting.