Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 358348

Summary: DefaultTextEditComposer should bendrReferences in case of change of name feature
Product: [Modeling] TMF Reporter: Boris holzer <boris.holzer>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: enhancement    
Priority: P3 CC: sebastian.zarnekow
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Boris holzer CLA 2011-09-21 02:39:03 EDT
Build Identifier:  I20110613-1736

If e.g a quickfix modifies the name of an object, references to that object within the document are corrupted.

As a local patch, I solved that issue by modifying DefaultTextEditComposer. recordObjectModification(EObject obj) as follows (note the change of the signature):
protected void recordObjectModification(Notification notification) {
  EObject obj = (EObject) notification.getNotifier();
  if (obj.eResource() == null || obj.eResource() != resource) {
   getModifiedObjects().remove(obj);
  } else {
   getModifiedObjects().add(obj);
   if("name".equals( ((EStructuralFeature) notification.getFeature()).getName())){
    final Collection<Setting> refs = UsageCrossReferencer.find(obj, resource);
    for (Setting setting : refs) {
     getModifiedObjects().add(setting.getEObject());
    } 
   }
  }
 }


Reproducible: Always
Comment 1 Sebastian Zarnekow CLA 2011-09-21 02:46:41 EDT
Please use the rename refactoring if you want to change the identifying attribute of an EObject. Otherwise external references will be broken.

The TextEditComposer will record the modifications as is since it is a low level component. To give you just an example: if we change the behavior as suggested, it would not be possible to create a semantic quickfix that solves a name clash.
Comment 2 Karsten Thoms CLA 2017-09-19 17:59:26 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 3 Karsten Thoms CLA 2017-09-19 18:10:07 EDT
Closing all bugs that were set to RESOLVED before Neon.0