update from 2.1 to 2.6.2 problem [message #1404900] |
Wed, 06 August 2014 05:26 |
Silvia Gotta Messages: 13 Registered: April 2013 |
Junior Member |
|
|
Hello,
I'm porting my plugin source code from xtext 2.1 to 2.6.2.
Specifically, I'd like to replace the following code because class EclipseResourceFileSystemAccess has been deprecated:
EclipseResourceFileSystemAccess fsa = new EclipseResourceFileSystemAccess();
fsa.setRoot(project.getWorkspace().getRoot());
fsa.setOutputPath(filePathF);
for (Resource r : model.getResources()) {
generator.doGenerate(fileNameF, functionName, subfunctionName, r, fsa);
}
My new code is very similar:
EclipseResourceFileSystemAccess2 fsa2 = new EclipseResourceFileSystemAccess2();
fsa2.setOutputPath(filePathF);
fsa2.setMonitor(monitor);
fsa2.setProject(project);
for (Resource r : model.getResources()) {
generator.doGenerate(fileNameF, functionName, subfunctionName, r, fsa2);
}
Unfortunately the new code rises a NullPointer Exception in EclipseResourceFileSystemAccess2.generateFile(String fileName, String outputName, CharSequence contents).
This is the stack trace:
java.lang.reflect.InvocationTargetException
at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:423)
at org.eclipse.jface.dialogs.ProgressMonitorDialog.run(ProgressMonitorDialog.java:527)
at org.eclipse.ui.internal.progress.ProgressMonitorJobsDialog.run(ProgressMonitorJobsDialog.java:284)
at org.eclipse.ui.internal.progress.ProgressManager$3.run(ProgressManager.java:983)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.ui.internal.progress.ProgressManager.busyCursorWhile(ProgressManager.java:1018)
at org.eclipse.ui.internal.progress.ProgressManager.busyCursorWhile(ProgressManager.java:993)
at com.nttdata.ansaldosts.wslmplugin.report.handlers.GenReportDetailsHandler.execute(GenReportDetailsHandler.java:125)
at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:294)
at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:90)
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.ui.workbench.renderers.swt.HandledContributionItem.executeItem(HandledContributionItem.java:825)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.handleWidgetSelection(HandledContributionItem.java:701)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.access$6(HandledContributionItem.java:685)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem$4.handleEvent(HandledContributionItem.java:613)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4353)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1061)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4172)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3761)
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.ui.internal.Workbench$5.run(Workbench.java:636)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:579)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:135)
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:382)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:236)
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: java.lang.NullPointerException
at org.eclipse.xtext.builder.EclipseResourceFileSystemAccess2.getTraceFile(EclipseResourceFileSystemAccess2.java:483)
at org.eclipse.xtext.builder.EclipseResourceFileSystemAccess2.generateFile(EclipseResourceFileSystemAccess2.java:173)
at org.eclipse.xtext.generator.AbstractFileSystemAccess.generateFile(AbstractFileSystemAccess.java:97)
at com.nttdata.ansaldosts.wslmplugin.report.template.GenReportDetails.generateReport(GenReportDetails.java:69)
at com.nttdata.ansaldosts.wslmplugin.report.template.GenReportDetails.doGenerate(GenReportDetails.java:47)
at com.nttdata.ansaldosts.wslmplugin.report.template.GenReportDetails.doGenerate(GenReportDetails.java:43)
at com.nttdata.ansaldosts.wslmplugin.report.handlers.GenReportDetailsHandler$1.run(GenReportDetailsHandler.java:156)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)
The null pointer is due to the fact that fileBasedTraceInformation (in EclipseResourceFileSystemAccess2) is not initialized.
Can anybody suggest me where is my mistake?
Thank you.
Silvia
|
|
|
|
|
|
|
|
|
|
|
Re: update from 2.1 to 2.6.2 problem [message #1737967 is a reply to message #1404972] |
Thu, 14 July 2016 13:40 |
Brandon Lewis Messages: 268 Registered: May 2012 |
Senior Member |
|
|
Thanks for the follow up Christian. For the most part we have this manual invocation of the doGenerate() working now. I'm having some small issues with gettting he context menu on the ProjectExplorer to pop.
We did have to add the following 3 lines of code slightly different from your original blog - but that's expected after 5 years authoring it.
final EclipseResourceFileSystemAccess2 fsa = fileAccessProvider.get();
fsa.setMonitor(new NullProgressMonitor());
fsa.setProject(project);
fsa.setOutputPath(srcGenFolder.getName());
We have other issues with the doGenerate() and when it's getting called in our GUI and command line builds - especially w.r.t. when we are using afterModelLinked() in our subclassed LazyLinker, but that's probably more appropriate for a separate thread.
Thanks and thanks for the original blog post!
[Updated on: Thu, 14 July 2016 13:40] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.07061 seconds