Auto-edit after reference completion [message #1016365] |
Wed, 06 March 2013 04:06  |
Eclipse User |
|
|
|
Hi,
In my grammar, I have a rule like that:
PartProvidedPortReference returns spead::PortReferenceWA:
{PartProvidedPortReference}
declaringComponent=[spead::ComponentInstance|ValidID] '.'
port=[spead::ProvidedPort|ValidID];
Is it possible to have the dot '.' auto-inserted after completion of declaringComponent using content-assist?
Thank you!
|
|
|
|
|
Re: Auto-edit after reference completion [message #1017013 is a reply to message #1016993] |
Fri, 08 March 2013 10:44   |
Eclipse User |
|
|
|
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.03353 seconds