Automatic Detection of SQL?
已回答
Is there a way to not to have to manually inject "SQL" when I start typing a query in a string? I have a file with dozens of queries and it'd be awesome if intellij would automatically detect it and transform it to SQL.
请先登录再写评论。
You can configure the rules so that the injection works automatically where needed: https://www.jetbrains.com/help/idea/using-language-injections.html#configure-injection-rules .
Thanks for the quick reply, Serge. It is not entirely clear from the link you've posted, how exactly one turns it automatically on? E.g. in the below line, you see that Intellij didn't automatically detect that string:
Only when I add the language comment on top, does it transform it to a SQL statement:
The settings themselves, were not changed by me and all injections have a checkmark:
Is there any pattern to the strings containing SQL in your code? You could add a new rule with the value pattern: https://www.jetbrains.com/help/idea/2019.3/language-injection-settings-dialog-java-parameter.html .