Newbie language plugin question

Hi all,

I'm trying my hand at developing a language plugin for IDEA. I currently have implemented the basics (LanguageFileType, Language, and the Lexer). I wanted to try the lexer, so my Language returns a SyntaxHighlighter which uses the lexer and has TextAttributes for all the token types. When I start the plugin, I get lots of the exception below in the logs, and no highlighting. The obvious bit I haven't implemented is the parser - is this required for a first step? I'd hoped to test the lexer with just the highlighting.

Thanks for any help,

java.lang.IllegalStateException: no segments avaliable
at com.intellij.openapi.editor.ex.util.SegmentArray.findSegmentIndex(
at com.intellij.openapi.editor.ex.util.LexerEditorHighlighter$HighlighterIteratorImpl.( at com.intellij.openapi.editor.ex.util.LexerEditorHighlighter.createIterator( at com.intellij.openapi.editor.impl.IterationState.]]>(
at com.intellij.openapi.editor.impl.EditorImpl.xyToVisualPosition(
at com.intellij.openapi.editor.impl.EditorImpl.xyToLogicalPosition(
at com.intellij.openapi.editor.impl.EditorGutterComponentImpl.b(
at com.intellij.openapi.editor.impl.EditorGutterComponentImpl.c(
at com.intellij.openapi.editor.impl.EditorGutterComponentImpl.paint(
at javax.swing.JComponent._paintImmediately(
at javax.swing.JComponent.paintImmediately(
at javax.swing.RepaintManager.paintDirtyRegions(
at javax.swing.SystemEventQueueUtilities$
at java.awt.event.InvocationEvent.dispatch(
at java.awt.EventQueue.dispatchEvent(
at com.intellij.ide.IdeEventQueue.b(
at com.intellij.ide.IdeEventQueue.a(
at com.intellij.ide.IdeEventQueue.dispatchEvent(
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(
at java.awt.EventDispatchThread.pumpEventsForHierarchy(
at java.awt.EventDispatchThread.pumpEvents(
at java.awt.EventDispatchThread.pumpEvents(
ERROR - com.intellij.ide.IdeEventQueue - Error during dispatching of java.awt.event.InvocationEvent[INVOCATION_DEFAULT,runnable=javax.swing.SystemEventQueueUtilities$ComponentWorkRequest@f215a7,notifier=null,catchExceptions=false,when=1176070621305] on apple.awt.CToolkit@865c1d


What lexer do you have? Is it flex-generated? If so do you use FlexAdapter over it?

Do you return null from Language.getParserDefinition() ?


No, the lexer is hand-written. I currently don't have Language.getParserDefinition overridden, so the base method is called, which returns null.


Hi, I got this fixed, thanks. I had a couple of problems, the main one was not calling advance() in the start() methods.



Hey Colin,

I'm trying to create a custom language plugin as well. Could you post the code you have that's working? Thanks

-- bryan


Please sign in to leave a comment.