Proper registration of Syntax coloring components for custom language plugins.
Hi,
A friend of mine and I have been trying to develop a custom language plugin for OpenGL Shading Language (GLSL).
This plugin started out as a 7.0 plugin but we have now moved over to 8.0.
I see that a lot of stuff has been moved from the Language class to the plugin.xml file instead.
The question is; is it possible to register all classes necessary for syntax highlighting in the xml file or is some "manual" registration still required in the code?
Our current extensions in the xml file are currently:
<fileTypeFactory implementation="glslplugin.GLSLSupportLoader" />
<colorSettingsPage implementation="glslplugin.GLSLColorAndFontsPage" />
<syntaxHighlighter key="GLSL" factoryClass="glslplugin.GLSLHighlighterFactory" />
I added the <syntaxHighlighter ...> in the xml file to register the glsl syntax highlighter but using the debugger it becomes apparent the the GLSLFactory is never instantiated. The syntax highlighting is still working in the color settings page though.
Furthermore what does the key attribute refer to and which class is GLSLFactory supposed to be a subclass of? Looking at the source code for the JS plugin its SyntaxHighlighterProvider, but if it's never instantiated, what use is it?
For now we have a explicit registration of the syntax highlighter in the GLSLLanguage constructor and it seems to work.
What are the minimum set of components needed for syntax coloring and how are they registered with IDEA (preferably using the xml file)?
Thanks in advance,
best regards,
Yngve D Hammersland
Please sign in to leave a comment.
Hello Yngve,
The correct registration is:
<lang.syntaxHighlighterFactory key="GLSL" implementationClass="GLSLHighlighterFactory"/>
where the key matches the name of the file type (rather than language), and
GLSLHighlighterFactory extends SyntaxHighlighterFactory.
All language components can be registered in plugin.xml - there's no need
to do manual registration from code.
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
Hi
As far as i understand, "key" attribute for syntaxHighlighter extension should be equal to your language name (what you pass to Language constructor in your Language implementation).
Also, here http://svn.jetbrains.org/idea/BRANCHES/DianaFinal/bundled/groovy/src/META-INF/plugin.xml and in my plugin i use "implementationClass" attribute to point to implementation and not "factoryClass", and that works for me.
Try looking at groovy plugin sources:
http://svn.jetbrains.org/idea/BRANCHES/DianaFinal/bundled/groovy/src/META-INF/plugin.xml
http://svn.jetbrains.org/idea/BRANCHES/DianaFinal/bundled/groovy/src/org/jetbrains/plugins/groovy/highlighter/GroovySyntaxHighlighter.java
http://svn.jetbrains.org/idea/BRANCHES/DianaFinal/bundled/groovy/src/org/jetbrains/plugins/groovy/GroovyLanguage.java
best,
jay
Hi,
I tried the implementationClass attribute and pointing it directly at the GLSLSyntaxHighlighter class but still no luck.
(It still doesn't instantiate the highlighter at all)
My xml which I try to keep at a minimum is currently:
The fileTypeFactory is working as I get the correct icons on the file and the color settings page is working. The grammar also works when I add it to the xml.
My GLSLLanguage class (I commented out the registration of the highlighter to try to make it work with xml only):
and my GLSLHighlighter class:
Any ideas?
regards,
Yngve
Great! Thanks, now it works.
I'm qurious on one more thing though. Why doesn't the lang.syntaxHighlighterFactory have a "lang" attribute like the other extension points? I would be great to have that kind of consistency.
regards,
- Yngve D. Hammersland
Hello Yngve,
Because the syntax highlighters are registered per file type and not per
language (for example, it's possible to register a syntax highlighter for
a file type hich doesn't have an associated language - for example, IDEA
custom file types use this possibility).
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"