Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to add cascading content assist in xtext(I want to add content-assist, one after the other in my xtext project)
How to add cascading content assist in xtext [message #1806647] Mon, 13 May 2019 08:21 Go to next message
Himanshu Patel is currently offline Himanshu PatelFriend
Messages: 3
Registered: April 2019
Junior Member
I'm creating an array of pre-defined values and I want that array to be completed with xtext content assist. An example of desired behaviour:

// defining the allowed values of array
Attribute list_of_codes {
codes: ["A", "B", "C", "D"]
}

// Using the above values
array {
elements: *Hits C-space to get '{' in content-assist box*
elements: { *Hits C-space to get "A", "B", "C", "D", "}" in content-assist box*
elements: { "A" *Hits C-space to get ',' and '}' in content-assist box*
}
// and so on.
Re: How to add cascading content assist in xtext [message #1806652 is a reply to message #1806647] Mon, 13 May 2019 10:24 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
hi,

i am not understand your problem.
if you implement grammar / cross references/scoping this will work
=> can you be a bit more specific

- how does your grammar look like?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to add cascading content assist in xtext [message #1806656 is a reply to message #1806652] Mon, 13 May 2019 11:45 Go to previous messageGo to next message
Himanshu Patel is currently offline Himanshu PatelFriend
Messages: 3
Registered: April 2019
Junior Member
The grammar looks something like:

Model:
      attributes += (Attribute)*
      arrays += (Array)*

Attribute:
      'Attribute' name=ID  '{'
      'codes' ':' '[' (codes+=(STRING)*)  ']'
'}'

Array:
      'array' '{' 'elements' ':' element+=STRING (',' element += STRING)*  '}'



Now as we can see from the grammar that array elements can be any string. But I want the content assist to show only those strings which are defined in the Attribute definition. Also I want the content assist to keep showing me suggestions until I hit the closing brace for the array.

[Updated on: Mon, 13 May 2019 11:56]

Report message to a moderator

Re: How to add cascading content assist in xtext [message #1806659 is a reply to message #1806656] Mon, 13 May 2019 12:24 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
what about

Model:
      attributes += (Attribute)*
      arrays += (Array)*;

Attribute:
      'Attribute' notname=ID  '{' // if you want to call this name you can do so but you have to adapt nameprovider too
      'codes' ':' '[' (codes+=(Element)*)  ']'
'}';

Element: name=STRING;

Array:
      'array' '{' 'elements' ':' element+=[Element|STRING] (',' element += [Element|STRING])*  '}';


see https://www.dietrich-it.de/xtext/2015/03/19/xtext-and-strings-as-cross-references.html too


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Combine Xtext editor with GEF editor
Next Topic:Check for byte array in model inferrer
Goto Forum:
  


Current Time: Fri Apr 26 02:48:46 GMT 2024

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

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

Back to the top