Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 316698 - [refactoring] Refactoring for moving a role class doesn't handle base imports
Summary: [refactoring] Refactoring for moving a role class doesn't handle base imports
Status: VERIFIED FIXED
Alias: None
Product: Objectteams
Classification: Tools
Component: OTDT (show other bugs)
Version: 1.4   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 2.1 M5   Edit
Assignee: Stephan Herrmann CLA
QA Contact:
URL:
Whiteboard: trac
Keywords:
Depends on:
Blocks: 356003
  Show dependency tree
 
Reported: 2010-06-13 09:10 EDT by Stephan Herrmann CLA
Modified: 2012-06-10 07:53 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stephan Herrmann CLA 2010-06-13 09:10:31 EDT
(originally from http://trac.objectteams.org/ot/ticket/227)

(observed by Robert Wloch) 
 The Move ... refactoring correctly moves a role class to another team. But if 
 the role is bound to a base-imported class: 
 the existing base import in the source team is not removed 
 the created import statement in the target team misses the base modifier.

(comment:1 by jogeb)
At least the refactoring finds the existing base import in the source team, but 
the ImportRewrite doesn't handle the change correctly and creates an empty 
MultiTextEdit (line 1068) => no changes
Comment 1 Stephan Herrmann CLA 2011-06-02 11:01:49 EDT
Similar effects happen when renaming a package.
Again base imports are not updated accordingly.
Comment 2 Stephan Herrmann CLA 2011-12-27 05:56:58 EST
Adding a new test class MoveRoleTests to reproduce.
(Test is a team for access to various private features of
org.eclipse.jdt.ui.tests.refactoring.ccp.MoveTest).

Fix comes in two steps (adding / removing):

Adding:
A new role in ReorgAdaptor hooks into
org.eclipse.jdt.internal.corext.refactoring.structure.ImportRewriteUtil:
a new nested team BaseImporting is activated during addImports(..).
This new team records when ImportReferencesCollector finds a
type reference inside a playedBy clause, passing this information
to the existing BaseImportRewriting engine.

Removing:
Adapt org.eclipse.jdt.core.dom.rewrite.ImportRewrite.removeEntry(String)
similar to addEntry(String).
Comment 3 Stephan Herrmann CLA 2011-12-27 06:20:41 EST
Released for 2.1M5 via commit 1437f3b477d90032b1ab3c67a691de78ab0aeee2
Comment 4 Stephan Herrmann CLA 2012-06-10 07:53:35 EDT
(In reply to comment #1)
> Similar effects happen when renaming a package.
> Again base imports are not updated accordingly.

Filed bug 382185 for an issue along these lines.

The problem in this bug has been fixed as verified for 2.1 using build 201206090452.