[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.modeling.tmf] Re: Implementing a something like the Rename->Refactor
|
Hi drew,
I have a grammar with a number statements that can reference other things. I
want to add a gesture that does something like the java Rename->refactor
gesture , so that during this gesture if one modifies a certain elements
attribute) all the depenedent elements get updated in the text editor. Not
sure exactly how to implement this.
This is not exactly a trivial task but I think all needed building
blocks should be available by now.
An implementation would/could/should work like this:
If the user selects an identifier and triggers the refactoring action:
1. Ensure all files are saved.
2. Ensure all files are indexed by EMF Index.
3. Determine the EObject of which the name-giving feature is being
renamed. This can be done by querying the node model, which is available
in each XtextResource.
4. Use EMF Index to find all cross references which point to this
EObject. If you support full qualified names in your languages, you will
halso have to find all cross references pointing to children of the
to-be-modified EObject.
5. Load (parse) all files which contain cross references from (4) and
make sure these cross references are resolved.
6. Modify the EObject by renaming the feature.
7. Store (serialize) all involved files to disk. During serialization,
the names of all cross references are re-calculated - thereby the
modified name is applied to all places where it occurs.
For the UI-part I'd recommend to utilize the Eclipse Language Toolkit
(LTK). It provides the nice wizard which guides you through
options/checking-preconditions/preview/postconditions. Furthermore, the
LTK provides an infrastructure participate in existing refactoring
operations and allow participation in own refactoring.
hth,
Moritz
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com