Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Completion with Enum(Enum literal constructed from two words and a space in between)
Completion with Enum [message #1693692] Mon, 27 April 2015 14:30 Go to next message
naseclipse naseclipse is currently offline naseclipse naseclipseFriend
Messages: 14
Registered: April 2015
Junior Member
Hello,

When it comes to completion for Enum literals, I see some problem when a certain literal is part of another literal. For example, 'may' and 'may have' are literals, where 'may' is part of 'may have'. During completion 'may have' overrides 'may'.

How is it possible to complete 'may' if i choose to, and ignore 'may have'?

/* Editor */
Type pronoun
Type verb

Statement s1 she:pronoun may have togo:verb
Statement s2 she:pronoun may go:verb // shows error in this line

Error: mismatched character 'g' expecting 'h'

/* the grammar */
grammar org.xtext.example.langdsl.LangDsl with org.eclipse.xtext.common.Terminals

generate langDsl "http://www.xtext.org/example/langdsl/LangDsl"

LanguageModel:
elements += LangModel*
;
LangModel:
Type | Statement
;
Type:
"Type" name = ID
;
Statement:
"Statement" name = ID
subject = ID ':' subType = [Type] verb = VerbEnum object = ID ':' objType = [Type]
;
enum VerbEnum:
MAY = 'may' | MAYHAVE = 'may have'
;

/* END: grammar */

Thank you.
Regards,
Nas

[Updated on: Mon, 27 April 2015 14:35]

Report message to a moderator

Re: Completion with Enum [message #1693698 is a reply to message #1693692] Mon, 27 April 2015 16:23 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
You should always avoid spaces in keywords. Provide a data type rule
instead to parse your enum.

Best,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Find help at http://xtext.itemis.com or xtext(@)itemis.com
Blog: zarnekow.blogspot.com
Twitter: @szarnekow
Google+: https://www.google.com/+SebastianZarnekow
Re: Completion with Enum [message #1693721 is a reply to message #1693698] Mon, 27 April 2015 21:09 Go to previous messageGo to next message
naseclipse naseclipse is currently offline naseclipse naseclipseFriend
Messages: 14
Registered: April 2015
Junior Member
Hello Sebastian,

The enum rule shows me the list of keywords to choose. But the dataType rule does not provide me with content assist at least with the default configuration of xText.
But I did some twist on the literal, that is I appended a space at the end of the literal, 'may' as follows:

enum VerbEnum:
MAY = 'may<space>' | MAYHAVE = 'may have'
;

I ve no explanation for this but, now it parses 'may' successfully
Statement s2 she:pronoun may go:verb

Thank you
Regards,
Nas
Re: Completion with Enum [message #1693732 is a reply to message #1693721] Tue, 28 April 2015 04:12 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

DO NOT use spaces in keywords!
Adjusting the Content Assist for the Datatype Rule is a NoBrainer,


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Build management
Next Topic:How to Disable outline view and show only Quickoutline view
Goto Forum:
  


Current Time: Sat Apr 20 00:49:28 GMT 2024

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

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

Back to the top