Parse and Tokenize a part of PHPDocComment with own Parser and Lexer
Answered
Hey,
I'm looking for the ability to parse and tokenize a part of PHPDoc by my own. But I don't know how to do it, I had different approaches with the file type (overring php file type and so on), but that did not work well. Could someone give me a hint? :)
Thx
Please sign in to leave a comment.
What do you want to achieve?
I want to highlight doctrine annotations and add further code assistance (like formatting, syntax error annotating). For this I already implemented my own lexer and parser. Now I need to know, how to "inject" the parsing into the PHPDocComment.
Hello. We have experimental EP `docTagParserExtension` for custom doc tag parsing, you may try to use it. Here is the examples for Psalm support:
https://github.com/JetBrains/phpstorm-psalm-plugin/blob/745774d6b35129d87792e7886e9e3e8c52177a88/src/com/jetbrains/php/psalm/lang/documentation/parser/PsalmDocVarTagParser.java
https://github.com/JetBrains/phpstorm-psalm-plugin/blob/77c624d04e44f6f523a97e95ef671c996f6cf101/src/META-INF/plugin.xml#L66