Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » AudoEditStrategy with context?
AudoEditStrategy with context? [message #1047184] Mon, 22 April 2013 22:30 Go to next message
Brad Riching is currently offline Brad Riching
Messages: 18
Registered: May 2012
Junior Member
Greetings everyone.

Does anyone know how I would go about implementing an AutoEditStrategy only in certain places of my model? The IAutoEditStrategy#customizeDocumentCommand only has an IDocument and DocumentCommand accessible, and no information or context about where I am in the model.

I would like to be able to take a list of items on a line like this:

containerName { item1, item2, item3, item4 }


And with each press of the [ENTER] button anywhere inside the brackets, I would like my AutoEditStrategy to insert a backslash indicating to my (external) compiler that the line has wrapped, like this:

containerName {\
  item1,\
  item2,\
  item3,\
  item4\
}


The key is, that the backslash should only be inserted if [ENTER] is pressed inside of the brackets. It should not insert a backslash outside the scope of the container.

Any ideas?
Re: AudoEditStrategy with context? [message #1047259 is a reply to message #1047184] Tue, 23 April 2013 01:24 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik Lindberg
Messages: 2500
Registered: July 2009
Senior Member
On 2013-23-04 24:30, Brad Riching wrote:
> Greetings everyone.
>
> Does anyone know how I would go about implementing an AutoEditStrategy
> only in certain places of my model? The
> IAutoEditStrategy#customizeDocumentCommand only has an IDocument and
> DocumentCommand accessible, and no information or context about where I
> am in the model.
>
> I would like to be able to take a list of items on a line like this:
>
>
> containerName { item1, item2, item3, item4 }
>
>
> And with each press of the [ENTER] button anywhere inside the brackets,
> I would like my AutoEditStrategy to insert a backslash indicating to my
> (external) compiler that the line has wrapped, like this:
>
>
> containerName {\
> item1,\
> item2,\
> item3,\
> item4\
> }
>
>
> The key is, that the backslash should only be inserted if [ENTER] is
> pressed inside of the brackets. It should not insert a backslash
> outside the scope of the container.
>
> Any ideas?
IIRC the auto edit is tied to regions in the text (i.e. inside strings,
comments etc.), but I don't remember exactly how. Think you need to read
the source for auto edits to figure it out.

Regards
- henrik
Re: AudoEditStrategy with context? [message #1047719 is a reply to message #1047259] Tue, 23 April 2013 15:01 Go to previous message
Brad Riching is currently offline Brad Riching
Messages: 18
Registered: May 2012
Junior Member
Thanks Henrik, I will give it a try and post my results if I come up with anything.
Previous Topic:JFace data binding between swt to Xtext model
Next Topic:cross-file references does not work after update (missing .classpath file)
Goto Forum:
  


Current Time: Tue Sep 30 14:07:45 GMT 2014

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

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