Java intellij multiple lines of string

I am currently using intellij for java being a phpstorm user, previously I got used to setting strings for multiple strings like this (which I know of is the wrong Java syntax):

@Query("select count(*) from table where
        value= :xxx
        AND value= :xxx2")

      

when it is configured like this:

@Query("select count(*) from table where "+
       "value= :xxx"+
       "AND value2 =:xxx2)

      

Is there any line editor plugin I can use in intelliJ, or some code formatting option I can use to make this more or less phpstorm-like?

+3


source to share


2 answers


I can edit the query and keep its formatting for the Mysql query string by going Alt + Enter -> Inject Language / Reference Mysql, then Alt + Enter again -> Edit Mysql Fragment on Nested Fragment.



+6


source


Not. This is Java, not PHP, so the way that string literals are represented in source code is very strictly defined by the Java Language Specification .

This is a compile-time error for the line terminator that appears after the opening "and before the closing match".



But all modern IDEs help to break the string correctly if you hit Enter on a string literal.

(By the way, your query string is wrong since it reads select count(*) from table wherevalue=...

)

+2


source







All Articles