Source for simple language plugin
Hi,
Are there sources of simple plugin which adds language to IDEA? Javascript plugin was the perfect, but it doesn't seem to work with latest version. Ruby, groovy those are too big.
Prefferably imperative language.
Thanks.
:sergiy
Please sign in to leave a comment.
Hello Sergiy,
Most of the third-party language plugins available in the plugin repository
are open-source.
http://plugins.intellij.net/category/?idea&category_id=48
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
Thanks. Found several, after looking at them for half a day they don't look that complex after all.
Is it possible to implement just syntax highlighting? I registered
<fileTypeFactory implementation="org.dubik.intelliantlr.AntlrFileTypeFactory"/>
<lang.syntaxHighlighterFactory key="antlr" implementationClass="org.dubik.intelliantlr.lang.highlighting.AntlrHighlightingFactory"/>
I implemented simple lexer and added several tokens. Token is "import". If I have it in the file, and just open it, it's colored and no exceptions. If I delete it or create a new file, and start typing same "import" it will show me several exceptions:
1) View provider com.intellij.psi.SingleRootFileViewProvider@130124d4 refused to parse text with Language: TEXT; base: Language: antlr; copy: Language: antlr; fileType: org.dubik.intelliantlr.AntlrFileType@1cb53eb8
2) commitDocument left PSI inconsistent: PsiFile(plain text):gram.g
I know that if I create ParserDefinition at least first exception goes away, but ParserDefinition requires quite a lot of code, I would prefer to debug and finish lexer first. Is there a way to make just highlighting working?
Thanks.
:sergiy
Hello, Sergiy Dubovik.
For simple highlighting purposes I use SyntaxHighlighterFactory.LANGUAGE_FACTORY.addExplicitExtension method.
As a parameters It excepts Language instance for what you want to do syntax highlighting and com.intellij.openapi.fileTypes.SyntaxHighlighterFactory implementation.
For simple purposes It is enough.
I hope it will be helpful for you.
My problem is not registration of a highlighter. I do it through plugin.xml which I believe same as you wrote. However it seems that I'm doing something wrong and get a lot of exceptions.
Some times ago I needed only syntax highlighting and found pretty small plugin with such kind of functionality.
Try to look at code -- http://code.google.com/p/idea-assemblysupport/
Thanks, that looked nice. However it uses different way to split input stream into tokens. It doesn't use flex. I still don't get what is wrong with my code. Found few other plugins. It looks quite straightforward after all. I get a lot of:
[ 28756] ERROR - pplication.impl.LaterInvocator - PSI/document inconsistency before reparse: file=PsiFile(plain text):grammar.g
java.lang.AssertionError: PSI/document inconsistency before reparse: file=PsiFile(plain text):grammar.g
and don't understand why they keep coming. Also this:
[ 27945] ERROR - si.impl.PsiDocumentManagerImpl - PSI is broken beyond repair in: PsiFile(plain text):grammar.g
java.lang.Throwable
at com.intellij.openapi.diagnostic.Logger.error(Logger.java:52)
at com.intellij.psi.impl.PsiDocumentManagerImpl.a(PsiDocumentManagerImpl.java:504)
at com.intellij.psi.impl.PsiDocumentManagerImpl.d(PsiDocumentManagerImpl.java:468)
at com.intellij.psi.impl.PsiDocumentManagerImpl.access$300(PsiDocumentManagerImpl.java:67)
at com.intellij.psi.impl.PsiDocumentManagerImpl$2.run(PsiDocumentManagerImpl.java:277)
Hello Sergiy,
CoffeeBrew is an example of a plugin that implements only syntax highlighting
with no parser:
https://github.com/netzpirat/coffee-brew/
See the org.coffeebrew.file package in particular.
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
You could also checkout mine
https://github.com/codingbox/idea-parser3
Thanks for help, I managed to move forward.
Hi Sergiy, how did you solve this problem? I've spend last day with the same exceptions and can't solve it. Thanks for help
(My plugin is on GitHub: https://github.com/juzna/intellij-neon)
I don't remember exactly, it was a year ago. Try to start parsing something, I don't think I did something special, at least from git log can't see anything. You seem to have all required pieces so you are quite close. I can give you my sources if you want.
:s
I took the dummy parser from CoffeeBew plugin as recomended here, but it still does the same. Pls, send me your code to my email (should be in my profile), and I'll play with that. Thanks
Actually, I've just found the problem. In my NeonLanguage class I registered the language as Neon, however in config as neon (notice the case). After changing it all to lowercase, it works fine now. And it also solved some other issues I had.