Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Filter the terminals list proposed in content assistant
Filter the terminals list proposed in content assistant [message #1831232] Fri, 14 August 2020 09:06 Go to next message
Eclipse UserFriend
When a grammar is more permisive, it is possible to filter the terminals proposed in content assistant?

In the grammar below, need to show in Content Assist only Component or only Function depending on my context.

Model:
'scenario' begin = '{' participants+=Participant*
end = '}';
Participant:
Component | Function
;
Component:
'component' name=STRING (nature = ('unset' | 'behavior' | 'node'))?
;
Function:
'function' name=STRING 'as' id=ID
;

Tried to override the complete_ methods in AbstractDslProposalProvider (Dsl-the name of the grammar file), but it still proposes all the terminals (keywords supported).

override void completeModel_Participants(EObject model, Assignment assignment, ContentAssistContext context,
ICompletionProposalAcceptor acceptor) {
acceptor.accept(createCompletionProposal("test1", "test1", null, context));
}

override complete_Participant(EObject model, RuleCall ruleCall, ContentAssistContext context,
ICompletionProposalAcceptor acceptor) {
acceptor.accept(createCompletionProposal("test2", "test2", null, context));
}

override void complete_Component(EObject model, RuleCall ruleCall, ContentAssistContext context,
ICompletionProposalAcceptor acceptor) {
// subclasses may override
acceptor.accept(createCompletionProposal("test3", "test3", null, context));
}
Re: Filter the terminals list proposed in content assistant [message #1831233 is a reply to message #1831232] Fri, 14 August 2020 09:15 Go to previous messageGo to next message
Eclipse UserFriend
For keywords you have to override completeKeyword
Re: Filter the terminals list proposed in content assistant [message #1831234 is a reply to message #1831233] Fri, 14 August 2020 09:26 Go to previous messageGo to next message
Eclipse UserFriend
I'll try:

AbstractJavaBasedContentProposalProvider::completeKeyword.

[Updated on: Fri, 14 August 2020 09:28] by Moderator

Re: Filter the terminals list proposed in content assistant [message #1831235 is a reply to message #1831234] Fri, 14 August 2020 09:37 Go to previous message
Eclipse UserFriend
Thanks, it works by overriding completeKeyword.
Previous Topic:Standalone XBase DSl with Compile Time Java Source (.java) and Jar (.class file) Dependencies
Next Topic:How to programmtically add EObject into Resource
Goto Forum:
  


Current Time: Fri Jul 25 09:33:50 EDT 2025

Powered by FUDForum. Page generated in 0.27546 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top