History log of /sdk/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactorings/core/RenameResourceParticipant.java
Revision Date Author Comments
8cf21be14c49245cb4bc967e81d8d7bc798179b7 07-Dec-2012 Tor Norbye <tnorbye@google.com> Refactoring fixes

This CL contains a couple of tweaks to the
refactoring support. First, update <declare-styleable>
declarations for renamed custom views. Second, update
XML in downstream projects from library projects.
Third, allow invoking the rename refactoring from XML
files from class attributes and custom view tags as well
(until now it applied only to resource names.)
Finally, update unit test golden file format to include
whether each change is enabled, and tweak the code to
disable R class changes to handle some additional
scenarios.

Change-Id: I74ccbe1b0f15ec10429f8dda7674f51f9a6f83cd
32654dfbd134559fbf6bec4542d6a4a8105897c9 03-Dec-2012 Tor Norbye <tnorbye@google.com> Fix rename type, rename package and move type refactorings

This CL updates the various refactorings to properly handle layout
refactoring such that it not only updates custom views, but also
updates fragment references, tool:context references etc. It also
fixes missing manifest updates (such as replacing the
parentActivityName attributes).

Most importantly, it also fixes bugs where the wrong elements in the
manifest could get updated. There are a lot of diffs in this CL
because I basically replaced the old refactoring code (which had a lot
of custom text change and document manipulation code) with code based
on the new resource refactoring, where there is a single iteration of
the XML documents. This also improves the emitted refactoring elements
such that it only lists each file once.

Also updated the unit tests to check additional scenarios; adding a
second activity with the same prefix as the first is what revealed the
broken document handling in the old code.

Change-Id: I7c5959ca6b046ce3dab566663988cdd0389b0e5b
a96737ef1ee717e322c87a8ef391440b2aaf03b6 09-Nov-2012 Tor Norbye <tnorbye@google.com> Add resource renaming support

This changeset adds support for renaming resources.

There are several new hooks for initiating a resource rename:

(1) You can use the same keybinding as in Java files from XML files to
initiate refactoring; for example, place the caret somewhere in
@+id/foo or @string/bar and hit the refactoring keybinding, and a
rename resource refactoring dialog shows up.

(2) Invoking Quick Assistant in an XML file (Ctrl/Cmd 1) will offer to
rename the resource, if the caret is over a resource name.

(3) Renaming an XML or bitmap resource file, such as
res/drawable-hdpi/foo.png, will now initiate the same XML resource
naming machinery as above to update all resource references, plus
it will also update all the other versions of the same file
(e.g. in res/drawable-mdpi, res/drawable-xhdpi, etc.). Assuming an
R field exists (e.g. the project has been built), it will also
optionally update all Java field references.

(4) Invoking renaming in the layout editor (via the rename keybinding,
or via the context menu, or via the property sheet's "..." button)
will also initiate id resource refactoring. Editing the id
directly in the inline editor for the id will pop up a dialog
asking whether to update references as well, along with a "Do not
ask again" checkbox.

(5) Finally, there is a renaming participant registered which will
discover whether an R field is renamed, so if you go and rename
R.layout.foo from Java, this will also kick in all of the above
machinery - renaming layout files, updating resource references,
etc.

If the renamed resource is in a library project, the refactoring
will also look at all the including projects and offer to update
references there as well.

Finally, this CL goes and fixes a few bugs in the existing refactoring
operations; in particular, making sure that they not only look at
files in layout/ but in all folder configurations containing layout
files. It also adds refactoring unit tests.

Change-Id: Ie88511a571b414fdc5be048e781fe29a34063cbf