|
|
Re: Auto-edit after reference completion [message #1016993 is a reply to message #1016981] |
Fri, 08 March 2013 14:09 |
|
Hi guess there is not out of the box solution for that, you can try to hook into
(a)
org.eclipse.xtext.ui.editor.contentassist.AbstractJavaBasedContentProposalProvider.DefaultProposalCreator.DefaultProposalCreator(AbstractJavaBasedContentProposalProvider, ContentAssistContext, String, IQualifiedNameConverter)
by overriding
org.eclipse.xtext.ui.editor.contentassist.AbstractJavaBasedContentProposalProvider.getProposalFactory(String, ContentAssistContext)
(b) org.eclipse.xtext.ui.editor.contentassist.AbstractContentProposalProvider.createCompletionProposal(String, StyledString, Image, ContentAssistContext)
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
Re: Auto-edit after reference completion [message #1017013 is a reply to message #1016993] |
Fri, 08 March 2013 15:44 |
Victor Noël Messages: 112 Registered: June 2010 |
Senior Member |
|
|
Thank you for these details, in the end I extended XbaseReferenceProposalCreator (and injected it in my UiModule) so that I can check the type of the feature that is being completed and then I tweaked the proposalCreator.
It gives me something like that for the record, I hope I didn't forget anything when modifying the proposal that is created:
public class SpeADLReferenceProposalCreator extends XbaseReferenceProposalCreator {
@Override
protected Function<IEObjectDescription, ICompletionProposal> getWrappedFactory(
final EObject model, final EReference reference,
final Function<IEObjectDescription, ICompletionProposal> proposalFactory) {
if (reference.equals(SpeADPackage.Literals.PORT_REFERENCE__DECLARING_INSTANCE)) {
return new Function<IEObjectDescription, ICompletionProposal>() {
public ICompletionProposal apply(IEObjectDescription from) {
ConfigurableCompletionProposal result = (ConfigurableCompletionProposal) proposalFactory.apply(from);
// TODO why null??!!
if (result != null) {
result.setReplacementString(result.getReplacementString() + ".");
result.setCursorPosition(result.getCursorPosition()+1);
}
return result;
}
};
}
return super.getWrappedFactory(model, reference, proposalFactory);
}
}
As you can see in my TODO comment, I don't know why, sometimes result is null.
Actually, when triggering completion, the proposal creator is called twice per candidate reference!
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03165 seconds