| Summary: | [rename] rename refactoring should save open documents | ||
|---|---|---|---|
| Product: | [Modeling] TMF | Reporter: | Knut Wannheden <knut.wannheden> |
| Component: | Xtext | Assignee: | Jan Koehnlein <jan> |
| Status: | CLOSED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | e.terekhov, jan, tmf.xtext-inbox, vpiskarov |
| Version: | 2.0.1 | Flags: | jan:
indigo+
|
| Target Milestone: | SR2 | ||
| Hardware: | PC | ||
| OS: | Mac OS X - Carbon (unsup.) | ||
| Whiteboard: | |||
|
Description
Knut Wannheden
Update: By default the JDT saves all files for which no *dirty* editor exists. In case of dirty editors only the document is updated. I think that's where the difference is: Xtext will *always* just update the the document if it finds an open editor for the given resource. May I vote for this, too? As Knut have pointed out, JDT attempts to minimize the number of build errors resulting from inconsistencies between 'saved' and 'dirty' state after refactoring (these inconsistencies can't be fully avoided). In addition, it seems that JDT policy for saving the document containing the element being renamed (as opposed to documents just referencing that element) is a function of the type of the element. Thus, when renaming a Java type it always saves the document containing the type declaration, but when renaming a method it avoids saving any documents that have already been 'dirty'. To summarize, there appears to be one rule which JDT always obeys: never change 'clean' state to 'dirty' after refactoring (but not vice-versa). Having used refactoring a while now, I agree: We should try to mimick JDT behavior as close as possible. Pushed to MASTER. We use a third kind of IRefactoringDocument now for documents that must be saved. For clean editors, the FileDocument is used, so we rely on the editor's resource listener to update the content. You can configure the refactoring behavior now in the preference pages. The same properties as in JDT are available. That more or less corresponds to what we hacked together in our code. The downside of using FileDocument for clean editors is that it messes up the selection in the editor, as it isn't applied as a change to the document. So I think it would really be cleaner if an EditorDocument would be used and then saved at the end. What do you think? You are right, that's better. Fix and tests pushed to MASTER. Unfortunately, the current solution breaks the refactoring of Xtend2 classes. Seems like the document saving has a race condition with the resource rename change, causing a corrupt editor state. Fixed by Sven's commit 6c7f55abd2332df3975af37675c0d040193f7149 |