Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to use a custom IAllContainersState
How to use a custom IAllContainersState [message #1836567] Thu, 07 January 2021 16:01 Go to next message
Yannick DAVELUY is currently offline Yannick DAVELUYFriend
Messages: 39
Registered: July 2020
Member
Hi,

In MyDslUIModule I added the following override
	@Override
	public Provider<IAllContainersState> provideIAllContainersState() {
		return Access.<IAllContainersState>contributedProvider(MyDslProjectsState.class);

	}


The MyDslProjectsState class is declared in the ui Plugin.

I have the following guice error when I launch my application :
1) Error injecting method, java.lang.IllegalStateException: Missing contribution for type: mydsl.ui.containers.MyDslProjectsState
  at org.eclipse.xtext.ui.shared.Access$InternalProviderForContribution.inject(Unknown Source)
  at org.eclipse.xtext.service.MethodBasedModule.configure(MethodBasedModule.java:76)



I tried to use the org.eclipse.xtext.ui.shared.sharedStateContributingModule but I don't understand how it works.

Any Hints ?

Yannick
Re: How to use a custom IAllContainersState [message #1836569 is a reply to message #1836567] Thu, 07 January 2021 16:09 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
> I tried to use the org.eclipse.xtext.ui.shared.sharedStateContributingModule but I don't understand how it works.

Simply create a new class that inherits from guices Module interface or one of the subclasses and register it via the extension point

Still wonder what problem zu want to solve


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Thu, 07 January 2021 16:10]

Report message to a moderator

Re: How to use a custom IAllContainersState [message #1836570 is a reply to message #1836569] Thu, 07 January 2021 16:27 Go to previous messageGo to next message
Yannick DAVELUY is currently offline Yannick DAVELUYFriend
Messages: 39
Registered: July 2020
Member
Ok thanks but I already tried this without success.

What I need is to store my dsl files in a plugin projects with the pde nature but without the java nature. Then I would like to get the visibles handles from the project Manifest.

Yannick
Re: How to use a custom IAllContainersState [message #1836571 is a reply to message #1836570] Thu, 07 January 2021 16:37 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Please provide more details what you exactly did

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to use a custom IAllContainersState [message #1836572 is a reply to message #1836571] Thu, 07 January 2021 18:26 Go to previous messageGo to next message
Yannick DAVELUY is currently offline Yannick DAVELUYFriend
Messages: 39
Registered: July 2020
Member
I finally solved the problem, my configure function in MyDslSharedModule was empty...

So in myDsl UI project I created :
The module:
public class MyDslSharedModule extends AbstractModule {

	@Override
	protected void configure() {

		bind(MyDslProjectsState.class);
		bind(MyDslProjectsStateHelper.class);
	}
}


In the MyDslUiModule
public class MyDslUiModuleextends AbstractMyDslUiModule {

	=
	@Override
	public Provider<IAllContainersState> provideIAllContainersState() {
		return Access.<IAllContainersState>contributedProvider(MyDslProjectsState.class);
	}
}



The MyDslProjectState:
public class MyDslProjectsState extends WorkspaceProjectsState {

	@Inject
	private MyDslProjectsStateHelper projectsHelper;

	@Override
	protected String doInitHandle(URI uri) {
		return projectsHelper.initHandle(uri);
	}

	@Override
	protected Collection<URI> doInitContainedURIs(String containerHandle) {
		return projectsHelper.initContainedURIs(containerHandle);
	}

	@Override
	protected List<String> doInitVisibleHandles(String handle) {
		return projectsHelper.initVisibleHandles(handle);
	}

}


And the Helper
public class MyDslProjectsStateHelper extends WorkspaceProjectsStateHelper {

}


And the plugin.xml
   <extension
         point="org.eclipse.xtext.ui.shared.sharedStateContributingModule">
      <module
            class="mydsl.MyDslSharedModule">
      </module>
   </extension>



I have to implements the MyDslProjectsStateHelper to retrieve visible handlers from the manifest

[Updated on: Thu, 07 January 2021 18:26]

Report message to a moderator

Re: How to use a custom IAllContainersState [message #1836577 is a reply to message #1836572] Thu, 07 January 2021 21:27 Go to previous messageGo to next message
Yannick DAVELUY is currently offline Yannick DAVELUYFriend
Messages: 39
Registered: July 2020
Member
The existing WorkspaceProjectsStateHelper collect the referenced projects and it already include the projects from the Manifest via org.eclipse.pde.internal.core.DynamicPluginProjectReferences.

The problem is that when the Manifest is updated, the index is not rebuilt.

I overrode the WorkspaceProjectsState.isAffectingContainerState like this :
	private final Path manifestPath = new Path("META-INF/MANIFEST.MF");

	@Override
	protected boolean isAffectingContainerState(IResourceDelta delta) {
		if (manifestPath.equals(delta.getProjectRelativePath())) {
			delta.getResource().getProject().clearCachedDynamicReferences();
			return true;
		}
		return super.isAffectingContainerState(delta);
	}


Then I have to manually trigger a project clean in order to rebuild the dsl files inside the project.

How to trigger a clean/rebuild of the xtext index ?

Yannick
Re: How to use a custom IAllContainersState [message #1836581 is a reply to message #1836577] Fri, 08 January 2021 06:40 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
the manifest change should lead to a classpath change which should lead to a rebuild.
you may start debug around BuilderDeltaConverter, ProjectClasspathChangeListener, JavaProjectClasspathChangeAnalyzer

otherwise this may be a bug in PDE !? if clearCachedDynamicReferences needs to be called manually

and or Xtext if we dont treat the classpath change somewhere else


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Fri, 08 January 2021 06:48]

Report message to a moderator

Re: How to use a custom IAllContainersState [message #1836582 is a reply to message #1836581] Fri, 08 January 2021 07:08 Go to previous messageGo to next message
Yannick DAVELUY is currently offline Yannick DAVELUYFriend
Messages: 39
Registered: July 2020
Member
Hi Christian,

In my case I don't have a classpath because I don't have the java nature (just PDE and manifestBuiler).

I have to call clearCachedDynamicReferences manually and then to forget the last built state to make it works.
			final XtextBuilder builder = BuildManagerAccess.findBuilder(delta.getResource().getProject());
			if (builder != null) {
				builder.forgetLastBuiltState();
			}


I think that there is a bug somewhere but I couln't say if it is on PDE or Xtext side.

Thanks for your help
Re: How to use a custom IAllContainersState [message #1836590 is a reply to message #1836582] Fri, 08 January 2021 09:03 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
can you please create an issue at https://github.com/eclipse/xtext-eclipse/
with details on your project setup and changes you do


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Type library not found with StadaloneSetup
Next Topic:Xtend Maven issues after upgrading to Java 9
Goto Forum:
  


Current Time: Thu Apr 18 12:13:20 GMT 2024

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

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

Back to the top