|
|
|
|
|
Re: Add an ID (hidden) in the metamodel associated with the xtext grammar [message #1831616 is a reply to message #1831574] |
Tue, 25 August 2020 09:58 |
Georgiana Ecobici Messages: 23 Registered: July 2019 |
Junior Member |
|
|
Is there a way in xtext content assist to know which of the proposals was selected?
In case there are duplicated names I need to distinguish based on id, in content assist the name is filled (the name + id is display as display string), but I would need to set also the id on the element after choosing one in content assist.
Update
var textApplier = new IReplacementTextApplier () {
override apply(IDocument document, ConfigurableCompletionProposal proposal) throws BadLocationException {
//todo
throw new UnsupportedOperationException("TODO: auto-generated method stub")
}
}
var proposal = createCompletionProposal("\"" + getName(el) + "\"",
getLabel(el), null, context) as ConfigurableCompletionProposal
proposal.textApplier = textApplier
acceptor.accept(proposal);
[Updated on: Tue, 25 August 2020 10:40] Report message to a moderator
|
|
|
|
Re: Add an ID (hidden) in the metamodel associated with the xtext grammar [message #1831620 is a reply to message #1831618] |
Tue, 25 August 2020 11:32 |
Georgiana Ecobici Messages: 23 Registered: July 2019 |
Junior Member |
|
|
Hello Christian,
Thank you for your suggestion. I have try to override apply and use addAditionalData link below, the Participant object is set with the id inside apply but after the document is updated, the Participant object it loses the id already set.
var textApplier = new IReplacementTextApplier () {
override apply(IDocument document, ConfigurableCompletionProposal proposal) throws BadLocationException {
var participant = proposal.getAdditionalData("participant") as Participant
participant.id = proposal.getAdditionalData("id") as String
document.replace(proposal.getReplacementOffset(), proposal.getReplacementLength(), proposal.getReplacementString());
}
}
var proposal = createCompletionProposal("\"" + getName(el) + "\"",
getLabel(el), null, context) as ConfigurableCompletionProposal
proposal.setTextApplier(textApplier)
proposal.setAdditionalData("id", getId(el))
proposal.setAdditionalData("participant", context.currentModel)
acceptor.accept(proposal);
[Updated on: Tue, 25 August 2020 11:32] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: Add an ID (hidden) in the metamodel associated with the xtext grammar [message #1831655 is a reply to message #1831654] |
Wed, 26 August 2020 08:05 |
Georgiana Ecobici Messages: 23 Registered: July 2019 |
Junior Member |
|
|
Yes,
Participant:
keyword = 'participant' name=STRING
;
ParticipantUncalled returns Participant: id=ID;
var textApplier = new IReplacementTextApplier () {
override apply(IDocument document, ConfigurableCompletionProposal proposal) throws BadLocationException {
var participant = proposal.getAdditionalData("participant") as Participant
participant.id = proposal.getAdditionalData("id") as String //if i set here the id- it is lost because on document.replace - a new object is created
participant.name = "A"
document.replace(proposal.getReplacementOffset(), proposal.getReplacementLength(), proposal.getReplacementString());
// todo - I will try to obtain here the new object created in the model
}
}
[Updated on: Wed, 26 August 2020 08:07] Report message to a moderator
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04924 seconds