Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » AdditionalProposalInfo for enum rule
AdditionalProposalInfo for enum rule [message #713883] Tue, 09 August 2011 09:51 Go to next message
Steffen Schuette is currently offline Steffen SchuetteFriend
Messages: 26
Registered: August 2010
Junior Member
Hi,

I managed to create autocompletion proposals and additional proposal info as popup next to it for a rule call. However, for an enum rule call (i.e. an attribute that can have the value of a enum I defined in Xtext) the proposal provider provides additional proposals besides the enum values. What I want to do is to provide additional proposal info to the existing autocompletion proposals without adding new proposals. Example:

The default autocompletion for the attribute proposes the enum values: "Avg", "Sum", "Min", Max"

Now what I want to have is additional information about these variants next to the autocompletion popup. Is this possible/what is the easiest way?

Thank you for your answers

Steffen
Re: AdditionalProposalInfo for enum rule [message #714127 is a reply to message #713883] Tue, 09 August 2011 21:04 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

i guess you have to hack completeKeyword


	@Override
	public void completeKeyword(Keyword keyword,
			ContentAssistContext contentAssistContext,
			ICompletionProposalAcceptor acceptor) {
		if (keyword.eContainer() instanceof EnumLiteralDeclaration) {
			EnumLiteralDeclaration enumLiteral = (EnumLiteralDeclaration)keyword.eContainer();
			acceptor.accept(createCompletionProposal(enumLiteral.getEnumLiteral().getLiteral(),
					"This is the literal for " + enumLiteral.getEnumLiteral().getName(),
					null,
					contentAssistContext));
		} else {
			super.completeKeyword(keyword, contentAssistContext, acceptor);
		}
	}


~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: AdditionalProposalInfo for enum rule [message #714252 is a reply to message #714127] Wed, 10 August 2011 06:53 Go to previous message
Steffen Schuette is currently offline Steffen SchuetteFriend
Messages: 26
Registered: August 2010
Junior Member
Hi,

thanks for the reply. This is not 100% what I ment but you got me on the right track with the completekeywork function. I only changed the true branch of the if statement in your code to inject the additional info text:
EnumLiteralDeclaration enumLiteral = (EnumLiteralDeclaration)keyword.eContainer();
ConfigurableCompletionProposal proposal = (ConfigurableCompletionProposal) createCompletionProposal(enumLiteral.getEnumLiteral().getLiteral(),contentAssistContext);
proposal.setAdditionalProposalInfo("Additional info for " + enumLiteral.getEnumLiteral().getLiteral());
acceptor.accept(proposal);


Thank you very much.

Steffen

[Updated on: Wed, 10 August 2011 06:54]

Report message to a moderator

Previous Topic:Registering a resource factory
Next Topic:The following token definitions are unreachable: RULE_ID
Goto Forum:
  


Current Time: Fri Apr 19 15:11:55 GMT 2024

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

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

Back to the top