Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to specify an array value in mwe2
How to specify an array value in mwe2 [message #1772598] Tue, 12 September 2017 22:19 Go to next message
Waqas Ilyas is currently offline Waqas IlyasFriend
Messages: 65
Registered: July 2009
Member
So if my fragment class has a String array data member, or an ArrayList<String> data member, how do I initialize it in mwe2?

for example:
mwe2...
fragment = MyFragment {
	myList = ArrayList {
		// ?????
	}
}
...

fragment...
class MyFragment extends AbstractXtextGeneratorFragment {
	@Accessors ArrayList<String> myList
....
}


I can't seem to find the syntax for filling the ArrayList. Or the only way is to create addMyListItem(String i) method?
Re: How to specify an array value in mwe2 [message #1772609 is a reply to message #1772598] Wed, 13 September 2017 04:46 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 11361
Registered: July 2009
Senior Member
You usually add a method addXxxx
And the do xxxx = "a" xxxx="b" in the workflow

you might have a look at this hidden treasure that was removed for whyever from the main xtext doc (maybe cause it parially outdated, i dont know)

https://eclipse.org/Xtext/documentation/306_mwe2.html


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com

[Updated on: Wed, 13 September 2017 05:05]

Report message to a moderator

Re: How to specify an array value in mwe2 [message #1772611 is a reply to message #1772609] Wed, 13 September 2017 04:57 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 11361
Registered: July 2009
Senior Member
example:

validator = {
composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
composedCheck = "bla.blubb.Validator"
}

val List<String> composedChecks = newArrayList

/**
* Adds a validator that is to be executed additionally.
*
* @param composedCheckValidator
* name of a class extending {@link AbstractDeclarativeValidator}
*/
def void addComposedCheck(String composedCheckValidator) {
composedChecks += composedCheckValidator
}


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Previous Topic:How to get images from other plug-in using PluginImageHelper
Next Topic:tycho question. postpone xtend source code generation
Goto Forum:
  


Current Time: Mon Nov 20 13:27:09 GMT 2017

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

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