Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [LSP] IOutputConfigurationProvider is not working with LSP(But works with Eclipse)
[LSP] IOutputConfigurationProvider is not working with LSP [message #1771044] Mon, 21 August 2017 12:52 Go to next message
Krzysztof Drozd is currently offline Krzysztof DrozdFriend
Messages: 11
Registered: July 2017
Location: Amsterdam
Junior Member
Hi,

I'll start with a question: What I'm missing for LSP as IOutputConfigurationProvider works fine with Eclipse and not with LSP?

I would like to generate my files to 'output' directory instead of 'src-out'.

So I implemented IOutputConfigurationProvider like this:




import static org.eclipse.xtext.xbase.lib.CollectionLiterals.newHashSet;

import java.util.Set;

import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.xtext.generator.IFileSystemAccess;
import org.eclipse.xtext.generator.IOutputConfigurationProvider;
import org.eclipse.xtext.generator.OutputConfiguration;

public class DSDOutputConfigurationProvider implements IOutputConfigurationProvider {

	public static final String GEN_DSD_OUTPUT = "output/";

	@Override
	public Set<OutputConfiguration> getOutputConfigurations() {	
		OutputConfiguration dsdOutput = new OutputConfiguration(IFileSystemAccess.DEFAULT_OUTPUT);
		dsdOutput.setDescription("Output folder");
		dsdOutput.setOutputDirectory(GEN_DSD_OUTPUT);
		dsdOutput.setOverrideExistingResources(true);
		dsdOutput.setCreateOutputDirectory(true);
		dsdOutput.setCleanUpDerivedResources(true);
		dsdOutput.setSetDerivedProperty(true);
		dsdOutput.setInstallDslAsPrimarySource(true);
		
		return newHashSet(dsdOutput);
	}

	
	public Set<OutputConfiguration> getOutputConfigurations(Resource context) {
		return this.getOutputConfigurations();
	}

	public Set<OutputConfiguration> getOutputConfigurations(ResourceSet context) {
		return this.getOutputConfigurations();
	}

}


With this binding in DLSRuntimeModule:
	override configure(Binder binder) {
		super.configure(binder);
		binder.bind(IOutputConfigurationProvider).to(DSDOutputConfigurationProvider).in(Singleton);
	}



And it works fine when I'm using Eclipse. But when I use it with VSCode as LSP files are still generated to 'src-out'


Thanks
Krzysiek
Re: [LSP] IOutputConfigurationProvider is not working with LSP [message #1771091 is a reply to message #1771044] Mon, 21 August 2017 20:27 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 11594
Registered: July 2009
Senior Member
afaik you need to bind to IContextualOutputConfigurationProvider



Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: [LSP] IOutputConfigurationProvider is not working with LSP [message #1771201 is a reply to message #1771091] Tue, 22 August 2017 20:34 Go to previous message
Krzysztof Drozd is currently offline Krzysztof DrozdFriend
Messages: 11
Registered: July 2017
Location: Amsterdam
Junior Member
It works :)

Thank you very much!


Thanks
Krzysiek
Previous Topic:Exclude Keyword from ID in specific Context
Next Topic:SecurityException when I use my modified org.eclipse.xtext to run "Generate Xtext Artifacts&
Goto Forum:
  


Current Time: Fri Jan 19 01:47:21 GMT 2018

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

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