Skip to main content



      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 04:21 Go to next message
Eclipse UserFriend
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 06:24 Go to previous messageGo to next message
Eclipse UserFriend
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?
Re: How to add cascading content assist in xtext [message #1806656 is a reply to message #1806652] Mon, 13 May 2019 07:45 Go to previous messageGo to next message
Eclipse UserFriend
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 07:56] by Moderator

Re: How to add cascading content assist in xtext [message #1806659 is a reply to message #1806656] Mon, 13 May 2019 08:24 Go to previous message
Eclipse UserFriend
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
Previous Topic:Combine Xtext editor with GEF editor
Next Topic:Check for byte array in model inferrer
Goto Forum:
  


Current Time: Tue Mar 25 19:11:28 EDT 2025

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

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

Back to the top