Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » rename refactoring in the presence of nested elements
rename refactoring in the presence of nested elements [message #697164] Fri, 15 July 2011 17:10 Go to next message
Henrik Rentz-Reichert is currently offline Henrik Rentz-ReichertFriend
Messages: 261
Registered: July 2009
Senior Member
Hi all,

in the eTrice project I'm currently introducing rename refactoring.
In this case the xmi resources of the diagrams need to be updated too.
Fortunately most of the job is done by your generic implementations for emf resources.
Below you can find some snippets that show what I did.


A problem now arises with nested elements, e.g. a hierarchical state machine like

RoomModel rename {
ActorClass A {
Structure { }
Behavior {
StateMachine {
State top {
subgraph {
State nested
}
}
}
}
}
}

The point is that I use a fragment provider which uses a path, e.g.
.../rename.room#BaseState:A$top$nested

When I rename the "top" state then the directly related fragment is changed correctly.
But the fragment for the "nested" state which is affected too also has to be updated.

So far I only use standard implementations like IResourceUIServiceProvider, EmfResourceReferenceUpdater etc.

Can you give me a hint where I have to hook in to handle also the indirectly affected nested elements?

Thanks,
Henrik


------------ snippets ---------------

<extension
point="org.eclipse.emf.ecore.extension_parser">
<parser
class="org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl"
type="behavior">
</parser>
</extension>
<extension point="org.eclipse.xtext.extension_resourceServiceProvider">
<resourceServiceProvider

class="org.eclipse.etrice.core.ui.rename.ReferringDiagramExecutableExtensionFactory:org.eclipse.xtext.ui.resource.IResourceUIServiceProvider"
uriExtension="behavior">
</resourceServiceProvider>
</extension>

------------------------

public class ReferringDiagramExecutableExtensionFactory extends
AbstractGuiceAwareExecutableExtensionFactory {

@Override
protected Bundle getBundle() {
return RoomActivator.getInstance().getBundle();
}

@Override
protected Injector getInjector() {
return createInjector(override(
override(new ReferringDiagramResourceModule()).with(new org.eclipse.xtext.ui.shared.SharedStateModule()))
.with(new EmfUiModule(RoomActivator.getInstance())));
}

}

------------------------

public class ReferringDiagramResourceModule extends
AbstractGenericResourceRuntimeModule {

/* (non-Javadoc)
* @see org.eclipse.xtext.resource.generic.AbstractGenericResourceRuntimeModule#getLanguageName()
*/
@Override
protected String getLanguageName() {
return "org.eclipse.etrice.diagrams";
}

/* (non-Javadoc)
* @see org.eclipse.xtext.resource.generic.AbstractGenericResourceRuntimeModule#getFileExtensions()
*/
@Override
protected String getFileExtensions() {
return "structure,behavior";
}

}

------------------------
Re: rename refactoring in the presence of nested elements [message #697688 is a reply to message #697164] Sun, 17 July 2011 18:22 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Henrik,

please dig into
org.eclipse.xtext.ui.refactoring.impl.DefaultDependentElementsCalculator
and the interface that it implements.

Hope that helps,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

On 15.07.11 19:10, Henrik Rentz-Reichert wrote:
> Hi all,
>
> in the eTrice project I'm currently introducing rename refactoring.
> In this case the xmi resources of the diagrams need to be updated too.
> Fortunately most of the job is done by your generic implementations for emf resources.
> Below you can find some snippets that show what I did.
>
>
> A problem now arises with nested elements, e.g. a hierarchical state machine like
>
> RoomModel rename {
> ActorClass A {
> Structure { }
> Behavior {
> StateMachine {
> State top {
> subgraph {
> State nested
> }
> }
> }
> }
> }
> }
>
> The point is that I use a fragment provider which uses a path, e.g.
> ../rename.room#BaseState:A$top$nested
>
> When I rename the "top" state then the directly related fragment is changed correctly.
> But the fragment for the "nested" state which is affected too also has to be updated.
>
> So far I only use standard implementations like IResourceUIServiceProvider, EmfResourceReferenceUpdater etc.
>
> Can you give me a hint where I have to hook in to handle also the indirectly affected nested elements?
>
> Thanks,
> Henrik
>
>
> ------------ snippets ---------------
>
> <extension
> point="org.eclipse.emf.ecore.extension_parser">
> <parser
> class="org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl"
> type="behavior">
> </parser>
> </extension>
> <extension point="org.eclipse.xtext.extension_resourceServiceProvider">
> <resourceServiceProvider
>
> class="org.eclipse.etrice.core.ui.rename.ReferringDiagramExecutableExtensionFactory:org.eclipse.xtext.ui.resource.IResourceUIServiceProvider"
> uriExtension="behavior">
> </resourceServiceProvider>
> </extension>
>
> ------------------------
>
> public class ReferringDiagramExecutableExtensionFactory extends
> AbstractGuiceAwareExecutableExtensionFactory {
>
> @Override
> protected Bundle getBundle() {
> return RoomActivator.getInstance().getBundle();
> }
>
> @Override
> protected Injector getInjector() {
> return createInjector(override(
> override(new ReferringDiagramResourceModule()).with(new org.eclipse.xtext.ui.shared.SharedStateModule()))
> .with(new EmfUiModule(RoomActivator.getInstance())));
> }
>
> }
>
> ------------------------
>
> public class ReferringDiagramResourceModule extends
> AbstractGenericResourceRuntimeModule {
>
> /* (non-Javadoc)
> * @see org.eclipse.xtext.resource.generic.AbstractGenericResourceRuntimeModule#getLanguageName()
> */
> @Override
> protected String getLanguageName() {
> return "org.eclipse.etrice.diagrams";
> }
>
> /* (non-Javadoc)
> * @see org.eclipse.xtext.resource.generic.AbstractGenericResourceRuntimeModule#getFileExtensions()
> */
> @Override
> protected String getFileExtensions() {
> return "structure,behavior";
> }
>
> }
>
> ------------------------
>
Re: rename refactoring in the presence of nested elements [message #698449 is a reply to message #697688] Tue, 19 July 2011 13:25 Go to previous message
Henrik Rentz-Reichert is currently offline Henrik Rentz-ReichertFriend
Messages: 261
Registered: July 2009
Senior Member
Hi Sebastian,

thanks for the hint.
I only had to provide a qualified name for an intermediate object (the sub state graph) in the hierarchy.
Now it works as a charm.

-Henrik

Am 17.07.2011 20:22, schrieb Sebastian Zarnekow:
> Hi Henrik,
>
> please dig into org.eclipse.xtext.ui.refactoring.impl.DefaultDependentElementsCalculator and the interface that it implements.
>
> Hope that helps,
> Sebastian
Previous Topic:XText Preprocess
Next Topic:Unit Testing
Goto Forum:
  


Current Time: Sat Apr 27 03:42:30 GMT 2024

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

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

Back to the top