antlr / intellij-plugin-v4 Goto Github PK
View Code? Open in Web Editor NEWAn IntelliJ plugin for ANTLR v4
Home Page: https://plugins.jetbrains.com/plugin/7358-antlr-v4
License: BSD 3-Clause "New" or "Revised" License
An IntelliJ plugin for ANTLR v4
Home Page: https://plugins.jetbrains.com/plugin/7358-antlr-v4
License: BSD 3-Clause "New" or "Revised" License
As we test rules within the preview input window, we could record good input to parse tree matches with a button that then remembered the information and could later generate a jUnit test file or something.
This error occurs if you have an options
block containing an invalid target
. For example:
grammar Foo;
options {
target = J;
}
Stack trace:
null
java.lang.NullPointerException
at org.antlr.v4.codegen.CodeGenerator.getTemplates(CodeGenerator.java:91)
at org.antlr.v4.automata.LexerATNFactory.<init>(LexerATNFactory.java:114)
at org.antlr.v4.Tool.processNonCombinedGrammar(Tool.java:403)
at org.antlr.v4.Tool.process(Tool.java:376)
at org.antlr.intellij.plugin.ANTLRv4ExternalAnnotator.doAnnotate(ANTLRv4ExternalAnnotator.java:105)
at org.antlr.intellij.plugin.ANTLRv4ExternalAnnotator.doAnnotate(ANTLRv4ExternalAnnotator.java:38)
at com.intellij.codeInsight.daemon.impl.ExternalToolPass.doAnnotate(ExternalToolPass.java:224)
at com.intellij.codeInsight.daemon.impl.ExternalToolPass.access$400(ExternalToolPass.java:43)
at com.intellij.codeInsight.daemon.impl.ExternalToolPass$2.run(ExternalToolPass.java:135)
at com.intellij.codeInsight.daemon.impl.ExternalToolPass$3.run(ExternalToolPass.java:172)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310)
at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227)
at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217)
at com.intellij.util.Alarm$Request$1.run(Alarm.java:289)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at com.intellij.util.concurrency.QueueProcessor$RunnableConsumer.consume(QueueProcessor.java:271)
at com.intellij.util.concurrency.QueueProcessor$RunnableConsumer.consume(QueueProcessor.java:268)
at com.intellij.util.concurrency.QueueProcessor$2$1.run(QueueProcessor.java:103)
at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:231)
at com.intellij.util.concurrency.QueueProcessor$2.consume(QueueProcessor.java:100)
at com.intellij.util.concurrency.QueueProcessor$2.consume(QueueProcessor.java:97)
at com.intellij.util.concurrency.QueueProcessor$3$1.run(QueueProcessor.java:208)
at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:231)
at com.intellij.util.concurrency.QueueProcessor$3.run(QueueProcessor.java:205)
at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:454)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
at com.intellij.openapi.application.impl.ApplicationImpl$1$1.run(ApplicationImpl.java:152)
At moment, must hit save button.
update failed for AnAction with ID=antlr.TestRule
java.lang.NullPointerException
at org.antlr.intellij.plugin.actions.TestRuleAction.update(TestRuleAction.java:42)
at com.intellij.openapi.actionSystem.ex.ActionUtil.performDumbAwareUpdate(ActionUtil.java:111)
at com.intellij.openapi.actionSystem.impl.Utils.a(Utils.java:167)
at com.intellij.openapi.actionSystem.impl.Utils.expandActionGroup(Utils.java:126)
at com.intellij.openapi.actionSystem.impl.Utils.expandActionGroup(Utils.java:85)
at com.intellij.openapi.actionSystem.impl.Utils.fillMenu(Utils.java:241)
at com.intellij.openapi.actionSystem.impl.ActionPopupMenuImpl$MyMenu.show(ActionPopupMenuImpl.java:96)
at com.intellij.openapi.fileEditor.impl.text.TextEditorComponent$MyEditorMouseListener.invokePopup(TextEditorComponent.java:294)
at com.intellij.util.EditorPopupHandler.a(EditorPopupHandler.java:27)
at com.intellij.util.EditorPopupHandler.mousePressed(EditorPopupHandler.java:37)
at com.intellij.openapi.editor.impl.EditorImpl$MyMouseAdapter.a(EditorImpl.java:5290)
at com.intellij.openapi.editor.impl.EditorImpl$MyMouseAdapter.mousePressed(EditorImpl.java:5250)
at java.awt.Component.processMouseEvent(Component.java:6411)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3275)
at java.awt.Component.processEvent(Component.java:6179)
at java.awt.Container.processEvent(Container.java:2084)
at java.awt.Component.dispatchEventImpl(Component.java:4776)
at java.awt.Container.dispatchEventImpl(Container.java:2142)
at java.awt.Component.dispatchEvent(Component.java:4604)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4618)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4276)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4209)
at java.awt.Container.dispatchEventImpl(Container.java:2128)
at java.awt.Window.dispatchEventImpl(Window.java:2492)
at java.awt.Component.dispatchEvent(Component.java:4604)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:717)
at java.awt.EventQueue.access$400(EventQueue.java:82)
at java.awt.EventQueue$2.run(EventQueue.java:676)
at java.awt.EventQueue$2.run(EventQueue.java:674)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:86)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:690)
at java.awt.EventQueue$3.run(EventQueue.java:688)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:86)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:687)
at com.intellij.ide.IdeEventQueue.d(IdeEventQueue.java:700)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:521)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:348)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Some of my students (on Windows) don't have the "ANTLR Tool Output" view, although they do have plugin version 1.1 and IntelliJ 13.1.1. Corresponding entry in View => Tool Windows menu is also missing.
I haven't been able to reproduce this in my computer.
Using this grammar from the Definitive ANTLR 4 Reference:
grammar Expr;
@Header {
package org.gleason.antlr.Expr;
}
// parser rules
prog: stat+ ;
stat: expr NEWLINE
| ID '=' expr NEWLINE
| NEWLINE
;
expr: expr ('*'|'/') expr
| expr ('+'|'-') expr
| INT
| ID
| '(' expr ')'
;
// lexer rules
ID : [a-zA-Z]+ ;
INT : [0-9]+ ;
NEWLINE : '\r' ? '\n' ;
WS : [ \t]+ -> skip ;
The generated files resulted in these errors when attempting to compile:
ExprParser.java:41: error: method does not override or implement a method from a supertype @Override ^ ExprParser.java:321: error: cannot find symbol new ATNDeserializer().deserialize(_serializedATN.toCharArray()); ^ symbol: class ATNDeserializer location: class ExprParser ExprParser.java:201: error: method enterRecursionRule in class Parser cannot be applied to given types; enterRecursionRule(_localctx, 4, RULE_expr, _p); ^ required: ParserRuleContext,int found: ExprContext,int,int,int reason: actual and formal argument lists differ in length ExprParser.java:245: error: cannot find symbol if (!(precpred(_ctx, 5))) throw new FailedPredicateException(this, "precpred(_ctx, 5)"); ^ symbol: method precpred(ParserRuleContext,int) location: class ExprParser ExprParser.java:261: error: cannot find symbol if (!(precpred(_ctx, 4))) throw new FailedPredicateException(this, "precpred(_ctx, 4)"); ^ symbol: method precpred(ParserRuleContext,int) location: class ExprParser ExprParser.java:299: error: cannot find symbol case 0: return precpred(_ctx, 5); ^ symbol: method precpred(ParserRuleContext,int) location: class ExprParser ExprParser.java:301: error: cannot find symbol case 1: return precpred(_ctx, 4); ^ symbol: method precpred(ParserRuleContext,int) location: class ExprParser ExprLexer.java:79: error: cannot find symbol new ATNDeserializer().deserialize(_serializedATN.toCharArray()); ^ symbol: class ATNDeserializer location: class ExprLexer ExprLexer.java:51: error: method does not override or implement a method from a supertype @Override ^ 9 errors
Going through the compilation process from start to finish by generating the code with with the normal ANTLR4 tool and then compiling with javac
works just fine.... no errors. I am not sure why it wouldn't work with IntelliJ; I have made sure ANTLR4 jar file is added as a library for the project....
2014-04-21 07:22:55,383 [45846214] INFO - ANTLR PreviewPanel - switchToGrammar /Volumes/SSD2/Users/parrt/IdeaProjects/testplugin/T.g4
2014-04-21 07:23:01,195 [45852026] INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $PROJECT_CONFIG_DIR$/ant.xml file is null
2014-04-21 07:23:04,185 [45855016] INFO - ANTLR ANTLRv4PluginController - currentEditorFileChangedEvent /Volumes/SSD2/Users/parrt/IdeaProjects/testplugin/T.g4 -> /Volumes/SSD2/Users/parrt/IdeaProjects/testplugin/Catalog.g4
2014-04-21 07:23:04,191 [45855022] ERROR - .impl.MessageBusConnectionImpl - null
java.lang.NullPointerException
at org.antlr.v4.Tool.createGrammar(Tool.java:553)
at org.antlr.v4.Tool.loadGrammar(Tool.java:585)
at org.antlr.intellij.plugin.ANTLRv4PluginController.loadGrammars(ANTLRv4PluginController.java:328)
at org.antlr.intellij.plugin.ANTLRv4PluginController.updateGrammarObjectsFromFile(ANTLRv4PluginController.java:258)
at org.antlr.intellij.plugin.ANTLRv4PluginController.currentEditorFileChangedEvent(ANTLRv4PluginController.java:229)
at org.antlr.intellij.plugin.ANTLRv4PluginController$2.selectionChanged(ANTLRv4PluginController.java:177)
at sun.reflect.GeneratedMethodAccessor25.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.intellij.util.messages.impl.MessageBusConnectionImpl.deliverMessage(MessageBusConnectionImpl.java:114)
at com.intellij.util.messages.impl.MessageBusImpl.doPumpMessages(MessageBusImpl.java:228)
at com.intellij.util.messages.impl.MessageBusImpl.doPumpMessages(MessageBusImpl.java:234)
at com.intellij.util.messages.impl.MessageBusImpl.pumpMessages(MessageBusImpl.java:219)
at com.intellij.util.messages.impl.MessageBusImpl.pumpMessages(MessageBusImpl.java:216)
at com.intellij.util.messages.impl.MessageBusImpl.sendMessage(MessageBusImpl.java:209)
at com.intellij.util.messages.impl.MessageBusImpl.access$000(MessageBusImpl.java:43)
at com.intellij.util.messages.impl.MessageBusImpl$1.invoke(MessageBusImpl.java:131)
at com.sun.proxy.$Proxy73.selectionChanged(Unknown Source)
at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl$16.run(FileEditorManagerImpl.java:1514)
at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl$13$1.run(FileEditorManagerImpl.java:960)
at com.intellij.openapi.wm.impl.FocusManagerImpl.flushRequest(FocusManagerImpl.java:638)
at com.intellij.openapi.wm.impl.FocusManagerImpl.access$2600(FocusManagerImpl.java:59)
at com.intellij.openapi.wm.impl.FocusManagerImpl$7.run(FocusManagerImpl.java:475)
at com.intellij.util.ui.UIUtil.invokeLaterIfNeeded(UIUtil.java:1999)
at com.intellij.openapi.wm.impl.FocusManagerImpl.doWhenFocusSettlesDown(FocusManagerImpl.java:466)
at com.intellij.openapi.wm.impl.FocusManagerImpl.doWhenFocusSettlesDown(FocusManagerImpl.java:461)
at com.intellij.openapi.wm.impl.IdeFocusManagerImpl.doWhenFocusSettlesDown(IdeFocusManagerImpl.java:64)
at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl$13.run(FileEditorManagerImpl.java:957)
at com.intellij.openapi.util.BusyObject$Impl$Simple.execute(BusyObject.java:122)
at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.notifyPublisher(FileEditorManagerImpl.java:953)
at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.fireSelectionChanged(FileEditorManagerImpl.java:1511)
at com.intellij.openapi.fileEditor.impl.EditorsSplitters$4.run(EditorsSplitters.java:717)
at com.intellij.openapi.fileEditor.impl.EditorsSplitters.setCurrentWindow(EditorsSplitters.java:728)
at com.intellij.openapi.fileEditor.impl.EditorWindow.setEditor(EditorWindow.java:680)
at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.openFileImpl4(FileEditorManagerImpl.java:828)
at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.openFileImpl3(FileEditorManagerImpl.java:740)
at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl$8.run(FileEditorManagerImpl.java:720)
at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:117)
at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:99)
at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:85)
at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.openFileImpl2(FileEditorManagerImpl.java:717)
at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.openFileWithProviders(FileEditorManagerImpl.java:654)
at com.intellij.openapi.fileEditor.ex.FileEditorManagerEx.openFile(FileEditorManagerEx.java:139)
at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl$14.run(FileEditorManagerImpl.java:1048)
at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:124)
at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:99)
at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:85)
at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.openEditor(FileEditorManagerImpl.java:1044)
at com.intellij.ide.util.EditorHelper.openInEditor(EditorHelper.java:56)
at com.intellij.ide.projectView.impl.ProjectViewImpl$MyIdeView.selectElement(ProjectViewImpl.java:1264)
at com.intellij.ide.actions.CreateElementActionBase.actionPerformed(CreateElementActionBase.java:80)
at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:162)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter$1.run(ActionMenuItem.java:261)
at com.intellij.openapi.wm.impl.FocusManagerImpl.runOnOwnContext(FocusManagerImpl.java:916)
at com.intellij.openapi.wm.impl.IdeFocusManagerImpl.runOnOwnContext(IdeFocusManagerImpl.java:124)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.actionPerformed(ActionMenuItem.java:231)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem.fireActionPerformed(ActionMenuItem.java:104)
at com.intellij.ui.plaf.beg.BegMenuItemUI.doClick(BegMenuItemUI.java:512)
at com.intellij.ui.plaf.beg.BegMenuItemUI.access$300(BegMenuItemUI.java:44)
at com.intellij.ui.plaf.beg.BegMenuItemUI$MyMouseInputHandler.mouseReleased(BegMenuItemUI.java:532)
at java.awt.Component.processMouseEvent(Component.java:6505)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
at java.awt.Component.processEvent(Component.java:6270)
at java.awt.Container.processEvent(Container.java:2229)
at java.awt.Component.dispatchEventImpl(Component.java:4861)
at java.awt.Container.dispatchEventImpl(Container.java:2287)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
at java.awt.Container.dispatchEventImpl(Container.java:2273)
at java.awt.Window.dispatchEventImpl(Window.java:2719)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:729)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:688)
at java.awt.EventQueue$3.run(EventQueue.java:686)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:702)
at java.awt.EventQueue$4.run(EventQueue.java:700)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:699)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:697)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:520)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:335)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
2014-04-21 07:23:04,193 [45855024] ERROR - .impl.MessageBusConnectionImpl - IntelliJ IDEA 13.0.2 Build #IC-133.SNAPSHOT
2014-04-21 07:23:04,193 [45855024] ERROR - .impl.MessageBusConnectionImpl - JDK: 1.7.0_21
2014-04-21 07:23:04,193 [45855024] ERROR - .impl.MessageBusConnectionImpl - VM: Java HotSpot(TM) 64-Bit Server VM
2014-04-21 07:23:04,193 [45855024] ERROR - .impl.MessageBusConnectionImpl - Vendor: Oracle Corporation
2014-04-21 07:23:04,194 [45855025] ERROR - .impl.MessageBusConnectionImpl - OS: Mac OS X
2014-04-21 07:23:04,194 [45855025] ERROR - .impl.MessageBusConnectionImpl - Last Action: NewFile
2014-04-21 07:23:04,194 [45855025] ERROR - .impl.MessageBusConnectionImpl - Current Command:
Currently, you have to save the grammar before the parse tree updates.
Intellij IDEA v13.1
Mac OS X 10.9.2
Java 1.6/1.7/1.8
Tried the sample grammar Hello, :
grammar Hello;
r : 'hello' ID ;
ID : [a-z]+ ;
WS : [ \r\t\n]+ -> skip ;
null
java.lang.NullPointerException
at org.antlr.v4.runtime.tree.gui.TreeViewer.getScaledTreeSize(TreeViewer.java:509)
at org.antlr.v4.runtime.tree.gui.TreeViewer.updatePreferredSize(TreeViewer.java:170)
at org.antlr.v4.runtime.tree.gui.TreeViewer.setScale(TreeViewer.java:699)
at org.antlr.intellij.plugin.preview.ParseTreePanel$1.stateChanged(ParseTreePanel.java:59)
at javax.swing.JSlider.fireStateChanged(JSlider.java:420)
at javax.swing.JSlider$ModelListener.stateChanged(JSlider.java:337)
at javax.swing.DefaultBoundedRangeModel.fireStateChanged(DefaultBoundedRangeModel.java:348)
at javax.swing.DefaultBoundedRangeModel.setRangeProperties(DefaultBoundedRangeModel.java:285)
at javax.swing.DefaultBoundedRangeModel.setValueIsAdjusting(DefaultBoundedRangeModel.java:214)
at javax.swing.JSlider.setValueIsAdjusting(JSlider.java:642)
at com.apple.laf.AquaSliderUI$TrackListener.mouseDragged(AquaSliderUI.java:405)
at java.awt.Component.processMouseMotionEvent(Component.java:6462)
at javax.swing.JComponent.processMouseMotionEvent(JComponent.java:3293)
at java.awt.Component.processEvent(Component.java:6183)
at java.awt.Container.processEvent(Container.java:2084)
at java.awt.Component.dispatchEventImpl(Component.java:4776)
at java.awt.Container.dispatchEventImpl(Container.java:2142)
at java.awt.Component.dispatchEvent(Component.java:4604)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4618)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4296)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4209)
at java.awt.Container.dispatchEventImpl(Container.java:2128)
at java.awt.Window.dispatchEventImpl(Window.java:2492)
at java.awt.Component.dispatchEvent(Component.java:4604)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:717)
at java.awt.EventQueue.access$400(EventQueue.java:82)
at java.awt.EventQueue$2.run(EventQueue.java:676)
at java.awt.EventQueue$2.run(EventQueue.java:674)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:86)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:690)
at java.awt.EventQueue$3.run(EventQueue.java:688)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:86)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:687)
at com.intellij.ide.IdeEventQueue.e(IdeEventQueue.java:697)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:520)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:335)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Syntax highlighting is broken when one of the following appears in the grammar:
DOC_COMMENT
BLOCK_COMMENT
DOUBLE_QUOTE_STRING_LITERAL
STRING_LITERAL
STRING_LITERAL
containing an invalid escape sequence, e.g. \a
Keeps throwing this exception:
Serialized ATN data element out of range.: Serialized ATN data element out of range.
java.lang.UnsupportedOperationException: Serialized ATN data element out of range.
at org.antlr.v4.runtime.atn.ATNSerializer.serialize(ATNSerializer.java:364)
at org.antlr.v4.runtime.atn.ATNSerializer.getSerialized(ATNSerializer.java:541)
at org.antlr.v4.runtime.atn.ATNSerializer.getSerializedAsChars(ATNSerializer.java:545)
at org.antlr.v4.tool.Grammar.createLexerInterpreter(Grammar.java:896)
at org.antlr.v4.tool.Grammar.createLexerInterpreter(Grammar.java:893)
at org.antlr.intellij.plugin.ANTLRv4ProjectComponent.parseText(ANTLRv4ProjectComponent.java:142)
at org.antlr.intellij.plugin.preview.ParseTreePanel$3.run(ParseTreePanel.java:129)
at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:343)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:715)
at java.awt.EventQueue.access$400(EventQueue.java:82)
at java.awt.EventQueue$2.run(EventQueue.java:676)
at java.awt.EventQueue$2.run(EventQueue.java:674)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:86)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:685)
at com.intellij.ide.IdeEventQueue.d(IdeEventQueue.java:700)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:525)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:348)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
I had field=ID in a rule and field was a rulename; the conflict was not reported anywhere by the plugin during generation or otherwise.
Should send event messages to the log.
I have an ANTLR grammar file located in my src
directory, along with a Java source file for the main program. When using the Tools > Generate ANTLR recognizer, the correct java files are generated but placed in a separate gen
directory. However, after building the project, only .class
files are generated for files listed in the src
directory.
It is not obvious how to integrate ANTLR files in the build -- it seems I have to rely on the command line tool to generate .g4
files in the src directory, and then compile. However, this definitely doesn't seem like the correct way to go about this.
Is there a correct solution to the above problem?
maybe allow right click on input file to say test?
(possible duplicate of #87)
Lishinko: I also encounted this problem. I am using windows xp , IntelliJ 13.1.1. plugin version 1.1 In this๏ผlishinko/cppStructParser@955dd3f right click on "struct.g4"->"generate antlr recognizer" and intellij will report the exception in "Event Log" window
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
grammar struct;
import cppLexerRules;
//structDefine : STRUCT structBody ; //struct็ฑstructๅ
ณ้ฎๅญๅ็ปๆไฝๅ
ๅฎน็ปๆ
//structBody : name=INDENTIFIER '{' field+ '}' ';'; //็ปๆไฝๅ
ๅฎนๆฏไธ็ณปๅ็ๅญๆฎต
structDefine : 'struct' name=INDENTIFIER leftCurlyBrace='{' structField rightCurlyBrace='}' ';';
structField : (fieldDecl | structDefine)+;//structๅ
้จๅฏไปฅๆฏๅญๆฎตๅฃฐๆๆ่
ๅ
ๅต็structๅฎไน
fieldDecl : fieldType INDENTIFIER ';' ;//ๅญๆฎตๅฃฐๆ๏ผ็ฑปๅ ๅญๆฎตๅ็งฐ ๅๅท
fieldType : normalType | nameInNamespace | genericCollType ;
//ๆจกๆฟ็ฑปๅ๏ผstd::vector<int>่ฟๆ ท็๏ผstd::ๅฏไปฅๅปๆ๏ผ
genericCollType : 'std::'? COLLTYPE '<' elementType '>'
;
nameInNamespace : 'std::'? INDENTIFIER ;
elementType : fieldType | mapType;
normalType : KEYWORD | INDENTIFIER ;
mapType : normalType ',' normalType ;
COLLTYPE : MAP | VECTOR //็ฎๅๆฏๆstd::mapๅstd::vector
;
Cache mechanism is the issue.
null
java.lang.NullPointerException
at org.antlr.intellij.plugin.psi.RuleSpecNode.getName(RuleSpecNode.java:23)
at com.intellij.psi.impl.search.CachesBasedRefSearcher.processQuery(CachesBasedRefSearcher.java:37)
at com.intellij.psi.impl.search.CachesBasedRefSearcher.processQuery(CachesBasedRefSearcher.java:20)
at com.intellij.openapi.application.QueryExecutorBase$2.run(QueryExecutorBase.java:44)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:931)
at com.intellij.openapi.application.QueryExecutorBase.execute(QueryExecutorBase.java:42)
at com.intellij.util.ExecutorsQuery.processResults(ExecutorsQuery.java:43)
at com.intellij.util.AbstractQuery.forEach(AbstractQuery.java:77)
at com.intellij.util.MergeQuery.processSubQuery(MergeQuery.java:83)
at com.intellij.util.MergeQuery.forEach(MergeQuery.java:56)
at com.intellij.util.UniqueResultsQuery.process(UniqueResultsQuery.java:66)
at com.intellij.util.UniqueResultsQuery.forEach(UniqueResultsQuery.java:56)
at com.intellij.util.UniqueResultsQuery.findAll(UniqueResultsQuery.java:85)
at com.intellij.find.findUsages.FindUsagesHandler.findReferencesToHighlight(FindUsagesHandler.java:206)
at com.intellij.codeInsight.daemon.impl.IdentifierHighlighterPass.highlightTargetUsages(IdentifierHighlighterPass.java:133)
at com.intellij.codeInsight.daemon.impl.IdentifierHighlighterPass.doCollectInformation(IdentifierHighlighterPass.java:110)
at com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:62)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass$1$1.run(PassExecutorService.java:357)
at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1184)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass$1.run(PassExecutorService.java:348)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:226)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.doRun(PassExecutorService.java:345)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.run(PassExecutorService.java:321)
at com.intellij.concurrency.JobLauncherImpl$3.call(JobLauncherImpl.java:145)
at com.intellij.concurrency.JobLauncherImpl$3.call(JobLauncherImpl.java:142)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at com.intellij.concurrency.PrioritizedFutureTask.access$101(PrioritizedFutureTask.java:31)
at com.intellij.concurrency.PrioritizedFutureTask$1.run(PrioritizedFutureTask.java:70)
at com.intellij.concurrency.PrioritizedFutureTask.run(PrioritizedFutureTask.java:113)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
java.lang.NullPointerException
at org.antlr.intellij.plugin.psi.RuleSpecNode.getName(RuleSpecNode.java:23)
at com.intellij.codeInsight.highlighting.HighlightUsagesHandler.getNameIdentifier(HighlightUsagesHandler.java:419)
at com.intellij.codeInsight.highlighting.HighlightUsagesHandler.getNameIdentifierRange(HighlightUsagesHandler.java:289)
at com.intellij.codeInsight.daemon.impl.IdentifierHighlighterPass.highlightTargetUsages(IdentifierHighlighterPass.java:146)
at com.intellij.codeInsight.daemon.impl.IdentifierHighlighterPass.doCollectInformation(IdentifierHighlighterPass.java:110)
at com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:62)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass$1$1.run(PassExecutorService.java:357)
at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1184)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass$1.run(PassExecutorService.java:348)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:226)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.doRun(PassExecutorService.java:345)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.run(PassExecutorService.java:321)
at com.intellij.concurrency.JobLauncherImpl$3.call(JobLauncherImpl.java:145)
at com.intellij.concurrency.JobLauncherImpl$3.call(JobLauncherImpl.java:142)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at com.intellij.concurrency.PrioritizedFutureTask.access$101(PrioritizedFutureTask.java:31)
at com.intellij.concurrency.PrioritizedFutureTask$1.run(PrioritizedFutureTask.java:70)
at com.intellij.concurrency.PrioritizedFutureTask.run(PrioritizedFutureTask.java:113)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
``
Hi.
I wanna ask to push, lib + generated lexer.
From site - i can download 4.1 version antlr4, but in plugin(already builded) it 4.2
And it hard, without generated lexers, build plugin. Need generate it first
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(String.java:1911)
at org.antlr.intellij.plugin.ANTLRv4ProjectComponent.parseText(ANTLRv4ProjectComponent.java:133)
at org.antlr.intellij.plugin.preview.ParseTreePanel$3.run(ParseTreePanel.java:129)
at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:343)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:727)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:688)
at java.awt.EventQueue$3.run(EventQueue.java:686)
...
Added live templates accessible via meta-j
I get the following exception fairly frequently while viewing / editing a simple Antlr grammar file.
java.lang.NullPointerException
at org.antlr.v4.Tool.createGrammar(Tool.java:553)
at org.antlr.v4.Tool.loadGrammar(Tool.java:585)
at org.antlr.intellij.plugin.ANTLRv4ProjectComponent.parseText(ANTLRv4ProjectComponent.java:121)
at org.antlr.intellij.plugin.preview.ParseTreePanel$3.run(ParseTreePanel.java:129)
at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:319)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:733)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:694)
at java.awt.EventQueue$3.run(EventQueue.java:692)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:703)
at com.intellij.ide.IdeEventQueue.e(IdeEventQueue.java:697)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:524)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:335)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
For example, using parser interp, I see:
tokenNames = {java.util.Arrays$ArrayList@14156} size = 5
[1] = {java.lang.String@14116}"T__2"
[2] = {java.lang.String@14117}"T__1"
[3] = {java.lang.String@14118}"T__0"
[4] = {java.lang.String@14119}"B"
Note: [0] is null
Nick Pratt started with the hello grammar example, and then I changed "r" to be something else - specifically "WORKSHEET" then I made it lower case. He had the Antlr plugin window open at the time while I made the changes in the editor.
// Define a grammar called Hello
grammar excel;
worksheet : 'hello' ID ; // match keyword hello followed by an identifier
ID : [a-z]+ ; // match lower-case identifiers
WS : [ \t\r\n]+ -> skip ; // skip spaces, tabs, newlines
gives
java.lang.NullPointerException
at org.antlr.intellij.plugin.ANTLRv4ProjectComponent.parseText(ANTLRv4ProjectComponent.java:173)
at org.antlr.intellij.plugin.preview.ParseTreePanel$3.run(ParseTreePanel.java:129)
at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:319)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:733)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:694)
at java.awt.EventQueue$3.run(EventQueue.java:692)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:703)
at com.intellij.ide.IdeEventQueue.e(IdeEventQueue.java:697)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:524)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:335)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Where NetBeans plugin says error(122): rule 'term': must label all alternatives or none
, IntelliJ plugin (ver 1.0.2) says:
null
java.lang.NullPointerException
at org.antlr.v4.runtime.tree.gui.TreeViewer.getScaledTreeSize(TreeViewer.java:509)
at org.antlr.v4.runtime.tree.gui.TreeViewer.updatePreferredSize(TreeViewer.java:170)
at org.antlr.v4.runtime.tree.gui.TreeViewer.setScale(TreeViewer.java:699)
at org.antlr.intellij.plugin.preview.ParseTreePanel$1.stateChanged(ParseTreePanel.java:59)
at javax.swing.JSlider.fireStateChanged(JSlider.java:432)
at javax.swing.JSlider$ModelListener.stateChanged(JSlider.java:350)
at javax.swing.DefaultBoundedRangeModel.fireStateChanged(DefaultBoundedRangeModel.java:364)
at javax.swing.DefaultBoundedRangeModel.setRangeProperties(DefaultBoundedRangeModel.java:302)
at javax.swing.DefaultBoundedRangeModel.setValueIsAdjusting(DefaultBoundedRangeModel.java:231)
at javax.swing.JSlider.setValueIsAdjusting(JSlider.java:652)
at javax.swing.plaf.basic.BasicSliderUI$TrackListener.mouseDragged(BasicSliderUI.java:1751)
at java.awt.Component.processMouseMotionEvent(Component.java:6553)
at javax.swing.JComponent.processMouseMotionEvent(JComponent.java:3338)
at java.awt.Component.processEvent(Component.java:6274)
at java.awt.Container.processEvent(Container.java:2229)
at java.awt.Component.dispatchEventImpl(Component.java:4861)
at java.awt.Container.dispatchEventImpl(Container.java:2287)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4509)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
at java.awt.Container.dispatchEventImpl(Container.java:2273)
at java.awt.Window.dispatchEventImpl(Window.java:2719)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:694)
at java.awt.EventQueue$3.run(EventQueue.java:692)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:708)
at java.awt.EventQueue$4.run(EventQueue.java:706)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:697)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:520)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:335)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
For example, from the many markdown grammar:
options {tokenVocab=CharVocab;}
...
header : '#'+ ~'\n'* '\n' ;
those literals should not be highlighted in the plug-in. That means I have to look for the vocab option and then find that file. I'm not sure why running ANTLR doesn't find, probably a directory issue.
If you hesitate at an id, it tries autocomplete and adds that weird string.
parse tree: (a (e (e x) * (e xIntellijIdeaRulezzz )) <missing ';'>)
But typing fast gets correct tree:
(a (e (e x) * (e x)) ;)
Grammar:
a : e ';' ;
e : 'x'
| e '*' e
;
<assoc=right> expr '^' expr
Grammar. caret is cursor position, and press Ctrl + Space. And u get exception
grammar Lexer2;
// [ EXP+ ]
composite: '[' ']';
a:<caret>a;
Exception
null
java.lang.NullPointerException
at org.antlr.v4.tool.LeftRecursiveRule.getAltLabels(LeftRecursiveRule.java:91)
at org.antlr.v4.tool.Rule.hasAltSpecificContexts(Rule.java:200)
at org.antlr.v4.tool.LeftRecursiveRule.hasAltSpecificContexts(LeftRecursiveRule.java:60)
at org.antlr.v4.semantics.SymbolChecks.checkForLabelConflicts(SymbolChecks.java:151)
at org.antlr.v4.semantics.SymbolChecks.process(SymbolChecks.java:99)
at org.antlr.v4.semantics.SemanticPipeline.process(SemanticPipeline.java:107)
at org.antlr.v4.Tool.processNonCombinedGrammar(Tool.java:397)
at org.antlr.v4.Tool.process(Tool.java:384)
at org.antlr.intellij.plugin.ANTLRv4ExternalAnnotator.doAnnotate(ANTLRv4ExternalAnnotator.java:101)
at org.antlr.intellij.plugin.ANTLRv4ExternalAnnotator.doAnnotate(ANTLRv4ExternalAnnotator.java:34)
at com.intellij.codeInsight.daemon.impl.ExternalToolPass.doAnnotate(ExternalToolPass.java:224)
at com.intellij.codeInsight.daemon.impl.ExternalToolPass.access$400(ExternalToolPass.java:43)
at com.intellij.codeInsight.daemon.impl.ExternalToolPass$2.run(ExternalToolPass.java:135)
at com.intellij.codeInsight.daemon.impl.ExternalToolPass$3.run(ExternalToolPass.java:172)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310)
at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227)
at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217)
at com.intellij.util.Alarm$Request$1.run(Alarm.java:289)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at com.intellij.util.concurrency.QueueProcessor$RunnableConsumer.consume(QueueProcessor.java:271)
at com.intellij.util.concurrency.QueueProcessor$RunnableConsumer.consume(QueueProcessor.java:268)
at com.intellij.util.concurrency.QueueProcessor$2$1.run(QueueProcessor.java:103)
at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:231)
at com.intellij.util.concurrency.QueueProcessor$2.consume(QueueProcessor.java:100)
at com.intellij.util.concurrency.QueueProcessor$2.consume(QueueProcessor.java:97)
at com.intellij.util.concurrency.QueueProcessor$3$1.run(QueueProcessor.java:208)
at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:231)
at com.intellij.util.concurrency.QueueProcessor$3.run(QueueProcessor.java:205)
at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:456)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
at com.intellij.openapi.application.impl.ApplicationImpl$1$1.run(ApplicationImpl.java:152)
I'm trying to generate parser with specific options. Looks like right-clicking the grammar file and selecting "Configure ANTLR ..." is the right thing to do. I specify all fields as follows
I press OK, right-click the grammar file, select "Generate ANTLR regognizer" and it still generates it in folder "gen" and the classes are not with the package requested.
Next time I open the conf dialog, all settings are there except the package field which is now empty.
Plugin version 1.1, IntelliJ version 3.1.1
aivarannamaa: Occasionally i get following error in Event log when generating the recognizer:
Do not call synchronous refresh under read lock (except from EDT) - this will cause a deadlock if there are any events to fire.
java.lang.Throwable
at com.intellij.openapi.diagnostic.Logger.error(Logger.java:113)
at com.intellij.openapi.vfs.newvfs.RefreshQueueImpl.execute(RefreshQueueImpl.java:61)
at com.intellij.openapi.vfs.newvfs.RefreshSessionImpl.launch(RefreshSessionImpl.java:107)
at com.intellij.openapi.vfs.newvfs.RefreshQueueImpl.processSingleEvent(RefreshQueueImpl.java:141)
at com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl.createAndFindChildWithEventFire(VirtualDirectoryImpl.java:424)
at com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl.findChild(VirtualDirectoryImpl.java:111)
at com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl.refreshAndFindChild(VirtualDirectoryImpl.java:431)
at com.intellij.openapi.vfs.newvfs.VfsImplUtil.refreshAndFindFileByPath(VfsImplUtil.java:115)
at com.intellij.openapi.vfs.impl.local.LocalFileSystemBase.refreshAndFindFileByPath(LocalFileSystemBase.java:74)
at com.intellij.openapi.vfs.impl.local.LocalFileSystemBase.refreshAndFindFileByIoFile(LocalFileSystemBase.java:242)
at com.intellij.openapi.vfs.impl.local.LocalFileSystemBase.refreshIoFiles(LocalFileSystemBase.java:270)
at org.antlr.intellij.plugin.actions.RunANTLROnGrammarFile.antlr(RunANTLROnGrammarFile.java:159)
at org.antlr.intellij.plugin.actions.RunANTLROnGrammarFile.run(RunANTLROnGrammarFile.java:77)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:911)
at org.antlr.intellij.plugin.actions.RunANTLROnGrammarFile.run(RunANTLROnGrammarFile.java:67)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$TaskRunnable.run(ProgressManagerImpl.java:464)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:178)
at com.intellij.openapi.progress.ProgressManager.executeProcessUnderProgress(ProgressManager.java:209)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:212)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:171)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$8.run(ProgressManagerImpl.java:373)
at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:419)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
at com.intellij.openapi.application.impl.ApplicationImpl$1$1.run(ApplicationImpl.java:149)
I just found out about this plugin today, and it is like magic :) seeing the parse tree update instantaneously while updating the grammar is very helpful. I think it will also be useful to have a tool window to just list the tokens (similar to calling grun -tokens) to be able to more easily find issues with the lexer.
null
java.lang.NullPointerException
at org.antlr.intellij.plugin.ANTLRv4ProjectComponent.getInstance(ANTLRv4ProjectComponent.java:41)
at org.antlr.intellij.plugin.ANTLRv4ExternalAnnotator.doAnnotate(ANTLRv4ExternalAnnotator.java:110)
at org.antlr.intellij.plugin.ANTLRv4ExternalAnnotator.doAnnotate(ANTLRv4ExternalAnnotator.java:38)
at com.intellij.codeInsight.daemon.impl.ExternalToolPass.e(ExternalToolPass.java:224)
at com.intellij.codeInsight.daemon.impl.ExternalToolPass.access$400(ExternalToolPass.java:43)
at com.intellij.codeInsight.daemon.impl.ExternalToolPass$2.run(ExternalToolPass.java:135)
at com.intellij.codeInsight.daemon.impl.ExternalToolPass$3.run(ExternalToolPass.java:172)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310)
at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227)
at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217)
at com.intellij.util.Alarm$Request$1.run(Alarm.java:289)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at com.intellij.util.concurrency.QueueProcessor$RunnableConsumer.consume(QueueProcessor.java:271)
at com.intellij.util.concurrency.QueueProcessor$RunnableConsumer.consume(QueueProcessor.java:268)
at com.intellij.util.concurrency.QueueProcessor$2$1.run(QueueProcessor.java:103)
at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:231)
at com.intellij.util.concurrency.QueueProcessor$2.consume(QueueProcessor.java:100)
at com.intellij.util.concurrency.QueueProcessor$2.consume(QueueProcessor.java:97)
at com.intellij.util.concurrency.QueueProcessor$3$1.run(QueueProcessor.java:208)
at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:231)
at com.intellij.util.concurrency.QueueProcessor$3.run(QueueProcessor.java:205)
at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:454)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:695)
at com.intellij.openapi.application.impl.ApplicationImpl$1$1.run(ApplicationImpl.java:152)
Sometimes intellij appends text to your input stream and so the lexer must stop reading where intellij says to instead of at the end of input.
If the grammar has an error, generating the recognizer (at least in some cases) will seem to succeed. But then testing the grammar will not work and you will only see a null pointer exception in the events log window. I could not get the parse tree window to work without trying to generate the parser on the command line to see the error. It would be helpful if the grammar error appears in the events log widow as well.
This line doesn't enter loop if first node is an error node:
while (builder.getCurrentOffset() <= node.getSymbol().getStartIndex()) {
node.getSymbol().getStartIndex() is -1 for all error nodes I think so will never enter.
String index out of range: 125: String index out of range: 125
java.lang.StringIndexOutOfBoundsException: String index out of range: 125
at java.lang.String.substring(String.java:1934)
at java.lang.String.subSequence(String.java:1972)
at org.antlr.intellij.adaptor.lexer.AntlrLexerAdapter$CharSequenceCharStream.getText(AntlrLexerAdapter.java:257)
at org.antlr.v4.runtime.Lexer.notifyListeners(Lexer.java:386)
at org.antlr.v4.runtime.Lexer.nextToken(Lexer.java:168)
at org.antlr.intellij.adaptor.lexer.AntlrLexerAdapter.advance(AntlrLexerAdapter.java:153)
at com.intellij.lang.impl.PsiBuilderImpl.a(PsiBuilderImpl.java:236)
at com.intellij.lang.impl.PsiBuilderImpl.<init>(PsiBuilderImpl.java:177)
at com.intellij.lang.impl.PsiBuilderImpl.<init>(PsiBuilderImpl.java:151)
at com.intellij.lang.impl.PsiBuilderImpl.<init>(PsiBuilderImpl.java:185)
at com.intellij.lang.impl.PsiBuilderFactoryImpl.createBuilder(PsiBuilderFactoryImpl.java:52)
...
ok, I don't know what the problem is because I don't remember all of the assumptions we made about the input index but here's the deal. Upon [ it jumps into the appropriate mode for character set and looks for more stuff. It finds \ and then consumes input giving it character -1 EOF, which does not match the wildcard after the escape character here:
LEXER_CHAR_SET_BODY
: ( ~[\]\\]
| '\\' .
)+
-> more
;
The index has moved to n (size of input) after consuming \ but of course that is an invalid index. it throws no viable alternative and then the lexer tries to notify the listeners with the text. It asks for text from the start index at [ char (as it did a more()) and in the string at the current index, but the current index has now moved to n. I'm not sure this is in the plug-in. It might be and how we're using it, however, but this all seems to be in the lexer proper as it has not returned to the plug-in.
Ah. I see
public String getText(Interval interval) {
int start = interval.a;
int stop = interval.b;
if ( stop >= n ) stop = n-1;
in ANTLRInputStream. It is avoiding the index overflow. apparently there is an assumption that the index can point at the position beyond the last real character. It is up to getText() in a stream to avoid overflow.
fail:
@header {
package mantra;
import mantra.symbols.Scope;
}
I think this missed the mantra.
java.lang.NullPointerException
at org.antlr.intellij.plugin.psi.RuleSpecNode.getName(RuleSpecNode.java:23)
at com.intellij.psi.util.PsiUtilCore.getName(PsiUtilCore.java:433)
at com.intellij.codeInsight.completion.CompletionData.objectToLookupItem(CompletionData.java:240)
at com.intellij.codeInsight.completion.CompletionData.addLookupItem(CompletionData.java:273)
at com.intellij.codeInsight.completion.CompletionData.completeReference(CompletionData.java:321)
at com.intellij.codeInsight.completion.CompletionVariant.addReferenceCompletions(CompletionVariant.java:181)
at com.intellij.codeInsight.completion.CompletionData.completeReference(CompletionData.java:112)
at com.intellij.codeInsight.completion.LegacyCompletionContributor$1.consume(LegacyCompletionContributor.java:72)
at com.intellij.codeInsight.completion.LegacyCompletionContributor$1.consume(LegacyCompletionContributor.java:68)
at com.intellij.codeInsight.completion.LegacyCompletionContributor.a(LegacyCompletionContributor.java:123)
at com.intellij.codeInsight.completion.LegacyCompletionContributor.processReferences(LegacyCompletionContributor.java:106)
at com.intellij.codeInsight.completion.LegacyCompletionContributor.completeReference(LegacyCompletionContributor.java:68)
at com.intellij.codeInsight.completion.LegacyCompletionContributor.fillCompletionVariants(LegacyCompletionContributor.java:51)
at com.intellij.codeInsight.completion.CompletionService.getVariantsFromContributors(CompletionService.java:84)
at com.intellij.codeInsight.completion.CompletionService.performCompletion(CompletionService.java:115)
at com.intellij.codeInsight.completion.CompletionProgressIndicator.a(CompletionProgressIndicator.java:775)
at com.intellij.codeInsight.completion.CompletionProgressIndicator.access$900(CompletionProgressIndicator.java:86)
at com.intellij.codeInsight.completion.CompletionProgressIndicator$1CalculateItems.run(CompletionProgressIndicator.java:757)
at com.intellij.codeInsight.completion.AsyncCompletion$1$1$1.run(CompletionThreading.java:93)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:940)
at com.intellij.codeInsight.completion.AsyncCompletion$1$1.run(CompletionThreading.java:88)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:185)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:226)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:175)
at com.intellij.codeInsight.completion.AsyncCompletion$1.run(CompletionThreading.java:84)
at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:454)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:695)
at com.intellij.openapi.application.impl.ApplicationImpl$1$1.run(ApplicationImpl.java:152)
See antlr/antlr4#536
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.