From 986561291b06f5283b447501f01ecece83dfae66 Mon Sep 17 00:00:00 2001 From: Tor Norbye Date: Tue, 26 Jul 2011 18:44:46 -0700 Subject: 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 --- .../refactorings/extractstring/ExtractStringRefactoring.java | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'eclipse') 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; -- cgit v1.1