Highlight js code in jsdoc comment
Answered
Good day
Can somebody please help me to create “Place pattern” for language injection of js code in jsdoc comment.
I'v already installed PsiViewer and found out path to needed psi element which should be highlighted - it's JSDocDescription
in JSDocTag
with PsiElement(JS:DOC_TAG_NAME)
equals `@body`
I can only guess that pattern could be like this
+ jsDocDescription(jsDocTag().withQualifiedName("@body"))
definitely there should be something else instead of withQualifiedName
Please sign in to leave a comment.
Or maybe patter could be like this?
but I just find out that
jsDocDescription
is invalid patternWill give you example of what I want to achieve
everything after
@example
should be highlighted as js code. Would be great if IDE will not run inspections on it, just syntax highlightingHi Sergii,
I can't find any patterns related to JS docs.
Instead of defining injections via XML, you can implement your custom injection logic programmatically. See:
https://plugins.jetbrains.com/docs/intellij/language-injection.html#languageinjectioncontributor-and-languageinjectionperformer
If you must stick to IntelliLang and XMLs, then it seems you need to implement custom
LanguageInjectionSupport
and register your pattern (which you also need to implement) class withgetPatternClasses
.See https://plugins.jetbrains.com/docs/intellij/language-injection.html#implementation and existing implementations in https://github.com/JetBrains/intellij-community or https://jb.gg/ipe.
Another way is to create a feature request which would allow defining such injections. https://youtrack.jetbrains.com/issues/WEB looks like a correct place for such an issue.