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,
Colin

java.lang.IllegalStateException: no segments avaliable
at com.intellij.openapi.editor.ex.util.SegmentArray.findSegmentIndex(SegmentArray.java:59)
at com.intellij.openapi.editor.ex.util.LexerEditorHighlighter$HighlighterIteratorImpl.(LexerEditorHighlighter.java:7) at com.intellij.openapi.editor.ex.util.LexerEditorHighlighter.createIterator(LexerEditorHighlighter.java:58) at com.intellij.openapi.editor.impl.IterationState.]]>(IterationState.java:70)
at com.intellij.openapi.editor.impl.EditorImpl.xyToVisualPosition(EditorImpl.java:949)
at com.intellij.openapi.editor.impl.EditorImpl.xyToLogicalPosition(EditorImpl.java:957)
at com.intellij.openapi.editor.impl.EditorGutterComponentImpl.b(EditorGutterComponentImpl.java:47)
at com.intellij.openapi.editor.impl.EditorGutterComponentImpl.c(EditorGutterComponentImpl.java:245)
at com.intellij.openapi.editor.impl.EditorGutterComponentImpl.paint(EditorGutterComponentImpl.java:106)
at javax.swing.JComponent._paintImmediately(JComponent.java:4881)
at javax.swing.JComponent.paintImmediately(JComponent.java:4667)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:477)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:114)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at com.intellij.ide.IdeEventQueue.b(IdeEventQueue.java:126)
at com.intellij.ide.IdeEventQueue.a(IdeEventQueue.java:153)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:124)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
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

4 comments

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

Do you return null from Language.getParserDefinition() ?

0

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

0

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

Cheers,
Colin

0

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

0

Please sign in to leave a comment.