blended-modeling / eatxt

Eclipse Public License 2.0
1 stars 1 forks source link

Autocompletion for shortName #8

Closed Wilson008 closed 2 years ago

Wilson008 commented 3 years ago

•When shortName is needed, autocompletion could suggest a unique name in the namespace such as Actuator_0 or DesignFunctionType_0.

Wilson008 commented 2 years ago

The solution is: Override the method comlete{TypeName}_shortName of AbstractEatxtProposalProvider in EatxtProposalProvider.

for example: ` @Override public void completeEAPackage_ShortName(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) { super.completeEAPackage_ShortName(model, assignment, context, acceptor);

    long suffix = Math.round(Math.random() * 1000);
    String strSuffix = Long.toString(suffix);
    String proposal = "EAPackage_" + strSuffix;

    acceptor.accept(createCompletionProposal(proposal, context));
}`

Note: the autogenerated name will have a random suffix.