Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Integrating into Eclipse e4 application
Integrating into Eclipse e4 application [message #1707479] Sat, 05 September 2015 02:13 Go to next message
Eclipse UserFriend
Hi,

i have a pure Eclipse e4 application. I wanted to integrate my DSL into the application. All needed plugins are loaded and the plugin for my own dsl is also loaded.

Now I am trying to read a DSL file and get the AST for it. But the problem already starts with "How to get a parser instance?". I tried the approach from the FAQ.

                StandaloneSetup standaloneSetup = new StandaloneSetup();
		// standaloneSetup.setPlatformUri(Platform.getInstallLocation().getURL().getPath());
		standaloneSetup.setPlatformUri("/home/mihael/devel/workspace-dsl/");
		
		Injector injector = new CLStandaloneSetupGenerated().createInjectorAndDoEMFRegistration();
		resourceSet = injector.getInstance(XtextResourceSet.class);
		resourceSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);


But to what should the platform URI be set?

No matter what I do the content type to factory map from the resource set is always empty (and it probably shouldn't be?).

Any attempt to parse a file results in

org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Content ist nicht zulässig in Prolog.
	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:195)
	at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:261)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1518)
	at miworkplace.ui.editor.cl.ClEditor.buildAst(ClEditor.java:113)
	at miworkplace.ui.editor.cl.ClEditor.receiveDocument(ClEditor.java:106)
	at miworkplace.ui.editor.SourceContentLoader.run(SourceContentLoader.java:94)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at miworkplace.ui.editor.RemoteEditor.load(RemoteEditor.java:459)
	at miworkplace.ui.explorer.api.AbstractOpenHandler.open(AbstractOpenHandler.java:139)
	at miworkplace.ui.explorer.api.AbstractOpenHandler.open(AbstractOpenHandler.java:41)
	at miworkplace.ui.editor.cl.handler.OpenWithClEditorHandler.execute(OpenWithClEditorHandler.java:50)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:55)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:247)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:229)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:132)
	at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:149)
	at org.eclipse.core.commands.Command.executeWithChecks(Command.java:499)
	at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
	at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:210)
	at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:196)
	at miworkplace.ui.SourceMemberDoubleClickProvider.execute(SourceMemberDoubleClickProvider.java:85)
	at miworkplace.ui.explorer.QsysViewer$2.doubleClick(QsysViewer.java:126)
	at org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredViewer.java:831)
	at org.eclipse.jface.util.SafeRunnable$1.run(SafeRunnable.java:131)
	at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:178)
	at org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(StructuredViewer.java:828)
	at org.eclipse.jface.viewers.AbstractTreeViewer.handleDoubleSelect(AbstractTreeViewer.java:1472)
	at org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSelected(StructuredViewer.java:1237)
	at org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEvent(OpenStrategy.java:252)
	at org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.java:249)
	at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:311)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4454)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1388)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3799)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3409)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1151)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148)
	at org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:164)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
Caused by: org.xml.sax.SAXParseExceptionpublicId: remotefile://VGVzdA==/QSYS.LIB/MSCHMIDT.LIB/SOURCES.FILE/INSTALL.MBR.cl; systemId: remotefile://VGVzdA==/QSYS.LIB/MSCHMIDT.LIB/SOURCES.FILE/INSTALL.MBR.cl; lineNumber: 1; columnNumber: 1; Content ist nicht zulässig in Prolog.
	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198)
	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177)
	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:441)
	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:368)
	at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1437)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:999)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:648)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:332)
	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:175)
	... 57 more


Seems to me it uses a default parser which of course doesn't work.

Any help is appreciated.

Thanx

Mihael
Re: Integrating into Eclipse e4 application [message #1707670 is a reply to message #1707479] Tue, 08 September 2015 08:50 Go to previous messageGo to next message
Eclipse UserFriend
.... so is your editor written by hand? The editor by default uses not
the core parser but the one from the UI-Bundle.

Tom

On 05.09.15 08:13, Mihael Schmidt wrote:
> Hi,
>
> i have a pure Eclipse e4 application. I wanted to integrate my DSL into
> the application. All needed plugins are loaded and the plugin for my own
> dsl is also loaded.
>
> Now I am trying to read a DSL file and get the AST for it. But the
> problem already starts with "How to get a parser instance?". I tried the
> approach from the FAQ.
>
> StandaloneSetup standaloneSetup = new
> StandaloneSetup();
> //
> standaloneSetup.setPlatformUri(Platform.getInstallLocation().getURL().getPath());
>
>
> standaloneSetup.setPlatformUri("/home/mihael/devel/workspace-dsl/");
>
> Injector injector = new
> CLStandaloneSetupGenerated().createInjectorAndDoEMFRegistration();
> resourceSet = injector.getInstance(XtextResourceSet.class);
> resourceSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL,
> Boolean.TRUE);
>
> But to what should the platform URI be set?
>
> No matter what I do the content type to factory map from the resource
> set is always empty (and it probably shouldn't be?).
>
> Any attempt to parse a file results in
>
> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Content ist
> nicht zulässig in Prolog.
> at
> org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:195)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:261)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1518)
>
> at miworkplace.ui.editor.cl.ClEditor.buildAst(ClEditor.java:113)
> at miworkplace.ui.editor.cl.ClEditor.receiveDocument(ClEditor.java:106)
> at
> miworkplace.ui.editor.SourceContentLoader.run(SourceContentLoader.java:94)
> at
> org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
> at miworkplace.ui.editor.RemoteEditor.load(RemoteEditor.java:459)
> at
> miworkplace.ui.explorer.api.AbstractOpenHandler.open(AbstractOpenHandler.java:139)
>
> at
> miworkplace.ui.explorer.api.AbstractOpenHandler.open(AbstractOpenHandler.java:41)
>
> at
> miworkplace.ui.editor.cl.handler.OpenWithClEditorHandler.execute(OpenWithClEditorHandler.java:50)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>
> at java.lang.reflect.Method.invoke(Method.java:606)
> at
> org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:55)
>
> at
> org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:247)
>
> at
> org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:229)
> at
> org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:132)
>
> at
> org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:149)
>
> at
> org.eclipse.core.commands.Command.executeWithChecks(Command.java:499)
> at
> org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
>
> at
> org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:210)
>
> at
> org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:196)
>
> at
> miworkplace.ui.SourceMemberDoubleClickProvider.execute(SourceMemberDoubleClickProvider.java:85)
>
> at
> miworkplace.ui.explorer.QsysViewer$2.doubleClick(QsysViewer.java:126)
> at
> org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredViewer.java:831)
> at org.eclipse.jface.util.SafeRunnable$1.run(SafeRunnable.java:131)
> at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:178)
> at
> org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(StructuredViewer.java:828)
>
> at
> org.eclipse.jface.viewers.AbstractTreeViewer.handleDoubleSelect(AbstractTreeViewer.java:1472)
>
> at
> org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSelected(StructuredViewer.java:1237)
>
> at
> org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEvent(OpenStrategy.java:252)
>
> at org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.java:249)
> at
> org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:311)
> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
> at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4454)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1388)
> at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3799)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3409)
> at
> org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1151)
>
> at
> org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
>
> at
> org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032)
>
> at
> org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148)
>
> at
> org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:164)
>
> at
> org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>
> at java.lang.reflect.Method.invoke(Method.java:606)
> at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
> at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
> at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
> Caused by: org.xml.sax.SAXParseExceptionpublicId:
> remotefile://VGVzdA==/QSYS.LIB/MSCHMIDT.LIB/SOURCES.FILE/INSTALL.MBR.cl;
> systemId:
> remotefile://VGVzdA==/QSYS.LIB/MSCHMIDT.LIB/SOURCES.FILE/INSTALL.MBR.cl;
> lineNumber: 1; columnNumber: 1; Content ist nicht zulässig in Prolog.
> at
> com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198)
>
> at
> com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177)
>
> at
> com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:441)
>
> at
> com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:368)
>
> at
> com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1437)
>
> at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:999)
>
> at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
>
> at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
>
> at
> com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
>
> at
> com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
>
> at
> com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
>
> at
> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
>
> at
> com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:648)
>
> at
> com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:332)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:175)
> ... 57 more
>
>
> Seems to me it uses a default parser which of course doesn't work.
>
> Any help is appreciated.
>
> Thanx
>
> Mihael
>
Re: Integrating into Eclipse e4 application [message #1707719 is a reply to message #1707670] Tue, 08 September 2015 13:56 Go to previous messageGo to next message
Eclipse UserFriend
The editor is the SourceViewer class from the JFace library.

I have created an Xtext project with Eclipse DSL Tools distro exported the plugin (the one with the grammar) and added it to the target platform.

My plan is to call my classes from my Xtext project in my ReconcilingStrategy class and build the AST there. But I can't get it to work. It is not clear for my how to set things up outside of an Eclipse 3.x application. The entry in the FAQ doesn't really explain things and doesn't work for me.


Thomas Schindl wrote on Tue, 08 September 2015 14:50
.... so is your editor written by hand? The editor by default uses not
the core parser but the one from the UI-Bundle.

Tom

[Updated on: Tue, 08 September 2015 13:57] by Moderator

Re: Integrating into Eclipse e4 application [message #1708280 is a reply to message #1707719] Tue, 15 September 2015 03:23 Go to previous messageGo to next message
Eclipse UserFriend
I did a short presentation this year at XtextCon on e4+JavaFX+Xtext you
can find the slides at
http://tomsondev.bestsolution.at/2015/05/20/code-editors-in-general-with-javafx/
which also points to a source code repo.

The code is for e4+JavaFX but I think you can learn the code how to set
things up to get content assist up and running.

Please note that this uses the 2.9-stream from Xtext!

Tom

On 08.09.15 19:56, Mihael Schmidt wrote:
> The editor a SourceViewer instance from the JFace library.
>
> I have created an Xtext project with Eclipse DSL Tools distro exported
> the plugin (the one with the grammar) and added it to the target platform.
>
> My plan is to call my classes from my Xtext project in my
> ReconcilingStrategy class and build the AST there. But I can't get it to
> work. It is not clear for my how to set things up outside of an Eclipse
> 3.x application. The entry in the FAQ doesn't really explain things and
> doesn't work for me.
>
>
> Thomas Schindl wrote on Tue, 08 September 2015 14:50
>> .... so is your editor written by hand? The editor by default uses not
>> the core parser but the one from the UI-Bundle.
>>
>> Tom
>
Re: Integrating into Eclipse e4 application [message #1708286 is a reply to message #1708280] Tue, 15 September 2015 03:48 Go to previous messageGo to next message
Eclipse UserFriend
Many thanks. I will look into this.

Best Regards

Mihael
Re: Integrating into Eclipse e4 application [message #1708696 is a reply to message #1708286] Fri, 18 September 2015 17:35 Go to previous message
Eclipse UserFriend
The most common reason for this error is when the URI of the resource doesn't end with the file extension of your language.
Previous Topic:local scope problem
Next Topic:Efficiently accessing attributes in multi-line template using Xtend
Goto Forum:
  


Current Time: Wed Oct 29 20:56:29 EDT 2025

Powered by FUDForum. Page generated in 0.03817 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top