|
|
Re: Using Quickfix to add elements to imported ECore resource [message #1707336 is a reply to message #1701103] |
Thu, 03 September 2015 15:51   |
Eclipse User |
|
|
|
Hi Christian,
sorry for the late response.
I created a custom LinkingDiagnosticMessageProvider and implemented the getUnresolvedProxyMessage method as you said.
This works fine, thank you very much!
Then I implemented a quickfix like I would do for my xtext document.
@Fix(IssueCodes::OPERATION_NOT_FOUND)
def fixOperationNotFound(Issue issue, IssueResolutionAcceptor acceptor) {
createLinkingIssueResolutions(issue, acceptor);
acceptor.accept(
issue,
'Add operation to model',
'Add operation to model.',
null,
new ISemanticModification() {
override apply(EObject element, IModificationContext context) throws Exception {
// Retrieve
val greeting = element as Greeting
val type = greeting.ec as EClass
// Retrieve name of operation
val operationName = context.xtextDocument.get(issue.offset, issue.length)
// Create new operation
val newOperation = EcoreFactory.eINSTANCE.createEOperation()
newOperation.name = operationName
// Add to model
type.EOperations.add(newOperation)
// Save model
type.eResource.save(Collections.EMPTY_MAP)
}
}
)
}
This works and adds the new operation to the model, but the Xtext editor still shows the error.
To refresh the editor I have to change something and then save the document.
How can I change the quickfix to refresh the editor automatically?
|
|
|
|
|
Re: Using Quickfix to add elements to imported ECore resource [message #1707352 is a reply to message #1707341] |
Thu, 03 September 2015 18:23  |
Eclipse User |
|
|
|
I don't really know how to tweak the DefaultResourceDescriptionManager..
I also tried to use EditingDomains to change the models and update the editor, but then I found out that Xtext does not use any EditingDomains (is that correct?).
But I found another way to modify xtext documents by using the modify method of the document (as you said before).
In this method I can set a "modified" flag that forces the editor to refresh.
context.xtextDocument.modify(
new IUnitOfWork.Void<XtextResource>() {
override process(XtextResource state) throws Exception {
state.modified = true
}
})
This works, but looks like a workaround though.. Does anyone know another way?
|
|
|
Powered by
FUDForum. Page generated in 0.24417 seconds