[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [imp-dev] Problems with custom parser

I'm happy to tell everybody that custom parser generated by ANTLR worked pretty good with IMP. At the moment I added only token coloring, and soon I'll try to add another stuff. 

Everybody, who have such issues, can check out my code from SVN - http://code.google.com/p/haxe-student-project/source/browse/#svn/trunk/haXe-IDE-IMP (token coloring added at 27-th revision). It contains some comments on Russian language, but feel free to ask me anything.

P.S. I'll repost soon this on eclipse IMP forum page, in custom parser's experience topic.

2010/5/3 Anatoly Kondratyev <anatoly.kondratyev@xxxxxxxxxxxxxx>
Thank you, Robert,

It was just what I done to solve problem. I wrote about it in my previous message in this mailing list - http://dev.eclipse.org/mhonarc/lists/imp-dev/msg00369.html. The problem was only in my hands, not IMP=).

Thanks for great tool! It really helps.  

2010/5/3 Robert M. Fuhrer <rfuhrer@xxxxxxxxxxxxxx>
Anatoly,

Sounds as though the ANTLR runtime library might be just in the project's .classpath (say, as a library or project dependency), and therefore not technically part of any bundle?

If you have the ANTLR jar file in your plugin (as opposed to its being contained within another bundle), you need to make sure that it is part of the bundle's "runtime path". I.e., edit the bundle manifest (META-INF/MANIFEST.MF), and on the "Runtime" tab, make sure that the jar file is listed in the "Classpath" pane in the lower-right.

If you just have the jar file listed as a project/library dependency in the Java Build Path property page, things *might* appear to work ok at debug time, but you'll get ClassNotFoundExceptions or somesuch at deploy time. This is because each bundle has its own class loader, and that class loader only pays attention to the info in the bundle manifest when setting up the runtime classpath. In fact, it doesn't even "know" about the .classpath file (which is a development-time artifact used by the Java development toolchain). [This is one way in which building Eclipse plugins differs significantly from building ordinary Java applications with the JDT.]

Does that help?

On May 3, 2010, at 10:09 AM, Anatoly Kondratyev wrote:

Hi Jurgen,

Thanks for reply - it really helps. I don't know what the hell was in my head yesterday, so I forgot to check error log. But, anyway, before I read your letter, I'v found something interesting, and even tried to write letter here, but completely fall asleep=). May be it will be useful for somebody: 

I have two IMP projects - first - is absolutely-default project created step-by-step by user guide, so it is about LEG, and it works fine. The second one is mine, it's about haxe programming language. So, now the most interesting part: when IMP applications are initializing, they search for some extensions needed for services. Services are provided by ServiceFactory (I mentioned it early), and extensions by ExtensionFactory. In my case bug appears in 

   private static ILanguageService loadLanguageService(IExtensionPoint extensionPoint, String language, String elementName,              IConfigurationElement element) throws ExtensionException {...}

method. (in my version, latest for today, it is line 312 of org.eclipse.imp.utils.ExtensionFactory). 

In first line of this method BundleHost variable bundle is initialized:

         Bundle bundle = Platform.getBundle(element.getDeclaringExtension().getContributor().getName());

The problem is, that bundle generated for both cases (for LEG project and mine) are equal (or very similar) - and they are about LEG.bla-bla-bla.framework, or something like this (I'm not sure about spelling); so when I tried LEG project, IMP checks if bundle equals to LEG language (it was true) and returns me something useful, but when IMP checks the same at my own, haxe project, it fails - bundle was still connected to LEG, but language was haxe, so it returns somewhere null.

So, long story short, I decided to clean up everything I could, but it was late night and I accidentally deleted all the code of my project (played too long with Run Configurations and working sets). Luckily it all was stored in SVN, so I restored my project and, while restoring, I noticed your letter. I run project, it fails as before, I open Error Log, where I see the problem:

Unable to instantiate implementation of Language-specific parser plugin for language 'haxe' because of the following low level exception: java.lang.NoClassDefFoundError: org/antlr/runtime/RecognitionException

org.eclipse.imp.utils.ExtensionException: Unable to instantiate implementation of Language-specific parser plugin for language 'haxe' because of the following low level exception: java.lang.NoClassDefFoundError: org/antlr/runtime/RecognitionException
at org.eclipse.imp.utils.ExtensionFactory.loadLanguageService(ExtensionFactory.java:335)
at org.eclipse.imp.utils.ExtensionFactory.getLanguageServiceForElement(ExtensionFactory.java:290)
at org.eclipse.imp.utils.ExtensionFactory.createServiceExtensionForPlugin(ExtensionFactory.java:120)
at org.eclipse.imp.utils.ExtensionFactory.createServiceExtensionForPlugin(ExtensionFactory.java:156)
at org.eclipse.imp.utils.ExtensionFactory.createServiceExtension(ExtensionFactory.java:53)
at org.eclipse.imp.language.ServiceFactory.createExtension(ServiceFactory.java:550)
at org.eclipse.imp.language.ServiceFactory.loadService(ServiceFactory.java:582)
at org.eclipse.imp.language.ServiceFactory.getParseController(ServiceFactory.java:444)
at org.eclipse.imp.editor.LanguageServiceManager.initialize(LanguageServiceManager.java:123)
at org.eclipse.imp.editor.UniversalEditor.createPartControl(UniversalEditor.java:689)
at org.eclipse.ui.internal.EditorReference.createPartHelper(EditorReference.java:662)
at org.eclipse.ui.internal.EditorReference.createPart(EditorReference.java:462)
at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:595)
at org.eclipse.ui.internal.EditorAreaHelper.setVisibleEditor(EditorAreaHelper.java:271)
at org.eclipse.ui.internal.EditorManager.setVisibleEditor(EditorManager.java:1417)
at org.eclipse.ui.internal.EditorManager$5.runWithException(EditorManager.java:942)
at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3855)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3476)
at org.eclipse.ui.application.WorkbenchAdvisor.openWindows(WorkbenchAdvisor.java:803)
at org.eclipse.ui.internal.Workbench$28.runWithException(Workbench.java:1384)
at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3855)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3476)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2316)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:493)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
at org.eclipse.equinox.launcher.Main.main(Main.java:1287)
Caused by: org.eclipse.core.runtime.CoreException: Plug-in "haXe_IDE" was unable to instantiate class "haxe.imp.parser.HaxeParseController".
at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.throwException(RegistryStrategyOSGI.java:180)
at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:174)
at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:874)
at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243)
at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:51)
at org.eclipse.imp.utils.ExtensionFactory.loadLanguageService(ExtensionFactory.java:323)
... 47 more
Caused by: java.lang.NoClassDefFoundError: org/antlr/runtime/RecognitionException
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:170)
... 51 more
Caused by: java.lang.ClassNotFoundException: org.antlr.runtime.RecognitionException
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:494)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:398)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:105)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 57 more

So, as I can see now, problem is that project doesn't pick up ANTLR Library (I use parser generated by ANTLR and some classes from it's library). Of course, in my project I have necessary library and can easily work with RecognitionException class. So, question of the day - how to check what libraries should be available at plugins runtime? 

About things that could go wrong, you mentioned above - I checked them in the first place. =)

2010/5/3 Jurgen Vinju <jurgen@xxxxxxxxx>
Hi Anatoly,

The first thing to do is to start the ErrorLog viewer (Using
Window->Show View). The reason for the failure is (probably) logged
there. Make sure to browse through the entire stack trace to find the
original cause.

Things that might have gone wrong are:
 - you have no zero argument constructor for the class that implement
IParseController
 - the extension points to a class that does not exist
 - the language name in the parser extension is different from the
language you registered with the extension
 - ...?

Cheers,

Jurgen

On Sun, May 2, 2010 at 8:50 PM, Anatoly Kondratyev
<anatoly.kondratyev@xxxxxxxxxxxxxx> wrote:
> Hello everybody,
> I hope this mailing list isn't already dead=) I tried to implement parser
> generated by ANTLR in IMP, so I implemented some Interfaces, as user's guide
> says: IParseController, ISourcePositionLocator, and some else, then I
> decided to add token coloring and check, do parser works, or not. But when I
> tried to open file with my language's extension, I run into error
> window: "Unable to instantiate parser for language '%LangName%';
> parser-related services will be disabled."
> I tried to set breakpoints at the IParseController's constructor, but it
> looks like IPaseController doesn't even invoked.
>
> Any suggestions? How can I find more information on such error, or, may be,
> what class invokes IParseController?
> --
> Kind regards,
> Anatoly Kondratyev.
>

--
Cheers,
  - Bob
-------------------------------------------------
Robert M. Fuhrer
Research Staff Member
Programming Technologies Dept.
IBM T.J. Watson Research Center

IMP Project Lead (http://www.eclipse.org/imp)
X10: Productivity for High-Performance Parallel Programming (http://x10-lang.org)


_______________________________________________
imp-dev mailing list
imp-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/imp-dev




--
Kind regards,
Anatoly Kondratyev.



--
Kind regards,
Anatoly Kondratyev.