Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » xtext rename participant
xtext rename participant [message #1143511] Fri, 18 October 2013 08:27 Go to next message
Benoit Ries is currently offline Benoit RiesFriend
Messages: 86
Registered: May 2013
Member
Hi,

I wish to create a rename participant in order to perform some custom changes after an EObject of my semantic model is renamed using Refactor->Rename.

I created a class RenameMsrEObjectsParticipant which extends AbstractProcessorBasedRenameParticipant

I also added the LTK extension description in my plugin.xml, see code below.

My problem is that none of the methods of the participant class are executed.

I'm not quite sure on what to put for enablement, this might be the cause of my problem ?

I put EObject so that the participant react to changes in any of my DSL's objects, would that be correct ?



----
<renameParticipant class="lu.uni.lassy.excalibur.textualeditor.ui.refactoring.participants.RenameMsrEObjectsParticipant"
id="lu.uni.lassy.excalibur.ui.renameParticipant.msrfile"
name="Msr eobjects renaming">
<enablement>
<with variable="element">
<instanceof value="org.eclipse.emf.ecore.EObject">
</instanceof>
</with>
</enablement>
</renameParticipant>

[Updated on: Fri, 18 October 2013 09:08]

Report message to a moderator

Re: xtext rename participant [message #1143610 is a reply to message #1143511] Fri, 18 October 2013 09:54 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14666
Registered: July 2009
Senior Member
Hi,

what is the reason you dont use the renaming that is already there?
if you dont use Xtext stuff this may be the wrong place to ask.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: xtext rename participant [message #1143611 is a reply to message #1143610] Fri, 18 October 2013 09:55 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14666
Registered: July 2009
Senior Member
---

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Fri, 18 October 2013 09:59]

Report message to a moderator

Re: xtext rename participant [message #1143617 is a reply to message #1143611] Fri, 18 October 2013 10:00 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14666
Registered: July 2009
Senior Member
Here ius what xtend

   <extension
         point="org.eclipse.ltk.core.refactoring.renameParticipants">
      <renameParticipant
            class="org.eclipse.xtend.ide.XtendExecutableExtensionFactory:org.eclipse.xtend.ide.refactoring.XtendFileRenameParticipant"
            id="org.eclipse.xtend.ide.resourceRenameParticipant"
            name="Xtend File Rename Participant">
         <enablement>
           <adapt
                 type="org.eclipse.core.resources.IFile">
              <test
                    property="org.eclipse.core.resources.extension"
                    value="xtend">
              </test>
           </adapt>
         </enablement>
      </renameParticipant>
   </extension>


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: xtext rename participant [message #1143646 is a reply to message #1143610] Fri, 18 October 2013 10:22 Go to previous messageGo to next message
Benoit Ries is currently offline Benoit RiesFriend
Messages: 86
Registered: May 2013
Member
I don't feel to be in the wrong forum. What I try to do is mentioned explicitly in the Xtext user manual, see below.

"
9.8.2. Rename Participants
One refactoring can trigger another: When renaming a rule in an Xtext grammar, the returned EClass should be renamed, too. For these cases, you can register a RenameParticipant by the common means of LTK. If the target of the participant is Xtext based, you can use a AbstractProcessorBasedRenameParticipant.
"

any idea how to achieve concretely what is mentioned in this section ?
Re: xtext rename participant [message #1143668 is a reply to message #1143646] Fri, 18 October 2013 10:41 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14666
Registered: July 2009
Senior Member
See my second post

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: xtext rename participant [message #1143731 is a reply to message #1143617] Fri, 18 October 2013 11:36 Go to previous messageGo to next message
Benoit Ries is currently offline Benoit RiesFriend
Messages: 86
Registered: May 2013
Member
This sample code seems to be when user rename an Xtend file. It didn't help in my case.

I would like to react to a change of EObject name in my DSL editor.
Re: xtext rename participant [message #1143835 is a reply to message #1143731] Fri, 18 October 2013 13:04 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14666
Registered: July 2009
Senior Member
I don't know that ltk extension point in detail.
Did you simply give it a try?
What happens if you call Xtend refactoring via rename element?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: xtext rename participant [message #1148485 is a reply to message #1143835] Mon, 21 October 2013 14:43 Go to previous messageGo to next message
Benoit Ries is currently offline Benoit RiesFriend
Messages: 86
Registered: May 2013
Member
yes I've given it a try. the provided xtend refactoring works great as it is.

I am looking for a hook to execute some additional code when the renaming of one of my DSL element is performed in the textual editor.

I just can't find it !

My easiest (unsuccessful) guess was to use a typical eclipse ltk mechanism which is RenameParticipant but my participant is not launched.

anyone have used LTK refactoring in XText context ???

thanks in advance,
Benoit
Re: xtext rename participant [message #1149869 is a reply to message #1148485] Tue, 22 October 2013 11:12 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
What kind of change would you like to perform on rename? I expect you to be much better off with customizing the IRenameStrategy, as it gives you access to the semantic model used during refactoring.

Nevertheless, the RenameElementProcessor loads and executes the registered participants. Try setting a breakpoint in RenameElementProcessor#loadParticipants(RefactoringStatus, SharableParticipants) to debug why yours is ignored.



---
Get professional support from the Xtext committers at www.typefox.io
Re: xtext rename participant [message #1149937 is a reply to message #1149869] Tue, 22 October 2013 12:14 Go to previous messageGo to next message
Benoit Ries is currently offline Benoit RiesFriend
Messages: 86
Registered: May 2013
Member
thanks Jan for the pointer.

my modification concerns a 3rd-party model (from Obeo Designer) which references Xtext EObjects. I've already coded the participants for renaming and moving my DSL files which work ok. That's why I would prefer to reuse the LTK code when renaming xtext EObjects.

so the breakpoint showed me that in ParticipantExtensionPoint#RefactoringParticipant[] getParticipants(...)

my participant is enabled but
descriptor.matches(evalContext, filter, filterStatus) returns false but it seems like it should return true.

My guess is that it's just a problem of how I specify the "enablement" section in the plugin.xml. what do you think ?
Re: xtext rename participant [message #1151556 is a reply to message #1149937] Wed, 23 October 2013 12:33 Go to previous messageGo to next message
Benoit Ries is currently offline Benoit RiesFriend
Messages: 86
Registered: May 2013
Member
finally I customized IRenameStrategy. I guess you were right, I'm better of using it.
Re: xtext rename participant [message #1220080 is a reply to message #1149937] Mon, 09 December 2013 14:50 Go to previous message
Benoit Ries is currently offline Benoit RiesFriend
Messages: 86
Registered: May 2013
Member
Hi Jan,

sorry to revive this post after a month, but I am still not satisfied with my rename refactoring participant implementation Sad

What I do for now is two-fold :
1) I extend the RenameElementProcessor, I reuse exactly its same behavior by calling super.initialize() and in createChange super.createChange().
2) I bind this in MyDslUiModule using bindAbstractRenameProcessor


BUT what I would like to do is to have two separate participants, the first one doing the usual xtext rename element, then my participant doing my processing.


=> How can I separate these two participants implementations ? so that xtext rename element is executed first, then my participant is executed knowing the old and new name.


NB: I have attached my two classes, just in case you need to see roughly what I do.

many thanks in advance.

regards,
Benoît
Previous Topic:Resolving proxies
Next Topic:Is it possible to start a parse from a sub-rule?
Goto Forum:
  


Current Time: Fri Apr 26 16:43:32 GMT 2024

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

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

Back to the top