简体   繁体   English

Java intellij多行字符串

[英]Java intellij multiple line strings

I am currently devving in inttelij for java, being a phpstorm user previously I am used to setting up strings the span multiple lines like this (which I am aware is incorrect Java syntax): 我目前正在使用inttelij for java,作为一个phpstorm用户以前我习惯于设置字符串这样的跨度多行(我知道这是不正确的Java语法):

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

when it expects to be set up like this: 当它希望设置如下:

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

Is there some kind of string editor plugin I can use on intelliJ, or some kind of code formatting option I can use to make this more or less like phpstorm? 是否有某种字符串编辑器插件我可以在intelliJ上使用,或者某种代码格式化选项我可以用来使这或多或少像phpstorm?

我可以通过按Alt + Enter - > Inject Language / Reference Mysql然后Alt + Enter再次 - >编辑注入片段上的Mysql片段来编辑查询并维护其Mysql查询字符串的格式。

No. This is Java, not PHP so the way string literals are represented in source code is defined very strictly by the Java Language Specification . 不。这是Java,而不是PHP,因此字符串文字在源代码中的表示方式由Java语言规范严格定义。

It is a compile-time error for a line terminator to appear after the opening " and before the closing matching ". 行终止符在打开“和结束匹配之前”之后出现是编译时错误。

But all modern IDEs help by breaking the string correctly if you press Enter within a string literal. 但是,如果在字符串文字中按Enter键,则所有现代IDE都可以通过正确断开字符串来提供帮助。

(By the way, your query string is wrong, as it reads select count(*) from table wherevalue=... ) (顺便说一下,你的查询字符串是错误的,因为它select count(*) from table wherevalue=...读取select count(*) from table wherevalue=...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM