How to activate a plugin for Groovy files?

I use the Copy as HTML plugin for Java files.
http://plugins.intellij.net/plugin/?id=190

I would really like to use the plugin for Groovy files as well. Can it possibly be that hard to activate this for Groovy files?

I looked as the source code included with the .zip download, and I don't see any code that activates this for any file types.

Does anyone have an idea what I can look for in the code or what I can change to activate the plugin for groovy? Is it that hard to do this?

5 comments
Comment actions Permalink

I had a request for that before, but was so busy with other projects that I forgot about it.
Will check now. IIRC that was somehow configured with the plugin meta data descriptor.

On 23.05.2011 12:47, Hamlet D'Arcy wrote:

I use the Copy as HTML plugin for Java files.
http://plugins.intellij.net/plugin/?id=190

>

I would really like to use the plugin for Groovy files as well. Can it possibly be that hard to activate this for Groovy files?

>

I looked as the source code included with the .zip download, and I don't see any code that activates this for any file types.

>

Does anyone have an idea what I can look for in the code or what I can change to activate the plugin for groovy? Is it that hard to do this?

>

---
Original message URL: http://devnet.jetbrains.net/message/5303913#5303913


0
Comment actions Permalink

Sorry, I found the problem, but have no solution :(

For every other language that I tested (JavaScript, Ruby, PHP) a call to "SyntaxHighlighterFactory.getSyntaxHighlighter(language, project, virtualFile)"
returns a language specific syntax highlighter.
For a groovy file call "language" is an instance of GroovyLanguage and "virtualFile" is a file with ".groovy" extension. However all that is returned is a PlainSyntaxHighlighter -
even though in the class hierarchy I see a GroovySyntaxHighlighter.

I tried adding
  
to plugin.xml but that did not change anything.

Anybody?

0
Comment actions Permalink

There are two ways of managing syntax highlighting in IDEA. You mentioned one, but Groovy (and a bunch of other languages) uses another: they override com.intellij.openapi.fileTypes.LanguageFileType#getEditorHighlighter, a lower-level API. You could support this API as well.

0
Comment actions Permalink

Thanks for the answer!

I wonder why there is a class GroovySyntaxHighlighter that implements the SyntaxHighlighter interface that I use?
Currently I get a lexer from the syntaxhighlighter then iterate that.

Anyway: Now as you suggested I tried instead to do this
    EditorHighlighter editorHighlighter = languageFileType.getEditorHighlighter(project, virtualFile, colorsScheme);
    HighlighterIterator editorHighlighterIterator = editorHighlighter.createIterator(0);
However the editorHighlighterIterator is always atEnd() :( (Regardless of whether I call advance() before the check or after it, no javadoc to be seen.)
What am I doing wrong?

Can I use the HighlighterIterator like I intend (iterating over all tokens and getting their TextAttributes.)
Or will I just get highlighted tokens?


On 24.05.2011 16:18, Peter Gromov wrote:

There are two ways of managing syntax highlighting in IDEA. You mentioned one, but Groovy (and a bunch of other languages) uses another: they override com.intellij.openapi.fileTypes.LanguageFileType#getEditorHighlighter, a lower-level API. You could support this API as well.

>

---
Original message URL: http://devnet.jetbrains.net/message/5304128#5304128


0
Comment actions Permalink

EditorHighlighter is a thing actually used during highlighting. Its most popular implementation just uses SyntaxHighlighter to highlight tokens. But for more complex cases (as in Groovy) we have to implement EditorHighlighter by ourselves. So if you use EditorHighlighter directly, you'll get wider language coverage.

The API is a bit crazy: atEnd means both "before start" and "after end". But advance/retreat should really work, unless the text is empty. And for this to be true, you have to call EditorHighlighter.setText before everything else (I'm not sure about other setters). Sorry for the inconvenience.

0

Please sign in to leave a comment.