Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Content Sensitive Autocomplete
Content Sensitive Autocomplete [message #1764968] Mon, 05 June 2017 08:43 Go to next message
Denis Kutergin is currently offline Denis KuterginFriend
Messages: 1
Registered: June 2017
Junior Member
Example of DSL grammar:
grammar hellodsl.HelloDsl with org.eclipse.xtext.common.Terminals

generate helloDsl "http://www.HelloDsl.hellodsl"

Model:
	statements+=Statement*;

Statement:
	Join|Leave|Greeting;

Join:
	'Join' name=ID ';';

Leave:
	'Leave' name=ID ';';

Greeting:
	'Hello' name=ID ';';


Example of DSL script:
Join Alice;
Join Bob;
Join Mike;
Leave Alice;
Hello 


How to add in autocomplete (Ctrl-SPACE) after "Hello" only names, defined above in "Join" statement and except names, defined in "Leave" statement? For this example must be 2 variants:

Hello <cursor here>
1) Bob
2) Mike
Re: Content Sensitive Autocomplete [message #1764988 is a reply to message #1764968] Mon, 05 June 2017 14:57 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14075
Registered: July 2009
Senior Member
Hi do you know the concept of cross references and scoping? that is perfect for this usecase.
alternatively have a look at the proposal providers complete Greeting_name method. you can use the context parameter to access the model and traverse it



Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Content Assist not displaying icon before keyword
Next Topic:org.xtext.xtend gradle plugin.
Goto Forum:
  


Current Time: Mon Oct 18 10:51:39 GMT 2021

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

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

Back to the top