Code-Highlighting of CSS Selectors in Strings

As the title suggests I would like to know how WebStorm (or any other editor) determines whethere a string is a CSS selector.

enter image description here

As seen in this image, WebStorm is aware that the string passed to document.querySelector is a CSS selector and highlights it accordingly.

My own function on the otherhand does not benefit from this.

The type of selectors is string for both my method and querySelector. Is this just hard coded into the editor or do I have any way of telling it that the argument should be treated as a CSS selector?


Certain patterns are known to the editor (hardcoded) - querySelector, querySelectorAll, $ (JQuery), etc. - CSS is auto-injected in such calls.

For your own functions, you need injecting the language manually using injection comments, for example:

// language=JQuery-CSS
scrollToTop('#id')

or create a permanent injection with the following Places pattern: +jsLiteralExpression(jsArgument(jsReferenceExpression().withQualifiedName("scrollToTop"), 0)) in Settings | Editor | Language Injections