How to enable CSS selector injections in a custom javascript function?
Hi,
When jQuery's `$` function is used, PyCharm highlights the selector string. As one would expect this does not happen for your own custom functions.
How to I enable this behaviour for one of my functions?
Here is a screenshot for reference - parameter for `$` function is highlighted as CSS while the parameter for function `OB` is not.

Thanks
Shobhit
Please sign in to leave a comment.
you can inject CSS in your function manually: put cursor within quotes, hit Alt+Enter, choose Inject language or reference, select JQuery-CSS from the list:
Note that you can make this injection permanent by adding // language=JQuery-CSS comment:
Thanks for the tip, I was wondering if it is possible to do it for the function definition of 'OB' such that everywhere OB is used the string gets highlighted with JQuery-CSS syntax without needing to write the comment multiple times.
This behaviour happens for the jQuery `$` and `$(elem).find` function automatically
After some research I figured it out, It is not exactly user-friendly but does work wonderfully
- Add a custom language injection to JS files in the Language Injection Settings
- Select jQuery-CSS as the language to be injected
- In 'Places Pattern' add the following -
+ jsLiteralExpression().and(jsArgument("OB", 0))- This will inject jQuery-CSS for the string literals that are 0th parameter to function `OB`
Here is an image for reference -
Shobhit V87, THANK YOU!!! You saved me another week of torment in search of a solution to the problem with SQL!