Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to display contents of Xtext index (builder.state)?
How to display contents of Xtext index (builder.state)? [message #1173365] Wed, 06 November 2013 13:19 Go to next message
Tim Geisler is currently offline Tim GeislerFriend
Messages: 47
Registered: July 2009
Member
Hi,

how to display the contents of the Xtext index in an editor in a human-readable form? (I am using 2.4.3)

The file builder.state (in .metadata/.plugins/org.eclipse.xtext.builder) is now a binary file. In former times this was an XML file which made it quite easy to view and discover problems with global scoping.

Best regards,

Tim
Re: How to display contents of Xtext index (builder.state)? [message #1173560 is a reply to message #1173365] Wed, 06 November 2013 15:59 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

cant you bind a changed PersistedStateProvider through the org.eclipse.xtext.ui.shared.overridingGuiceModule extension point?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to display contents of Xtext index (builder.state)? [message #1173661 is a reply to message #1173560] Wed, 06 November 2013 17:22 Go to previous messageGo to next message
Tim Geisler is currently offline Tim GeislerFriend
Messages: 47
Registered: July 2009
Member
Hi Christian,

of course this will work, but it seems to me not very convenient to have to change the index-persisting "machinery" to just be able to read this file. I thought there might be some clever editor which can be used through "Open with ...".

Best regards,

Tim
Re: How to display contents of Xtext index (builder.state)? [message #1173720 is a reply to message #1173661] Wed, 06 November 2013 18:14 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

i dont know of such an editor. maybe you should file a bug agains sample ecore model editor etc...


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to display contents of Xtext index (builder.state)? [message #1173742 is a reply to message #1173720] Wed, 06 November 2013 18:36 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
P.S:

maybe a simple transposition helps

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl;
import org.eclipse.xtext.builder.builderState.BuilderStatePackage;
import org.eclipse.xtext.builder.builderState.EMFBasedPersister;


@SuppressWarnings("restriction")
public class Main {
	
	public static void main(String[] args) {
		Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("xmi", new XMIResourceFactoryImpl());
		EPackage.Registry.INSTANCE.put(BuilderStatePackage.eNS_URI, BuilderStatePackage.eINSTANCE);
		Resource resource = new EMFBasedPersister().getFactory().createResource(URI.createURI("builder.state"));
		Map options = new HashMap<>();
		options.put(XMIResourceImpl.OPTION_BINARY, true);
		try {
			resource.load(options );
			System.out.println(resource);
			Resource rs2 = new ResourceSetImpl().createResource(URI.createURI("out.xmi"));
			rs2.getContents().addAll(resource.getContents());
			rs2.save(null);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	
	

}


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to display contents of Xtext index (builder.state)? [message #1174708 is a reply to message #1173742] Thu, 07 November 2013 09:11 Go to previous message
Tim Geisler is currently offline Tim GeislerFriend
Messages: 47
Registered: July 2009
Member
Hi Christian,

thanks a lot! Your code works out of the box. I will file a bug against the sample ecore model editor.

Best regards,

Tim
Previous Topic:[ContentAssistant] Propose type involving ImportManager
Next Topic:Replace object after linking
Goto Forum:
  


Current Time: Fri Apr 19 08:51:52 GMT 2024

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

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

Back to the top