javascriptjavaintellij-idea

How to auto inject language by place pattern in Intellij IDEA?


How to configure Intellij IDEA to automatically inject SQL language inside JS files for string template functions? For example i want to inject SQL for this code:

const query = SQL`SELECT * FROM table`;

In PSI Viewer i found that this is JSStringTemplateExpression node. How to configure place pattern for this PSI node?


Solution

  • The following places pattern works for me:

    + jsLiteralExpression().withText(string().startsWith("SQL`"))