Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » CrossReferences [..|STRING] and AutoEditing is not nice
CrossReferences [..|STRING] and AutoEditing is not nice [message #1686619] Thu, 19 March 2015 09:15 Go to next message
Marcus Höpfner is currently offline Marcus HöpfnerFriend
Messages: 56
Registered: February 2014
Member
Hi,

In the grammar there is the following cross ref:
FormulaMemberOperand returns FormulaMemberOperand:
	member=[QueryElement|STRING];

terminal STRING:
	'"' ('\\' ('b' | 't' | 'n' | 'f' | 'r' | 'u' | '"' | "'" | '\\') | !('\\' | '"'))* '"';


Enter a " and use content assist ends up in to double quotes at the end and a syntax error.
One double quote comes from auto editing and one from the cross ref string.
Like this:

  1. User enters "
  2. AutoEditing makes it "", cursor is in the middle
  3. User presse CTRL+SPACE and selects an entry
  4. Content is e.g. "Sales""

I switched off auto editing for string but I don't like the behaviour.
I thought of changing the replaceRegion in ContentAssistContext but I don't know how.

I would like to stay with auto editing but content assist should replace the second " which came from auto editing.
Is this possible?
Re: CrossReferences [..|STRING] and AutoEditing is not nice [message #1686662 is a reply to message #1686619] Thu, 19 March 2015 09:40 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi, yes it is possible but is very tricky and the solution may be "not nice" anyway. the basic idea is to have a custom ICompletionProposalAcceptor.Delegate that
in its accept method examines the document and the givens ConfigurableCompletionProposal replacement offset/length and replacement string
and manipultates them the replace length-1 chars only if there is already a " after the replacing.

Unfortunately i cannot share the code since it belongs to my customer.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: CrossReferences [..|STRING] and AutoEditing is not nice [message #1686873 is a reply to message #1686662] Thu, 19 March 2015 11:44 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

i took that as a base and created following blog post: https://christiandietrich.wordpress.com/2015/03/19/xtext-and-strings-as-cross-references/


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:How to remove the xtext update site in RCP app
Next Topic:org.eclipse.core.contenttype.contentTypes support
Goto Forum:
  


Current Time: Thu Apr 25 12:24:43 GMT 2024

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

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

Back to the top