How can I add xText editor to Eclipse (e4) RCP Application?

喜欢而已 提交于 2019-12-07 17:16:56

问题


I've already made a xtext editor (2.5). I try to use this editor in a part in my RCP application.

I use this code:

Injector injector = MyDslActivator.getInstance().getInjector(MyDslActivator.XTEXT_DSL_MYDSL);
EmbeddedEditorFactory factory = injector.getInstance(EmbeddedEditorFactory.class);
editor = factory.newEditor(resourceProvider).showErrorAndWarningAnnotations().withParent(container);

But I got an error

java.lang.LinkageError: loader constraint violation: loader (instance of org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader) previously initiated loading for a different type with name "com/google/inject/Injector"

UPD1

The bundle "eclipse.m2e.maven.runtime" has the package "org.google.inject" with another version. The solution was exclude this bundle from the project.

But now I got new error.

Caused by: java.lang.NullPointerException
at org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorActions.initialize(EmbeddedEditorActions.java:124)
at org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorActions.<init>(EmbeddedEditorActions.java:119)
at org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorActions$Factory.createActions(EmbeddedEditorActions.java:63)
at org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory$Builder.initializeActions(EmbeddedEditorFactory.java:397)
at org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory$Builder.withParent(EmbeddedEditorFactory.java:233)

It happend because the google injector doesn't inject IWorkbench into EmbeddedEditorActions.Factory.

I haven't idea how to fix it. The e4 application has org.eclipse.e4.ui.workbench.IWorkbench, bot doesn't have org.eclipse.ui.IWorkbench.


回答1:


You have to make sure that your RCP contains the bundle com.google.inject only once. Somehow it was loaded in two different versions and both were made available to your DSL plugin.



来源:https://stackoverflow.com/questions/22242845/how-can-i-add-xtext-editor-to-eclipse-e4-rcp-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!