Skip to main content



      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 10:30 Go to next message
Eclipse UserFriend
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 10:35] by Moderator

Re: Completion with Enum [message #1693698 is a reply to message #1693692] Mon, 27 April 2015 12:23 Go to previous messageGo to next message
Eclipse UserFriend
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 17:09 Go to previous messageGo to next message
Eclipse UserFriend
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 00:12 Go to previous message
Eclipse UserFriend
Hi,

DO NOT use spaces in keywords!
Adjusting the Content Assist for the Datatype Rule is a NoBrainer,
Previous Topic:Build management
Next Topic:How to Disable outline view and show only Quickoutline view
Goto Forum:
  


Current Time: Sun Jul 27 04:58:55 EDT 2025

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

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

Back to the top