grosenberg / AntlrDT

Eclipse editor and builder for Antlr4 grammars
10 stars 3 forks source link

AntlrDT - NullPointerException on Eclipse 2018-09 (4.9.0) - macOS #4

Closed svkx closed 5 years ago

svkx commented 5 years ago

Hi, @grosenberg

I got the following exception when opening Tokens View, I went through documentations and other git reported similar issues, nothing helps:

java.lang.NullPointerException
    at net.certiv.antlrdt.ui.view.tokens.GrammarRecord.genPackageNames(GrammarRecord.java:70)
    at net.certiv.antlrdt.ui.view.tokens.GrammarRecord.init(GrammarRecord.java:54)
    at net.certiv.antlrdt.ui.view.tokens.GrammarRecord.<init>(GrammarRecord.java:50)
    at net.certiv.antlrdt.ui.view.tokens.TokensView.checkGrammar(TokensView.java:180)
    at net.certiv.antlrdt.ui.view.tokens.TokensView.validateControls(TokensView.java:160)
    at net.certiv.antlrdt.ui.view.tokens.TokensView.createPartControl(TokensView.java:128)
    at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.createPartControl(CompatibilityPart.java:156)
    at org.eclipse.ui.internal.e4.compatibility.CompatibilityView.createPartControl(CompatibilityView.java:152)
    at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.create(CompatibilityPart.java:367)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58)
    at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:1001)
    at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:966)
    at org.eclipse.e4.core.internal.di.InjectorImpl.internalInject(InjectorImpl.java:139)
    at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:411)
    at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:333)
    at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:193)
    at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:108)
    at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:77)
    at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:59)
    at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.createWidget(ContributedPartRenderer.java:132)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createWidget(PartRenderingEngine.java:1015)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:675)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$1.run(PartRenderingEngine.java:560)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:544)
    at org.eclipse.e4.ui.workbench.renderers.swt.ElementReferenceRenderer.createWidget(ElementReferenceRenderer.java:73)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createWidget(PartRenderingEngine.java:1015)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:675)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:781)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$0(PartRenderingEngine.java:752)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$2.run(PartRenderingEngine.java:746)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:730)
    at org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer.showTab(StackRenderer.java:1296)
    at org.eclipse.e4.ui.workbench.renderers.swt.LazyStackRenderer.lambda$0(LazyStackRenderer.java:75)
    at org.eclipse.e4.ui.services.internal.events.UIEventHandler.lambda$0(UIEventHandler.java:38)
    at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:236)
    at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:147)
    at org.eclipse.swt.widgets.Display.syncExec(Display.java:4905)
    at org.eclipse.e4.ui.internal.workbench.swt.E4Application$1.syncExec(E4Application.java:215)
    at org.eclipse.e4.ui.services.internal.events.UIEventHandler.handleEvent(UIEventHandler.java:38)
    at org.eclipse.equinox.internal.event.EventHandlerWrapper.handleEvent(EventHandlerWrapper.java:204)
    at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:199)
    at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:1)
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:233)
    at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:151)
    at org.eclipse.equinox.internal.event.EventAdminImpl.dispatchEvent(EventAdminImpl.java:138)
    at org.eclipse.equinox.internal.event.EventAdminImpl.sendEvent(EventAdminImpl.java:81)
    at org.eclipse.equinox.internal.event.EventComponent.sendEvent(EventComponent.java:42)
    at org.eclipse.e4.ui.services.internal.events.EventBroker.send(EventBroker.java:55)
    at org.eclipse.e4.ui.internal.workbench.UIEventPublisher.notifyChanged(UIEventPublisher.java:63)
    at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:424)
    at org.eclipse.e4.ui.model.application.ui.impl.ElementContainerImpl.setSelectedElement(ElementContainerImpl.java:177)
    at org.eclipse.e4.ui.workbench.renderers.swt.LazyStackRenderer.postProcess(LazyStackRenderer.java:110)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:693)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:781)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$0(PartRenderingEngine.java:752)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$2.run(PartRenderingEngine.java:746)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:730)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.subscribeTopicToBeRendered(PartRenderingEngine.java:160)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58)
    at org.eclipse.e4.core.di.internal.extensions.EventObjectSupplier$DIEventHandler.handleEvent(EventObjectSupplier.java:91)
    at org.eclipse.equinox.internal.event.EventHandlerWrapper.handleEvent(EventHandlerWrapper.java:204)
    at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:199)
    at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:1)
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:233)
    at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:151)
    at org.eclipse.equinox.internal.event.EventAdminImpl.dispatchEvent(EventAdminImpl.java:138)
    at org.eclipse.equinox.internal.event.EventAdminImpl.sendEvent(EventAdminImpl.java:81)
    at org.eclipse.equinox.internal.event.EventComponent.sendEvent(EventComponent.java:42)
    at org.eclipse.e4.ui.services.internal.events.EventBroker.send(EventBroker.java:55)
    at org.eclipse.e4.ui.internal.workbench.UIEventPublisher.notifyChanged(UIEventPublisher.java:63)
    at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:424)
    at org.eclipse.e4.ui.model.application.ui.impl.UIElementImpl.setToBeRendered(UIElementImpl.java:307)
    at org.eclipse.e4.ui.workbench.addons.cleanupaddon.CleanupAddon.subscribeRenderingChanged(CleanupAddon.java:314)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58)
    at org.eclipse.e4.ui.internal.di.UIEventObjectSupplier$UIEventHandler$1.run(UIEventObjectSupplier.java:67)
    at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:236)
    at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:147)
    at org.eclipse.swt.widgets.Display.syncExec(Display.java:4905)
    at org.eclipse.e4.ui.internal.workbench.swt.E4Application$1.syncExec(E4Application.java:215)
    at org.eclipse.e4.ui.internal.di.UIEventObjectSupplier$UIEventHandler.handleEvent(UIEventObjectSupplier.java:64)
    at org.eclipse.equinox.internal.event.EventHandlerWrapper.handleEvent(EventHandlerWrapper.java:204)
    at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:199)
    at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:1)
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:233)
    at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:151)
    at org.eclipse.equinox.internal.event.EventAdminImpl.dispatchEvent(EventAdminImpl.java:138)
    at org.eclipse.equinox.internal.event.EventAdminImpl.sendEvent(EventAdminImpl.java:81)
    at org.eclipse.equinox.internal.event.EventComponent.sendEvent(EventComponent.java:42)
    at org.eclipse.e4.ui.services.internal.events.EventBroker.send(EventBroker.java:55)
    at org.eclipse.e4.ui.internal.workbench.UIEventPublisher.notifyChanged(UIEventPublisher.java:63)
    at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:424)
    at org.eclipse.e4.ui.model.application.ui.impl.UIElementImpl.setToBeRendered(UIElementImpl.java:307)
    at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.showElementInWindow(ModelServiceImpl.java:632)
    at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.bringToTop(ModelServiceImpl.java:601)
    at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.delegateBringToTop(PartServiceImpl.java:791)
    at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:762)
    at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:684)
    at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:679)
    at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.showPart(PartServiceImpl.java:1232)
    at org.eclipse.ui.internal.WorkbenchPage.showPart(WorkbenchPage.java:1293)
    at org.eclipse.ui.internal.WorkbenchPage.busyShowView(WorkbenchPage.java:1282)
    at org.eclipse.ui.internal.WorkbenchPage.lambda$10(WorkbenchPage.java:4393)
    at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:72)
    at org.eclipse.ui.internal.WorkbenchPage.showView(WorkbenchPage.java:4391)
    at org.eclipse.ui.internal.WorkbenchPage.showView(WorkbenchPage.java:4371)
    at org.eclipse.ui.handlers.ShowViewHandler.openView(ShowViewHandler.java:135)
    at org.eclipse.ui.handlers.ShowViewHandler.openOther(ShowViewHandler.java:113)
    at org.eclipse.ui.handlers.ShowViewHandler.execute(ShowViewHandler.java:80)
    at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:294)
    at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:96)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58)
    at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:320)
    at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:254)
    at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:164)
    at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:156)
    at org.eclipse.core.commands.Command.executeWithChecks(Command.java:497)
    at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:490)
    at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:207)
    at org.eclipse.ui.internal.handlers.LegacyHandlerService.executeCommand(LegacyHandlerService.java:399)
    at org.eclipse.ui.internal.ShowViewMenu$1.run(ShowViewMenu.java:142)
    at org.eclipse.jface.action.Action.runWithEvent(Action.java:476)
    at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:568)
    at org.eclipse.jface.action.ActionContributionItem.lambda$4(ActionContributionItem.java:400)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
    at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4292)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1512)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1535)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1520)
    at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1324)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4116)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3733)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1173)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1062)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156)
    at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:628)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:563)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:151)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:155)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:199)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:137)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:107)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:391)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:246)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:595)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1501)

My setup is Eclipse 2018-09 (4.9.0). I included all g4 files, generated sources and testing text files into build path, automatic builds work just fine. There might be some bug with handling packages, based on the exception stack. I checked the jar where that issue is getting thrown: net.certiv.antlrdt.ui.view.tokens.GrammarRecord.genPackageNames(GrammarRecord.java:70). It doesn't seem like any process has started that it's unable to find a resource but it's likely the problem with AntlrDTCore initialization.

I tried a few different installations: From Eclipse marketplace and from update sites. Marketplace installation includes Zest dependency, though, as mentioned in another git issue I tried to install Zest manually, that is v 1.7.0 currently. In fact, Marketplace version of AntlrDT references to the same 1.7.0 Zest version.

The problem hasn't gone away. If that Eclipse 2018-09 incompatibility issue then this is unfortunate for me. Please let me know if anything else can cause the NullPointerException.

grosenberg commented 5 years ago

Updated the Github Readme with a recommended layout. Check and advise of any differences to what you are using.

deepankarsharma commented 5 years ago

Small request for @grosenberg - Could you please upload a sample working Eclipse project into this github? That would be very helpful for people like me who are trying to use AntlrDT but are new to the Java ecosystem.

grosenberg commented 5 years ago

@deepankarsharma - try this net.certiv.toml.dev.zip

deepankarsharma commented 5 years ago

Thanks for responding promptly and for taking the time to create a standalone project.

I had to do a couple of things to get the project working from scratch on eclipse

  1. Add http:// to www.certiv.net/updates before being able to add it in eclipse.
  2. Add log4j-api-2.11.1.jar and log4g-core-2.11.1.jar to lib since maven didnt appear to be downloading these.
  3. Go to pom.xml and click quick fix - since m2e connectors were missing.

Now I am stuck at the following stack traces.

java.lang.NoClassDefFoundError: org/eclipse/jdt/internal/corext/codemanipulation/OrganizeImportsOperation$IChooseImportQuery at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671) at java.lang.Class.getConstructor0(Class.java:3075) at java.lang.Class.newInstance(Class.java:412) at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:190) at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:934) at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:246) at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:63) at org.eclipse.core.internal.events.BuildManager.instantiateBuilder(BuildManager.java:963) at org.eclipse.core.internal.events.BuildManager.initializeBuilder(BuildManager.java:916) at org.eclipse.core.internal.events.BuildManager.getBuilder(BuildManager.java:601) at org.eclipse.core.internal.events.BuildManager.getBuilder(BuildManager.java:638) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:260) at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:315) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:318) at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:370) at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:391) at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:145) at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:235) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63) Caused by: java.lang.ClassNotFoundException: org.eclipse.jdt.internal.corext.codemanipulation.OrganizeImportsOperation$IChooseImportQuery cannot be found by net.certiv.antlrdt.core_4.7.0.20171212-2143 at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:511) at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422) at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:414) at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:153) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 21 more

===================================================================

org.eclipse.core.runtime.CoreException: Plug-in "net.certiv.antlrdt.core" was unable to instantiate class "net.certiv.antlrdt.core.builder.AntlrDTBuilder". at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.throwException(RegistryStrategyOSGI.java:200) at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:194) at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:934) at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:246) at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:63) at org.eclipse.core.internal.events.BuildManager.instantiateBuilder(BuildManager.java:963) at org.eclipse.core.internal.events.BuildManager.initializeBuilder(BuildManager.java:916) at org.eclipse.core.internal.events.BuildManager.getBuilder(BuildManager.java:601) at org.eclipse.core.internal.events.BuildManager.getBuilder(BuildManager.java:638) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:260) at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:315) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:318) at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:370) at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:391) at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:145) at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:235) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63) Caused by: java.lang.NoClassDefFoundError: org/eclipse/jdt/internal/corext/codemanipulation/OrganizeImportsOperation$IChooseImportQuery at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671) at java.lang.Class.getConstructor0(Class.java:3075) at java.lang.Class.newInstance(Class.java:412) at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:190) ... 16 more Caused by: java.lang.ClassNotFoundException: org.eclipse.jdt.internal.corext.codemanipulation.OrganizeImportsOperation$IChooseImportQuery cannot be found by net.certiv.antlrdt.core_4.7.0.20171212-2143 at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:511) at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422) at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:414) at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:153) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 21 more

svkx commented 5 years ago

@grosenberg thank you for README updates and a sample project. This really helped me to move forward with NPE and compare sample project with mine. I used the version from Marketplace, I also notice the version on update site is the same with recent update.

I had to do similar steps as @deepankarsharma. In fact, I was able to reproduce the same exception on my project as well:

org.eclipse.core.runtime.CoreException: Plug-in "net.certiv.antlrdt.core" was unable to instantiate class "net.certiv.antlrdt.core.builder.AntlrDTBuilder".
    at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.throwException(RegistryStrategyOSGI.java:200)
    at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:194)
    at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:934)
    at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:246)
    at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:63)
    at org.eclipse.core.internal.events.BuildManager.instantiateBuilder(BuildManager.java:963)
    at org.eclipse.core.internal.events.BuildManager.initializeBuilder(BuildManager.java:916)
    at org.eclipse.core.internal.events.BuildManager.getBuilder(BuildManager.java:601)
    at org.eclipse.core.internal.events.BuildManager.getBuilder(BuildManager.java:638)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:260)
    at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:315)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:318)
    at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:370)
    at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:391)
    at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:145)
    at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:235)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: java.lang.NoClassDefFoundError: org/eclipse/jdt/internal/corext/codemanipulation/OrganizeImportsOperation$IChooseImportQuery
    at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.base/java.lang.Class.privateGetDeclaredConstructors(Class.java:3110)
    at java.base/java.lang.Class.getConstructor0(Class.java:3315)
    at java.base/java.lang.Class.newInstance(Class.java:530)
    at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:190)
    ... 16 more
Caused by: java.lang.ClassNotFoundException: org.eclipse.jdt.internal.corext.codemanipulation.OrganizeImportsOperation$IChooseImportQuery cannot be found by net.certiv.antlrdt.core_4.7.0.20171212-2143
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:511)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:414)
    at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:153)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496)
    ... 21 more

But this happens during the build process, looks like AntlrDT wasn't able to generate the code in my project. Similar with sample project, yet no Exception was thrown and net.certiv.toml.dev.parser.gen stayed empty unless I did the following maven trick. This time build happened with external mvn clean package call and Lexer, Parser, Listeners Java classes have been compiled:

<plugin>
  <groupId>org.antlr</groupId>
  <artifactId>antlr4-maven-plugin</artifactId>
  <version>4.7.1</version>
  <executions>
    <execution>
      <id>Toml</id>
      <goals>
        <goal>antlr4</goal>
      </goals>
      <configuration>
        <sourceDirectory>${project.basedir}/src/main/java/net/certiv/toml/dev/parser/</sourceDirectory>
        <outputDirectory>${project.basedir}/src/main/java/net/certiv/toml/dev/parser/gen</outputDirectory>
      </configuration>
    </execution>
  </executions>
</plugin>

Sample project appeared as following:

net.certiv.toml.dev/src/main/java
└── net
    └── certiv
        └── toml
            └── dev
                ├── App.java
                ├── parser
                │   ├── TomlLexer.g4
                │   ├── TomlParser.g4
                │   └── gen
                │       ├── TomlLexer.interp
                │       ├── TomlLexer.java
                │       ├── TomlLexer.tokens
                │       ├── TomlParser.interp
                │       ├── TomlParser.java
                │       ├── TomlParser.tokens
                │       ├── TomlParserBaseListener.java
                │       └── TomlParserListener.java
                └── util
                    └── Strings.java

After that I open TokensView widget, In integration window:

Project: net.certiv.toml.dev
Gen: TomlParser.g4
Snippets Dir: ../../parent-folder/net.certiv.toml.dev/test.snippets
Snippets Ext: toml
Token factory: {empty or TomlParser.tokens}
Parser Error strategy: {empty}

I was not sure if I need to specify anything in Token factory (as antlr framework is something new for me), tried to keep both empty and set to TomlParser.tokens. But once I set the value I cannot unset this.

After Integration setup I picked up both example-v0.3.0.toml and example-v0.4.0.toml, but nothing happens after that. All Lexer, Grammar, example files are open in editor, nothing happens on example editing. TokensView stays empty and no Exceptions thrown in workspace logs.

I'm running Eclipse on macOS, I was able to run Eclipse in console mode and forward errors from system output. This is what I get:

10:12:57.022 [Worker-1: Parse Tree Builder] ERROR net.certiv.antlrdt.ui.view.tokens.TargetUnit - Failed to load class 'net.certiv.toml.dev.parser.gen.TomlParser' (net.certiv.toml.dev.parser.gen.TomlParser)
10:12:57.024 [Worker-1: Parse Tree Builder] ERROR net.certiv.antlrdt.ui.view.tokens.TargetUnit - Failed to load class 'net.certiv.toml.dev.parser.gen.TomlLexer' (net.certiv.toml.dev.parser.gen.TomlLexer)
10:12:57.024 [Worker-1: Parse Tree Builder] ERROR java.lang.Class - Failed to find resource [name=TomlParser.tokens]

I still think there might be something off with my workspace configuration as your project is considered a working one. It is not clear for me why AntlrDTBuilder is not able to initialize on itself and I had to engage maven plugin for that, which is likely unnecessary if AntlrDT plugin should do the trick.

I keep digging, if you can give a couple of suggestions on ERRORs above I'm stuck with. I try to include as much debug information as possible. Let me know if you may need to get more, e.g. run eclipse plugin in debug mode somehow.

--

Now, speaking of my own project. The major difference I found is that my g4 files are stored in src/main/antlr4 and are getting built into src/main/java. Though, both of them are in a build path, TokensView throws that NullPointerException in a first place. I just followed the recommended antlr4 setup, and, by default, antlr maven plugin looks into src/main/antlr4. This might be a good test case for you to check. I still need to figure out what else can be different, but I would prefer to have the plugin working first with your sample project and then deal with my project layout.

Thank you for your quick response anyway! =)

grosenberg commented 5 years ago

Caused by: java.lang.NoClassDefFoundError: org/eclipse/jdt/internal/corext/codemanipulation/OrganizeImportsOperation$IChooseImportQuery

OrganizeImportsOperation is a standard part of the JDT; indicates that the JDT is missing from your Eclipse installation?

@ssbiox while not preferred, using Maven to generate the grammar -> java files should be OK (the next version of AntlrDT will explicitly allow for use of such 'extra' source roots).

Be sure that you have 'Project → Build Automatically' so that the necessary class files are auto-generated. Verify that the class files exist under /target/classes

10:12:57.022 [Worker-1: Parse Tree Builder] ERROR net.certiv.antlrdt.ui.view.tokens.TargetUnit - Failed to load class 'net.certiv.toml.dev.parser.gen.TomlParser' (net.certiv.toml.dev.parser.gen.TomlParser)

To produce the ParseTree and Tokens views, AntlrDT has to instantiate and execute the class files. The failure to load message indicates that the class files do not exist in the expected location.

svkx commented 5 years ago

@grosenberg it might be the problem with Eclipse 2018-09 then. I do have JDT installed by default, that is confirmed in "Installation Details" and update site won't allow to install it again. This is a list of all org.eclipse.jdt.* jars available in plugins folder:

/Applications/Eclipse.app/Contents/Eclipse/plugins$ tree | grep jdt
├── org.eclipse.jdt.annotation.source_1.1.300.v20180905-0314.jar
├── org.eclipse.jdt.annotation.source_2.2.100.v20180905-0314.jar
├── org.eclipse.jdt.annotation_1.1.300.v20180905-0314.jar
├── org.eclipse.jdt.annotation_2.2.100.v20180905-0314.jar
├── org.eclipse.jdt.apt.core.source_3.6.100.v20180905-0315.jar
├── org.eclipse.jdt.apt.core_3.6.100.v20180905-0315.jar
├── org.eclipse.jdt.apt.pluggable.core.source_1.2.200.v20180905-0315.jar
├── org.eclipse.jdt.apt.pluggable.core_1.2.200.v20180905-0315.jar
├── org.eclipse.jdt.apt.ui.source_3.6.100.v20180905-0315.jar
├── org.eclipse.jdt.apt.ui_3.6.100.v20180905-0315.jar
├── org.eclipse.jdt.compiler.apt.source_1.3.300.v20180905-0315.jar
├── org.eclipse.jdt.compiler.apt_1.3.300.v20180905-0315.jar
├── org.eclipse.jdt.compiler.tool.source_1.2.300.v20180905-0319.jar
├── org.eclipse.jdt.compiler.tool_1.2.300.v20180905-0319.jar
├── org.eclipse.jdt.core.manipulation.source_1.10.100.v20180829-0618.jar
├── org.eclipse.jdt.core.manipulation_1.10.100.v20180829-0618.jar
├── org.eclipse.jdt.core.source_3.15.0.v20180905-0317.jar
├── org.eclipse.jdt.core_3.15.0.v20180905-0317.jar
├── org.eclipse.jdt.debug.source_3.12.0.v20180827-1040.jar
├── org.eclipse.jdt.debug.ui.source_3.10.0.v20180827-1040.jar
├── org.eclipse.jdt.debug.ui_3.10.0.v20180827-1040.jar
├── org.eclipse.jdt.debug_3.12.0.v20180827-1040
├── org.eclipse.jdt.doc.isv_3.14.100.v20180905-0558.jar
├── org.eclipse.jdt.doc.user_3.15.0.v20180905-1254.jar
├── org.eclipse.jdt.junit.core.source_3.10.100.v20180829-0645.jar
├── org.eclipse.jdt.junit.core_3.10.100.v20180829-0645.jar
├── org.eclipse.jdt.junit.runtime.source_3.4.800.v20180829-0645.jar
├── org.eclipse.jdt.junit.runtime_3.4.800.v20180829-0645.jar
├── org.eclipse.jdt.junit.source_3.11.100.v20180829-0645.jar
├── org.eclipse.jdt.junit4.runtime.source_1.1.800.v20180829-0645.jar
├── org.eclipse.jdt.junit4.runtime_1.1.800.v20180829-0645.jar
├── org.eclipse.jdt.junit5.runtime.source_1.0.200.v20180829-0645.jar
├── org.eclipse.jdt.junit5.runtime_1.0.200.v20180829-0645.jar
├── org.eclipse.jdt.junit_3.11.100.v20180829-0645.jar
├── org.eclipse.jdt.launching.macosx.source_3.4.200.v20180823-0805.jar
├── org.eclipse.jdt.launching.macosx_3.4.200.v20180823-0805.jar
├── org.eclipse.jdt.launching.source_3.11.0.v20180827-1040.jar
├── org.eclipse.jdt.launching.ui.macosx.source_1.2.200.v20180823-0805.jar
├── org.eclipse.jdt.launching.ui.macosx_1.2.200.v20180823-0805.jar
├── org.eclipse.jdt.launching_3.11.0.v20180827-1040.jar
├── org.eclipse.jdt.ui.source_3.15.0.v20180829-2215.jar
├── org.eclipse.jdt.ui_3.15.0.v20180829-2215.jar
├── org.eclipse.jdt_3.15.0.v20180906-0745.jar

It seems like org.eclipse.jdt.internal.corext package is no longer there?

As for the other questions: I do have Automatic Builds available and class files are found inside target folder and jar:

├── classes
│   └── net
│       └── certiv
│           └── toml
│               └── dev
│                   ├── App.class
│                   ├── parser
│                   │   └── gen
│                   │       ├── TomlLexer.class
│                   │       ├── TomlParser$ArrayContext.class
│                   │       ├── TomlParser$DottedIDContext.class
│                   │       ├── TomlParser$ElementContext.class
│                   │       ├── TomlParser$InlineTableContext.class
│                   │       ├── TomlParser$KeyContext.class
│                   │       ├── TomlParser$ScalarContext.class
│                   │       ├── TomlParser$StringContext.class
│                   │       ├── TomlParser$TableArrayContext.class
│                   │       ├── TomlParser$TableContext.class
│                   │       ├── TomlParser$TomlContext.class
│                   │       ├── TomlParser$ValueContext.class
│                   │       ├── TomlParser.class
│                   │       ├── TomlParserBaseListener.class
│                   │       └── TomlParserListener.class
│                   └── util
│                       └── Strings.class

Should I be able to run the plugin on latest Eclipse? Or should I downgrade to 4.5.2 as mentioned in documentation? Which Eclipse version supported?

grosenberg commented 5 years ago

@ssbiox

1) It is part of the org.eclipse.jdt.core.manipulation bundle. Have you installed any other plugin that might change/interfere the JDT, such as Scala or Koltin? 2) In any case, need to see your configuration ('Help → About → Installation Details → Configuration'). Preferably attach to a reply as a file.
3) are the class files under /classes/ or /target/classes/ ? 4) AntlrDT runs just fine, as it should, on the latest Eclipse version (for me on Windows)

Eclipse IDE for Java Developers Version: 2018-09 (4.9.0) Build id: 20180917-1800

svkx commented 5 years ago

@grosenberg

  1. thank you for pointing out to the jar name, I should've searched for it across all jars. I use the standard macOS installation package from eclipse.org. I attempted to re-download the vanilla macOS package of Java Developers Edition, the problem persists and I can see what's wrong. The package is different: org.eclipse.jdt.core.manipulation
    
    /Applications/Eclipse.app/Contents/Eclipse/plugins$ find . -name '*jdt.core*.jar' -print0 |  xargs -0 -I '{}' sh -c 'jar tf {} | grep OrganizeImportsOperation &&  echo {}'
    org/eclipse/jdt/core/manipulation/OrganizeImportsOperation.class
    org/eclipse/jdt/core/manipulation/OrganizeImportsOperation$UnresolvableImportMatcher.class
    org/eclipse/jdt/core/manipulation/OrganizeImportsOperation$TypeReferenceProcessor.class
    org/eclipse/jdt/core/manipulation/OrganizeImportsOperation$1.class
    org/eclipse/jdt/core/manipulation/OrganizeImportsOperation$TypeReferenceProcessor$UnresolvedTypeData.class
    org/eclipse/jdt/core/manipulation/OrganizeImportsOperation$IChooseImportQuery.class
    ./org.eclipse.jdt.core.manipulation_1.10.100.v20180829-0618.jar

/Applications/Eclipse.app/Contents/Eclipse/plugins$ md5 org.eclipse.jdt.core.manipulation_1.10.100.v20180829-0618.jar MD5 (org.eclipse.jdt.core.manipulation_1.10.100.v20180829-0618.jar) = f8e41e71b8eb232dd72b1e4a6f089905


2. Let me know if I can send you the configuration directly, a little concern that it may contain any private host information. Probably, it's not really necessary since I found a mismatch in macOS version
3. Class files are generated by maven under target/classes and also bundled into the jar.
4. Good to hear, but apparently the jdt jar is different for mac.
grosenberg commented 5 years ago

@ssbiox Please send the configuration to support@certiv.net.

There should not be such a difference in the jars. Looking in eclipse-java-2018-09-macosx-cocoa-x86_64.dmg I can see the jar has the same content (both by the filenames in the relevant subdir and the size of the jar) as compared to the same jar in my working Windows installation.

Name: org.eclipse.jdt.core.manipulation_1.10.100.v20180829-0618.jar
Size: 500 826
Created: 2018-09-17 12:03:44

Do you have old and/or 32-bit versions of Eclipse installed?

Hopefully the configuration will illuminate the problem.

svkx commented 5 years ago

@grosenberg Hmm, that is very interesting. I use the same latest 64 bit setup file from here: https://www.eclipse.org/downloads/packages/release/2018-09/r/eclipse-ide-java-developers Reinstalled from scratch, vanilla version, no extra plugins installed. About shows:

Eclipse IDE for Java Developers
Version: 2018-09 (4.9.0)
Build id: 20180917-1800

Jar looks like the same size:

ls -la org.eclipse.jdt.core.manipulation_1.10.100.v20180829-0618.jar
-rw-r--r--@ 1 xxx  admin  500826 Sep 17 16:05 org.eclipse.jdt.core.manipulation_1.10.100.v20180829-0618.jar

I'll send you the configuration shortly.

svkx commented 5 years ago

@grosenberg I've also checked Windows installation of "Eclipse IDE for Java Developers" edition; version: 2018-09 (4.9.0); build id: 20180917-1800. It looks like OrganizeImportsOperation has been moved as well within org.eclipse.jdt.core.manipulation_1.10.100.v20180829-0618.jar

grosenberg commented 5 years ago

Unfortunately, the current public version of AntlrDT is not fully compatible with Eclipse 2018-09. This will be true on both Windows and Mac. As a bit of a hack, if both Eclipse Photon and Eclipse 2018-09 are installed, AntlrDT will work regardless of which version of Eclipse is run (at least on Windows -- both versions populate the same local .p2 repository with the class files necessary for the builder to instantiate and build the Antlr grammars.

Certainly, downgrading to Eclipse Photon will work.

Currently working on a point upgrade that will fix this problem.

james-bryant-entrust commented 5 years ago

I have both Photon and 2018-09 installed, but it still does not work for me. Is there some kind of trick to getting it to work?

svkx commented 5 years ago

@james-bryant-entrust I haven't found any workaround at the moment and gave up using the tool until it's fixed with latest Eclipse. I believe the short term solution might be an eclipse bundle with compatible plugins and default workspace and sample project; Eclipse API seems like not always backward compatible.

grosenberg commented 5 years ago

Fixed in newest release.