Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Issue deleting element from a list with multiple items
Issue deleting element from a list with multiple items [message #1707824] Wed, 09 September 2015 14:29 Go to next message
Luis De Bello is currently offline Luis De BelloFriend
Messages: 95
Registered: January 2015
Member
Hi guys,

I am trying to delete the last element from my model but after deleting the last element I thought that the "new last element" would be without the comma but does is not happening Sad

MultipleKeyValuePairObj:
	{MultipleKeyValuePairObj} "{" (elements+=KeyValuePair ("," elements+= KeyValuePair?)*)? "}";

Example:
Initial State:
{
    Field01: "SimpleValue01",
    Field02: "SimpleValue02"
}

Expected Final State:
{
    Field01: "SimpleValue01"
}

Current Final State:
{
    Field01: "SimpleValue01",
}


Current code to remove last element
public void process(XtextResource state) throws Exception {
        EObject eObject = state.getEObject(uriFragment);
        EObject eContainer = eObject.eContainer();
        if (eContainer instanceof MultipleKeyValuePairObj) {
            MultipleKeyValuePairObj multipleKeyValuePairObj = (MultipleKeyValuePairObj) eContainer;
            EList< KeyValuePair> elements = multipleKeyValuePairObj.getElements();
            elements.remove(eObject);
        }
    }


Do you have any idea or tip to solve my issue?

Thanks in advance

Best regards,
Luis

[Updated on: Wed, 09 September 2015 14:31]

Report message to a moderator

Re: Issue deleting element from a list with multiple items [message #1707829 is a reply to message #1707824] Wed, 09 September 2015 14:54 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
can you file a bug for that?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Issue deleting element from a list with multiple items [message #1707832 is a reply to message #1707829] Wed, 09 September 2015 15:01 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
P.S:
is the (inner) questionmark in your grammar intended?

MultipleKeyValuePairObj:
{MultipleKeyValuePairObj} "{" (elements+=KeyValuePair ("," elements+= KeyValuePair?)*)? "}";

vs

MultipleKeyValuePairObj:
{MultipleKeyValuePairObj} "{" (elements+=KeyValuePair ("," elements+= KeyValuePair)*)? "}";


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Issue deleting element from a list with multiple items [message #1707839 is a reply to message #1707832] Wed, 09 September 2015 15:45 Go to previous messageGo to next message
Luis De Bello is currently offline Luis De BelloFriend
Messages: 95
Registered: January 2015
Member
Hi Christian,

Thanks for your prompt response

The inner question mark is on purpose, because that was the only way to get the autocompletion in the following case

Current behaviour using "?"
Result: {
Field01: "SimpleValue",
@CursorHere@
}

If use content assist here I get Field02, Field03 etc which is the structure for my output, we use the proposal provider to populate this list of values depending on the currentModel
In this case I received the model which contains Field01 and I can populate a list for that level, however If I remove the "?" from my grammar I get the currentModel as the object which is container for "result"

Regards,
Luis
Re: Issue deleting element from a list with multiple items [message #1707841 is a reply to message #1707839] Wed, 09 September 2015 15:59 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
hmmm

can you try this one?

MultipleKeyValuePairObj:
	{MultipleKeyValuePairObj} "{" (elements+=KeyValuePair ((=>"," elements+= KeyValuePair)|",")*)? "}";
	


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Issue deleting element from a list with multiple items [message #1707849 is a reply to message #1707841] Wed, 09 September 2015 17:12 Go to previous message
Luis De Bello is currently offline Luis De BelloFriend
Messages: 95
Registered: January 2015
Member
Hi Christian,

I have just tried and it works great, the only thing was that I have to change => for -> because using => I got an exception during the serialisation process to convert Xtext model to text.

{MultipleKeyValuePairObj} "{" (elements+= KeyValuePair ((->"," elements+= KeyValuePair)|",")*)? "}";

Thanks for your help

Best regards,
Luis
Previous Topic:Scoping interrupts Content-Assist Test
Next Topic:Adding to the import list in the generated code
Goto Forum:
  


Current Time: Thu Apr 25 11:59:08 GMT 2024

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

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

Back to the top