|
|
|
|
|
|
|
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 07:32   |
Eclipse User |
|
|
|
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 07:32] by Moderator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: Add an ID (hidden) in the metamodel associated with the xtext grammar [message #1831677 is a reply to message #1831663] |
Wed, 26 August 2020 08:01  |
Eclipse User |
|
|
|
Thanks for the suggestions.
It worked to set the id like below, using IDerivedStateComputer.
class DslDerivedStateComputer implements IDerivedStateComputer {
override discardDerivedState(DerivedStateAwareResource resource) {
resource.allContents.filter(Participant).forEach [
id = "456"
]
}
override installDerivedState(DerivedStateAwareResource resource, boolean preLinkingPhase) {
if (!preLinkingPhase)
resource.allContents.filter(Participant).forEach [ participant |
participant.id = "123"
]
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.04771 seconds