Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext : shouldgenerate
Xtext : shouldgenerate [message #1764419] Mon, 29 May 2017 14:53 Go to next message
Pascal Lacabanne is currently offline Pascal LacabanneFriend
Messages: 17
Registered: November 2016
Junior Member
Hello,

I have a new problem.
I want to launch the function doGenerate even if there are errors.
I found this interface which blocks me.
@Beta
@ImplementedBy(OnlyWithoutErrors)
interface IShouldGenerate {
	
	/**
	 * whether code should be generated for this resource.
	 */
	def boolean shouldGenerate(Resource resource, CancelIndicator cancelIndicator);
	
	@Beta
	static class OnlyWithoutErrors implements IShouldGenerate {
		
		@Inject IResourceValidator resourceValidator
		
		override shouldGenerate(Resource resource, CancelIndicator cancelIndicator) {
			if (!resource.errors.isEmpty)
				return false
			val issues = resourceValidator.validate(resource, CheckMode.NORMAL_AND_FAST, cancelIndicator)
			return !issues.exists[severity == Severity.ERROR]
		}
		
	}
	@Beta
	static class Always implements IShouldGenerate {
		
		override shouldGenerate(Resource resource, CancelIndicator cancelIndicator) {
			return true
		}
		
	}
}


I would like to use the Always implementation.
How I have to configure it (in GenerateMyDsl.mwe2) ?

Thank you
Re: Xtext : shouldgenerate [message #1764421 is a reply to message #1764419] Mon, 29 May 2017 14:58 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14062
Registered: July 2009
Senior Member
you don't you simply add a binding to YourDslModule

def Class<? extends IShouldGenerate> bindIShouldGenerate() {
return CustomShouldGenerate
}

and/ or YourDslUiModule

override Class<? extends IShouldGenerate> bindIShouldGenerate() {
return CustomEclipseBasedShouldGenerate
}


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext : shouldgenerate [message #1764423 is a reply to message #1764421] Mon, 29 May 2017 15:12 Go to previous messageGo to next message
Pascal Lacabanne is currently offline Pascal LacabanneFriend
Messages: 17
Registered: November 2016
Junior Member
Thank your for your prompt response.
That works.

Do you konw where I can find Xtext's documentation, please ?
Thank you
Re: Xtext : shouldgenerate [message #1764427 is a reply to message #1764423] Mon, 29 May 2017 15:27 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14062
Registered: July 2009
Senior Member
here https://www.eclipse.org/Xtext/documentation/index.html
and here is the dep. injection part: https://www.eclipse.org/Xtext/documentation/302_configuration.html#dependency-injection


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext : shouldgenerate [message #1764462 is a reply to message #1764427] Tue, 30 May 2017 08:16 Go to previous message
Pascal Lacabanne is currently offline Pascal LacabanneFriend
Messages: 17
Registered: November 2016
Junior Member
Thanks
Previous Topic:Xtext newbie - ID with array declaration
Next Topic:UtilsMethods?
Goto Forum:
  


Current Time: Sun Sep 19 19:15:35 GMT 2021

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

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

Back to the top