Extending syntax checking
Hi all,
I am developing a plugin which will be ignore the syntax checking errors in IDE with my custom rules,I will be having template code inside language, I wanted to add rules to check my custom syntax for existing languages
请先登录再写评论。
Hello Saleeh,
Why do you need a plugin like this?
Syntaxically wrong code won't be executed, why writing it in the first place?
Hi Saleeh,
You could define both languages in one bnf file.
just make sure the lexer can figure out, which elements belong to which language, and return the appropriate element type.
If bnf is defined correctly, syntax will be checked against both languages.
There are probably other ways to do this, but this could work too.
Irina,
Saleeh needs to mix languages in one file type. This is common in some frameworks e.g. MVC: Html and C#.Net. Or Html and JavaScript
This mixed code -if valid- should not throw errors.
Because there is parsing template with values before compilation process
Can I add it to existing languages like java and xml.etc?
it is probably possible.
these files may be relevant:
Java
Lexer:
https://github.com/JetBrains/intellij-community/blob/a5cd6ac6102731ea9b557dcc1c684340f7d8432a/java/java-psi-impl/src/com/intellij/lang/java/lexer/JavaLexer.java
Parser:
https://github.com/JetBrains/intellij-community/blob/a5cd6ac6102731ea9b557dcc1c684340f7d8432a/java/java-psi-impl/src/com/intellij/lang/java/parser/JavaParser.java
XML
Lexer:
https://github.com/JetBrains/intellij-community/blob/a5cd6ac6102731ea9b557dcc1c684340f7d8432a/xml/xml-psi-impl/src/com/intellij/lexer/XmlLexer.java
Parser:
https://github.com/JetBrains/intellij-community/blob/a5cd6ac6102731ea9b557dcc1c684340f7d8432a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/parsing/xml/XmlParser.java
This is not a simple task.