Code assist for DataType rules [message #1779847] |
Sun, 14 January 2018 11:07  |
Eclipse User |
|
|
|
Hello,
I would like to get some help regarding this problem:
I have a data type rule like this (unit of measure) with a Value converter etc..
A valid value would be ex: 200 mm
UomLength returns UomLength:
INT STRING
;
I need to get the code assist popup after I type the integer value. The code assist has to show the units available.
I can only get the popup for the whole thing only, not the integer.
Still is reasonable, I can suggest "0 mm" and jump the cursor but I am asking if it's possible
Thanks and Regards,
PD
|
|
|
Re: Code assist for DataType rules [message #1779849 is a reply to message #1779847] |
Sun, 14 January 2018 12:48   |
Eclipse User |
|
|
|
i am not sure if a datatype rule is very good here cause error recovery / context calculation might be bad.
you may try to play around with
UomLength returns UomLength:
INT ID
;
class MyDslProposalProvider extends AbstractMyDslProposalProvider {
override complete_UomLength(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
super.complete_UomLength(model, ruleCall, context, acceptor)
if (context.prefix.isEmpty) {
acceptor.accept(createCompletionProposal("1", context))
} else if (context.prefix.endsWith(" ")) {
acceptor.accept(createCompletionProposal(context.prefix+"mm", context))
} else {
acceptor.accept(createCompletionProposal(context.prefix+" mm", context))
}
}
@Inject MyDslGrammarAccess ga
override complete_ID(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
if (ruleCall === ga.uomLengthAccess.IDTerminalRuleCall_1) {
acceptor.accept(createCompletionProposal("mm", context))
}
super.complete_ID(model, ruleCall, context, acceptor)
}
}
|
|
|
|
Powered by
FUDForum. Page generated in 0.07046 seconds