Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Extending XtextBuilder for two DSLs(Extending XtextBuilder for two DSLs)
Extending XtextBuilder for two DSLs [message #1844694] Wed, 22 September 2021 05:28 Go to next message
Virag Purnam is currently offline Virag PurnamFriend
Messages: 135
Registered: June 2014
Senior Member
Hi,

I am trying to extend XtextBuilder for two different DSLs.
I have created two Xtext project for the two different DSLs and extended XtextBuilder in both projects. Now on save it always calls extended class of XtextBuilder of second project. This is irrespective of the resource. (Whether it is from first or second DSL).

My requirement is to call the extended class of XtextBuilder based on file extension. Could you please guide me on this?

Thanks and regards,
Virag
Re: Extending XtextBuilder for two DSLs [message #1844695 is a reply to message #1844694] Wed, 22 September 2021 05:30 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14103
Registered: July 2009
Senior Member
Hi, I cannot follow you. The Xtext builder is shared among all DSLs
Can you explain what and how you were changing the builder


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: Extending XtextBuilder for two DSLs [message #1844696 is a reply to message #1844695] Wed, 22 September 2021 05:42 Go to previous messageGo to next message
Virag Purnam is currently offline Virag PurnamFriend
Messages: 135
Registered: June 2014
Senior Member
Hi Mr. Christian Dietrich,

I have just added the example below. In this case it always calls the MyDsl2Builder. Even if I am saving the resource which is from MyDsl1. I have created two xtext projects with MyDsl1 grammar and MyDsl2 grammar. Requirement was to create two separate xtext projects for both the grammar.

MyDsl1Builder.java
public class MyDsl1Builder extends XtextBuilder {
	
	@Override    
	protected IProject[] build(final int kind, Map args, IProgressMonitor monitor) throws CoreException {
		// I want to add my custom implementation
		return super.build(kind, args, monitor);
	}

}

MyDsl2Builder.java
public class MyDsl2Builder extends XtextBuilder {
	
	@Override    
	protected IProject[] build(final int kind, Map args, IProgressMonitor monitor) throws CoreException {
		// I want to add my custom implementation
		return super.build(kind, args, monitor);
	}

}
Re: Extending XtextBuilder for two DSLs [message #1844700 is a reply to message #1844696] Wed, 22 September 2021 08:30 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14103
Registered: July 2009
Senior Member
This does not work. The builder is shared globally with all dsls
Thus my question what you want to customize


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

[Updated on: Wed, 22 September 2021 09:39]

Report message to a moderator

Re: Extending XtextBuilder for two DSLs [message #1844722 is a reply to message #1844700] Thu, 23 September 2021 05:02 Go to previous messageGo to next message
Virag Purnam is currently offline Virag PurnamFriend
Messages: 135
Registered: June 2014
Senior Member
Thanks Mr. Christian Dietrich.
I want to perform some operation before the build. Now I got that we can not do that using 'builder'. I will use 'EditorCallBack' for the same.

Thanks and regards,
Virag
Re: Extending XtextBuilder for two DSLs [message #1844725 is a reply to message #1844722] Thu, 23 September 2021 06:53 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14103
Registered: July 2009
Senior Member
can you please be more specific. maybe there is already an extension point fo that

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: Extending XtextBuilder for two DSLs [message #1844743 is a reply to message #1844725] Thu, 23 September 2021 17:43 Go to previous messageGo to next message
Virag Purnam is currently offline Virag PurnamFriend
Messages: 135
Registered: June 2014
Senior Member
Hi Mr. Christian Dietrich,

When user creates a new dsl project, user can select the template 'HelloWorld' project. On click of 'Finish' button it opens the file in editor. (Similar as Java).

Now before the file opens in an editor, I want to read few libraries (plain text file without extension) which are included in the resource. I want to read that and populate those in outline view along with the variable definitions presents in resource.

When user creates a new project, it triggers 'Complete Build' and I was trying to write code there. (Sounds bad idea though).

Could you please suggest the correct approach to achieve this?

Thanks and regards,
Virag



Re: Extending XtextBuilder for two DSLs [message #1844744 is a reply to message #1844743] Thu, 23 September 2021 17:51 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14103
Registered: July 2009
Senior Member
shouldnt you then adapt the outline and or the wizard?

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: Extending XtextBuilder for two DSLs [message #1844848 is a reply to message #1844744] Tue, 28 September 2021 05:40 Go to previous message
Virag Purnam is currently offline Virag PurnamFriend
Messages: 135
Registered: June 2014
Senior Member
Yes Mr. Christian Dietrich,

I will try that out and update here.

Thanks and regards,
Virag
Previous Topic:Best Practise for autocompletion during syntax errors
Next Topic:Change StringConcatenation for grammar tests
Goto Forum:
  


Current Time: Fri Dec 03 17:24:18 GMT 2021

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

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

Back to the top