diff options
author | Tor Norbye <tnorbye@google.com> | 2011-07-26 18:44:46 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2011-07-26 18:44:46 -0700 |
commit | 986561291b06f5283b447501f01ecece83dfae66 (patch) | |
tree | 016dab125a0f23a25b2a84cd2b5c7a847e796467 /eclipse/plugins/com.android.ide.eclipse.adt | |
parent | 4acb7dd9a09af790eb019922f6e4bc8555c39cd6 (diff) | |
download | sdk-986561291b06f5283b447501f01ecece83dfae66.zip sdk-986561291b06f5283b447501f01ecece83dfae66.tar.gz sdk-986561291b06f5283b447501f01ecece83dfae66.tar.bz2 |
Fix 18539: "Extract Android String" mangles the replacement str
The refactoring could end up processing the current Java file twice -
first using the normal code path, and a second time if the "Replace in
All Java Files" checkbox was checked. This second pass would add a
second set of edits which would mangle the file.
Change-Id: I99ed50ab477af12d7fb54a7de6401689dad5d104
Diffstat (limited to 'eclipse/plugins/com.android.ide.eclipse.adt')
-rw-r--r-- | eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactorings/extractstring/ExtractStringRefactoring.java | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactorings/extractstring/ExtractStringRefactoring.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactorings/extractstring/ExtractStringRefactoring.java index f2b9a55..8b2f729 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactorings/extractstring/ExtractStringRefactoring.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactorings/extractstring/ExtractStringRefactoring.java @@ -930,6 +930,8 @@ public class ExtractStringRefactoring extends Refactoring { } if (mReplaceAllJava) { + String currentIdentifier = mUnit != null ? mUnit.getHandleIdentifier() : ""; //$NON-NLS-1$ + SubMonitor submon = SubMonitor.convert(monitor, 1); for (ICompilationUnit unit : findAllJavaUnits()) { // Only process Java compilation units that exist, are not derived @@ -941,6 +943,13 @@ public class ExtractStringRefactoring extends Refactoring { if (resource == null || resource.isDerived()) { continue; } + + // Ensure that we don't process the current compilation unit (processed + // as mUnit above) twice + if (currentIdentifier.equals(unit.getHandleIdentifier())) { + continue; + } + ResourceAttributes attrs = resource.getResourceAttributes(); if (attrs != null && attrs.isReadOnly()) { continue; |