aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2011-06-09 11:46:40 -0700
committerTor Norbye <tnorbye@google.com>2011-06-09 12:32:21 -0700
commit42b2f34604a3f8e8ac191831d8f01a0498760d38 (patch)
tree87bef940d0d63d29a83a9fa8093265d1dcbb3ed7
parent0fcd2d039245ff3b0bd84d3fc9a2050dd34ad3b0 (diff)
downloadsdk-42b2f34604a3f8e8ac191831d8f01a0498760d38.zip
sdk-42b2f34604a3f8e8ac191831d8f01a0498760d38.tar.gz
sdk-42b2f34604a3f8e8ac191831d8f01a0498760d38.tar.bz2
Fix various warnings
I ran the latest version of findbugs on our codebase and fixed some (not all!) of the warnings. I also ran with Eclipse 3.7 RC3 and updated our compiler warning settings for the new warnings that are available. I also fixed some DOS line endings in some files (formatted with CRLF instead of LF). Change-Id: I9a9d34a9b60f2cb609245793815d96a4587007b0
-rw-r--r--ddms/app/.settings/org.eclipse.jdt.core.prefs9
-rw-r--r--ddms/libs/ddmlib/.settings/org.eclipse.jdt.core.prefs9
-rw-r--r--ddms/libs/ddmuilib/.settings/org.eclipse.jdt.core.prefs9
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/.settings/org.eclipse.jdt.core.prefs9
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/LinearLayoutRule.java8
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/PropertyCallback.java2
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/relative/ConstraintType.java5
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/AndroidContentAssist.java2
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/AndroidSourceViewerConfig.java2
-rwxr-xr-xeclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/export/AbstractPropertiesFieldsPart.java2
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/ConfigurationComposite.java4
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/descriptors/CustomViewDescriptorService.java6
-rwxr-xr-xeclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GCWrapper.java2
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GraphicalEditorPart.java4
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/MarqueeGesture.java2
-rwxr-xr-xeclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/PaletteControl.java4
-rwxr-xr-xeclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/SimpleElement.java2
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/RelativeLayoutConversionHelper.java2
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/WrapInWizard.java2
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/ui/ErrorImageComposite.java4
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/uimodel/UiElementNode.java6
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/xml/Hyperlinks.java2
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/DeviceChooserDialog.java6
-rw-r--r--[-rwxr-xr-x]eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactoring/core/AndroidPackageRenameParticipant.java1060
-rw-r--r--[-rwxr-xr-x]eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactoring/core/AndroidRenameParticipant.java168
-rw-r--r--[-rwxr-xr-x]eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactoring/core/AndroidTypeMoveParticipant.java836
-rw-r--r--[-rwxr-xr-x]eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactoring/core/AndroidTypeRenameParticipant.java766
-rw-r--r--[-rwxr-xr-x]eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactoring/core/FixImportsJob.java290
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactoring/core/RefactoringUtil.java2
-rw-r--r--[-rwxr-xr-x]eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactorings/extractstring/EnabledTextEditGroup.java0
-rw-r--r--[-rwxr-xr-x]eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactorings/extractstring/ReplaceStringsVisitor.java961
-rw-r--r--[-rwxr-xr-x]eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactorings/renamepackage/ApplicationPackageNameRefactoring.java0
-rw-r--r--[-rwxr-xr-x]eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactorings/renamepackage/ApplicationPackageNameRefactoringWizard.java0
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/CyclicDependencyValidator.java4
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ResourceManager.java4
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/sdk/ProjectState.java4
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/newxmlfile/NewXmlFileCreationPage.java4
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/newxmlfile/NewXmlFileWizard.java2
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.ddms/.settings/org.eclipse.jdt.core.prefs9
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/.settings/org.eclipse.jdt.core.prefs9
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.pdt/.settings/org.eclipse.jdt.core.prefs9
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.tests/.settings/org.eclipse.jdt.core.prefs9
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.traceview/.settings/org.eclipse.jdt.core.prefs9
-rw-r--r--ide_common/.settings/org.eclipse.jdt.core.prefs9
-rw-r--r--layoutlib_api/.settings/org.eclipse.jdt.core.prefs9
-rw-r--r--sdkmanager/app/.settings/org.eclipse.jdt.core.prefs9
-rw-r--r--sdkmanager/libs/sdklib/.settings/org.eclipse.jdt.core.prefs9
-rw-r--r--sdkmanager/libs/sdkuilib/.settings/org.eclipse.jdt.core.prefs9
48 files changed, 2195 insertions, 2099 deletions
diff --git a/ddms/app/.settings/org.eclipse.jdt.core.prefs b/ddms/app/.settings/org.eclipse.jdt.core.prefs
index 1cb4685..e755df2 100644
--- a/ddms/app/.settings/org.eclipse.jdt.core.prefs
+++ b/ddms/app/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,4 @@
-#Wed Mar 09 14:02:32 PST 2011
+#Thu Jun 09 12:26:44 PDT 2011
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
@@ -16,6 +16,7 @@ org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
@@ -24,6 +25,7 @@ org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
@@ -37,11 +39,15 @@ org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
@@ -55,6 +61,7 @@ org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverridin
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
diff --git a/ddms/libs/ddmlib/.settings/org.eclipse.jdt.core.prefs b/ddms/libs/ddmlib/.settings/org.eclipse.jdt.core.prefs
index 1cb4685..e755df2 100644
--- a/ddms/libs/ddmlib/.settings/org.eclipse.jdt.core.prefs
+++ b/ddms/libs/ddmlib/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,4 @@
-#Wed Mar 09 14:02:32 PST 2011
+#Thu Jun 09 12:26:44 PDT 2011
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
@@ -16,6 +16,7 @@ org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
@@ -24,6 +25,7 @@ org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
@@ -37,11 +39,15 @@ org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
@@ -55,6 +61,7 @@ org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverridin
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
diff --git a/ddms/libs/ddmuilib/.settings/org.eclipse.jdt.core.prefs b/ddms/libs/ddmuilib/.settings/org.eclipse.jdt.core.prefs
index 1cb4685..e755df2 100644
--- a/ddms/libs/ddmuilib/.settings/org.eclipse.jdt.core.prefs
+++ b/ddms/libs/ddmuilib/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,4 @@
-#Wed Mar 09 14:02:32 PST 2011
+#Thu Jun 09 12:26:44 PDT 2011
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
@@ -16,6 +16,7 @@ org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
@@ -24,6 +25,7 @@ org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
@@ -37,11 +39,15 @@ org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
@@ -55,6 +61,7 @@ org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverridin
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/.settings/org.eclipse.jdt.core.prefs b/eclipse/plugins/com.android.ide.eclipse.adt/.settings/org.eclipse.jdt.core.prefs
index f4696e4..e755df2 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/.settings/org.eclipse.jdt.core.prefs
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,4 @@
-#Wed Mar 16 15:10:40 PDT 2011
+#Thu Jun 09 12:26:44 PDT 2011
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
@@ -16,6 +16,7 @@ org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
@@ -24,6 +25,7 @@ org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
@@ -37,11 +39,15 @@ org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
@@ -55,6 +61,7 @@ org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverridin
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/LinearLayoutRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/LinearLayoutRule.java
index 77cd7fe..ac4b6ff 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/LinearLayoutRule.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/LinearLayoutRule.java
@@ -38,14 +38,14 @@ import com.android.ide.common.api.IMenuCallback;
import com.android.ide.common.api.INode;
import com.android.ide.common.api.INodeHandler;
import com.android.ide.common.api.IViewMetadata;
+import com.android.ide.common.api.IViewMetadata.FillPreference;
import com.android.ide.common.api.IViewRule;
import com.android.ide.common.api.InsertType;
import com.android.ide.common.api.MenuAction;
+import com.android.ide.common.api.MenuAction.OrderedChoices;
import com.android.ide.common.api.Point;
import com.android.ide.common.api.Rect;
import com.android.ide.common.api.SegmentType;
-import com.android.ide.common.api.IViewMetadata.FillPreference;
-import com.android.ide.common.api.MenuAction.OrderedChoices;
import com.android.ide.eclipse.adt.AdtPlugin;
import com.android.sdklib.SdkConstants;
@@ -544,7 +544,7 @@ public class LinearLayoutRule extends BaseLayoutRule {
}
/** A possible match position */
- private class MatchPos {
+ private static class MatchPos {
/** The pixel distance */
private int mDistance;
/** The position among siblings */
@@ -571,7 +571,7 @@ public class LinearLayoutRule extends BaseLayoutRule {
}
}
- private class LinearDropData {
+ private static class LinearDropData {
/** Vertical layout? */
private final boolean mVertical;
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/PropertyCallback.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/PropertyCallback.java
index 4024d5a..559aac8 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/PropertyCallback.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/PropertyCallback.java
@@ -44,7 +44,7 @@ public class PropertyCallback implements IMenuCallback {
// ---- Implements IMenuCallback ----
public void action(MenuAction action, final String valueId, final Boolean newValue) {
- if (mTargetNodes != null && mTargetNodes.size() == 0) {
+ if (mTargetNodes == null || mTargetNodes.size() == 0) {
return;
}
mTargetNodes.get(0).editXml(mUndoLabel, new INodeHandler() {
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/relative/ConstraintType.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/relative/ConstraintType.java
index 8488760..7c6fae8 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/relative/ConstraintType.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/relative/ConstraintType.java
@@ -141,10 +141,11 @@ enum ConstraintType {
public static ConstraintType fromAttribute(String attribute) {
if (sNameToType == null) {
ConstraintType[] types = ConstraintType.values();
- sNameToType = new HashMap<String, ConstraintType>(types.length);
+ Map<String, ConstraintType> map = new HashMap<String, ConstraintType>(types.length);
for (ConstraintType type : types) {
- sNameToType.put(type.name, type);
+ map.put(type.name, type);
}
+ sNameToType = map;
}
return sNameToType.get(attribute);
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/AndroidContentAssist.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/AndroidContentAssist.java
index 46af01e..f28c681 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/AndroidContentAssist.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/AndroidContentAssist.java
@@ -550,7 +550,7 @@ public abstract class AndroidContentAssist implements IContentAssistProcessor {
}
int replaceLength = 0;
addMatchingProposals(proposals, choices,
- offset, parentNode != null ? parentNode : null, wordPrefix, needTag,
+ offset, parentNode, wordPrefix, needTag,
false /* isAttribute */,
false /*isNew*/,
false /*isComplete*/,
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/AndroidSourceViewerConfig.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/AndroidSourceViewerConfig.java
index 5a38fec..33203b2 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/AndroidSourceViewerConfig.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/AndroidSourceViewerConfig.java
@@ -129,7 +129,7 @@ public class AndroidSourceViewerConfig extends StructuredTextViewerConfiguration
* A delegating {@link IContentAssistProcessor} whose purpose is to filter out some
* default Eclipse XML completions which are distracting in Android XML files
*/
- private class FilteringContentAssistProcessor implements IContentAssistProcessor {
+ private static class FilteringContentAssistProcessor implements IContentAssistProcessor {
private IContentAssistProcessor mDelegate;
public FilteringContentAssistProcessor(IContentAssistProcessor delegate) {
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/export/AbstractPropertiesFieldsPart.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/export/AbstractPropertiesFieldsPart.java
index 0d72614..434c217 100755
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/export/AbstractPropertiesFieldsPart.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/export/AbstractPropertiesFieldsPart.java
@@ -205,7 +205,7 @@ abstract class AbstractPropertiesFieldsPart extends ManifestSectionPart {
numLines = doc.getNumberOfLines();
IRegion info = numLines > 0 ? doc.getLineInformation(numLines - 1) : null;
- if (info.getLength() == 0) {
+ if (info != null && info.getLength() == 0) {
// last line is empty. Insert right before there.
doc.replace(info.getOffset(), info.getLength(), line);
} else {
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/ConfigurationComposite.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/ConfigurationComposite.java
index 4c6bac8..413ebde 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/ConfigurationComposite.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/ConfigurationComposite.java
@@ -44,9 +44,9 @@ import com.android.ide.eclipse.adt.internal.resources.manager.ProjectResources;
import com.android.ide.eclipse.adt.internal.resources.manager.ResourceManager;
import com.android.ide.eclipse.adt.internal.sdk.AndroidTargetData;
import com.android.ide.eclipse.adt.internal.sdk.LayoutDevice;
+import com.android.ide.eclipse.adt.internal.sdk.LayoutDevice.DeviceConfig;
import com.android.ide.eclipse.adt.internal.sdk.LayoutDeviceManager;
import com.android.ide.eclipse.adt.internal.sdk.Sdk;
-import com.android.ide.eclipse.adt.internal.sdk.LayoutDevice.DeviceConfig;
import com.android.resources.Density;
import com.android.resources.DockMode;
import com.android.resources.NightMode;
@@ -1463,7 +1463,7 @@ public class ConfigurationComposite extends Composite {
mIsProjectTheme.clear();
ArrayList<String> themes = new ArrayList<String>();
- String includedIn = mListener != null ? mListener.getIncludedWithin() : null;
+ String includedIn = mListener.getIncludedWithin();
// First list any themes that are declared by the manifest
if (mEditedFile != null) {
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/descriptors/CustomViewDescriptorService.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/descriptors/CustomViewDescriptorService.java
index de8a83d..75fdf5b 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/descriptors/CustomViewDescriptorService.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/descriptors/CustomViewDescriptorService.java
@@ -294,18 +294,18 @@ public final class CustomViewDescriptorService {
* @param type the type for which the {@link AttributeDescriptor} are returned.
* @param parentDescriptor the {@link ViewElementDescriptor} of the direct superclass.
*/
- private AttributeDescriptor[] getAttributeDescriptor(IType type,
+ private static AttributeDescriptor[] getAttributeDescriptor(IType type,
ViewElementDescriptor parentDescriptor) {
// TODO add the class attribute descriptors to the parent descriptors.
return parentDescriptor.getAttributes();
}
- private AttributeDescriptor[] getLayoutAttributeDescriptors(IType type,
+ private static AttributeDescriptor[] getLayoutAttributeDescriptors(IType type,
ViewElementDescriptor parentDescriptor) {
return parentDescriptor.getLayoutAttributes();
}
- private class CustomViewDescriptor extends ViewElementDescriptor {
+ private static class CustomViewDescriptor extends ViewElementDescriptor {
public CustomViewDescriptor(String name, String fqcn, AttributeDescriptor[] attributes,
AttributeDescriptor[] layoutAttributes,
ElementDescriptor[] children) {
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GCWrapper.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GCWrapper.java
index fd4f47e..cd4105d 100755
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GCWrapper.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GCWrapper.java
@@ -58,7 +58,7 @@ public class GCWrapper implements IGraphics {
/**
* Implementation of IColor wrapping an SWT color.
*/
- private class ColorWrapper implements IColor {
+ private static class ColorWrapper implements IColor {
private final Color mColor;
public ColorWrapper(Color color) {
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GraphicalEditorPart.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GraphicalEditorPart.java
index b4ff869..176b7bd 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GraphicalEditorPart.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GraphicalEditorPart.java
@@ -43,12 +43,12 @@ import com.android.ide.eclipse.adt.internal.editors.IPageImageProvider;
import com.android.ide.eclipse.adt.internal.editors.IconFactory;
import com.android.ide.eclipse.adt.internal.editors.layout.LayoutEditor;
import com.android.ide.eclipse.adt.internal.editors.layout.LayoutReloadMonitor;
-import com.android.ide.eclipse.adt.internal.editors.layout.ProjectCallback;
import com.android.ide.eclipse.adt.internal.editors.layout.LayoutReloadMonitor.ChangeFlags;
import com.android.ide.eclipse.adt.internal.editors.layout.LayoutReloadMonitor.ILayoutReloadListener;
+import com.android.ide.eclipse.adt.internal.editors.layout.ProjectCallback;
import com.android.ide.eclipse.adt.internal.editors.layout.configuration.ConfigurationComposite;
-import com.android.ide.eclipse.adt.internal.editors.layout.configuration.LayoutCreatorDialog;
import com.android.ide.eclipse.adt.internal.editors.layout.configuration.ConfigurationComposite.IConfigListener;
+import com.android.ide.eclipse.adt.internal.editors.layout.configuration.LayoutCreatorDialog;
import com.android.ide.eclipse.adt.internal.editors.layout.descriptors.LayoutDescriptors;
import com.android.ide.eclipse.adt.internal.editors.layout.descriptors.ViewElementDescriptor;
import com.android.ide.eclipse.adt.internal.editors.layout.gle2.IncludeFinder.Reference;
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/MarqueeGesture.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/MarqueeGesture.java
index b6f47bb..d0ef9b7 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/MarqueeGesture.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/MarqueeGesture.java
@@ -93,7 +93,7 @@ public class MarqueeGesture extends Gesture {
* overlay rectangle matching the mouse coordinate delta between gesture
* start and the current position.
*/
- private class MarqueeOverlay extends Overlay {
+ private static class MarqueeOverlay extends Overlay {
/** Rectangle border color. */
private Color mStroke;
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/PaletteControl.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/PaletteControl.java
index f4248b5..4b6cab1 100755
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/PaletteControl.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/PaletteControl.java
@@ -23,8 +23,8 @@ import static com.android.ide.common.layout.LayoutConstants.ATTR_TEXT;
import static com.android.ide.common.layout.LayoutConstants.VALUE_WRAP_CONTENT;
import com.android.ide.common.api.InsertType;
-import com.android.ide.common.api.Rect;
import com.android.ide.common.api.MenuAction.Toggle;
+import com.android.ide.common.api.Rect;
import com.android.ide.common.rendering.LayoutLibrary;
import com.android.ide.common.rendering.api.Capability;
import com.android.ide.common.rendering.api.LayoutLog;
@@ -676,7 +676,7 @@ public class PaletteControl extends Composite {
* An Item widget represents one {@link ElementDescriptor} that can be dropped on the
* GLE2 canvas using drag'n'drop.
*/
- private class IconTextItem extends CLabel implements MouseTrackListener {
+ private static class IconTextItem extends CLabel implements MouseTrackListener {
private boolean mMouseIn;
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/SimpleElement.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/SimpleElement.java
index 42c49cc..20a8433 100755
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/SimpleElement.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/SimpleElement.java
@@ -290,7 +290,7 @@ public class SimpleElement implements IDragElement {
mAttributes.size() == se.mAttributes.size() &&
mElements.size() == se.mElements.size() &&
mAttributes.equals(se.mAttributes) &&
- mElements.equals(mElements);
+ mElements.equals(se.mElements);
}
return false;
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/RelativeLayoutConversionHelper.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/RelativeLayoutConversionHelper.java
index 193c3c0..51bbc38 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/RelativeLayoutConversionHelper.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/RelativeLayoutConversionHelper.java
@@ -557,7 +557,7 @@ class RelativeLayoutConversionHelper {
}
}
- if (baselineRef != null && !baselineRef.equals(childView.getId())) {
+ if (baselineRef != null && !baselineRef.getId().equals(childView.getId())) {
assert !isVertical;
// Only align if they share the same gravity
if ((childView.getGravity() & GRAVITY_VERT_MASK) ==
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/WrapInWizard.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/WrapInWizard.java
index 69df9a1..11022a2 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/WrapInWizard.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/WrapInWizard.java
@@ -250,7 +250,7 @@ public class WrapInWizard extends VisualRefactoringWizard {
for (ViewElementDescriptor d : layoutDescriptors) {
String className = d.getFullClassName();
- if (exclude == null || !exclude.equals(className)) {
+ if (exclude == null || !exclude.contains(className)) {
combo.add(d.getUiName());
classNames.add(Pair.of(className, d));
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/ui/ErrorImageComposite.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/ui/ErrorImageComposite.java
index a70cf90..f6ec863 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/ui/ErrorImageComposite.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/ui/ErrorImageComposite.java
@@ -25,14 +25,14 @@ public class ErrorImageComposite extends CompositeImageDescriptor {
ISharedImages.IMG_OBJS_ERROR_TSK);
mSize = new Point(baseImage.getBounds().width, baseImage.getBounds().height);
}
-
+
@Override
protected void drawCompositeImage(int width, int height) {
ImageData baseData = mBaseImage.getImageData();
drawImage(baseData, 0, 0);
ImageData overlayData = mErrorImageDescriptor.getImageData();
- if (overlayData.width == baseData.width && baseData.height == baseData.height) {
+ if (overlayData.width == baseData.width && overlayData.height == baseData.height) {
overlayData = overlayData.scaledTo(14, 14);
drawImage(overlayData, -3, mSize.y - overlayData.height + 3);
} else {
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/uimodel/UiElementNode.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/uimodel/UiElementNode.java
index 0e780d1..6506b58 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/uimodel/UiElementNode.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/uimodel/UiElementNode.java
@@ -31,11 +31,11 @@ import com.android.ide.eclipse.adt.AdtPlugin;
import com.android.ide.eclipse.adt.internal.editors.AndroidXmlEditor;
import com.android.ide.eclipse.adt.internal.editors.descriptors.AttributeDescriptor;
import com.android.ide.eclipse.adt.internal.editors.descriptors.ElementDescriptor;
+import com.android.ide.eclipse.adt.internal.editors.descriptors.ElementDescriptor.Mandatory;
import com.android.ide.eclipse.adt.internal.editors.descriptors.IUnknownDescriptorProvider;
import com.android.ide.eclipse.adt.internal.editors.descriptors.SeparatorAttributeDescriptor;
import com.android.ide.eclipse.adt.internal.editors.descriptors.TextAttributeDescriptor;
import com.android.ide.eclipse.adt.internal.editors.descriptors.XmlnsAttributeDescriptor;
-import com.android.ide.eclipse.adt.internal.editors.descriptors.ElementDescriptor.Mandatory;
import com.android.ide.eclipse.adt.internal.editors.layout.descriptors.LayoutDescriptors;
import com.android.ide.eclipse.adt.internal.editors.manifest.descriptors.AndroidManifestDescriptors;
import com.android.ide.eclipse.adt.internal.editors.resources.descriptors.ResourcesDescriptors;
@@ -63,8 +63,8 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import java.util.Map.Entry;
+import java.util.Set;
/**
* Represents an XML node that can be modified by the user interface in the XML editor.
@@ -1581,7 +1581,7 @@ public class UiElementNode implements IPropertySource {
// Ask the document about it. This method may not be implemented by the Document.
String nsPrefix = null;
try {
- nsPrefix = doc.lookupPrefix(nsUri);
+ nsPrefix = doc != null ? doc.lookupPrefix(nsUri) : null;
if (nsPrefix != null) {
return nsPrefix;
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/xml/Hyperlinks.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/xml/Hyperlinks.java
index ae84f13..817fcbe 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/xml/Hyperlinks.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/xml/Hyperlinks.java
@@ -1509,7 +1509,7 @@ public class Hyperlinks {
return;
}
- IAbstractFile wrappedFile = mFile.getFile();
+ IAbstractFile wrappedFile = mFile != null ? mFile.getFile() : null;
if (wrappedFile instanceof IFileWrapper) {
IFile file = ((IFileWrapper) wrappedFile).getIFile();
try {
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/DeviceChooserDialog.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/DeviceChooserDialog.java
index b0dfea3..609dc35 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/DeviceChooserDialog.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/DeviceChooserDialog.java
@@ -17,9 +17,9 @@
package com.android.ide.eclipse.adt.internal.launch;
import com.android.ddmlib.AndroidDebugBridge;
+import com.android.ddmlib.AndroidDebugBridge.IDeviceChangeListener;
import com.android.ddmlib.Client;
import com.android.ddmlib.IDevice;
-import com.android.ddmlib.AndroidDebugBridge.IDeviceChangeListener;
import com.android.ddmlib.IDevice.DeviceState;
import com.android.ddmuilib.ImageLoader;
import com.android.ddmuilib.TableHelper;
@@ -90,7 +90,7 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
* Basic Content Provider for a table full of {@link IDevice} objects. The input is
* a {@link AndroidDebugBridge}.
*/
- private class ContentProvider implements IStructuredContentProvider {
+ private static class ContentProvider implements IStructuredContentProvider {
public Object[] getElements(Object inputElement) {
if (inputElement instanceof AndroidDebugBridge) {
return ((AndroidDebugBridge)inputElement).getDevices();
@@ -462,7 +462,7 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
}
if (mWarningImage == null) {
- mNoMatchImage = factory.getIcon("warning", //$NON-NLS-1$
+ mWarningImage = factory.getIcon("warning", //$NON-NLS-1$
SWT.COLOR_YELLOW,
IconFactory.SHAPE_DEFAULT);
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactoring/core/AndroidPackageRenameParticipant.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactoring/core/AndroidPackageRenameParticipant.java
index 3a8348d..fd726de 100755..100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactoring/core/AndroidPackageRenameParticipant.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactoring/core/AndroidPackageRenameParticipant.java
@@ -1,530 +1,530 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Eclipse Public License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.eclipse.org/org/documents/epl-v10.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ide.eclipse.adt.internal.refactoring.core;
-
-import com.android.AndroidConstants;
-import com.android.ide.common.layout.LayoutConstants;
-import com.android.ide.eclipse.adt.AdtConstants;
-import com.android.ide.eclipse.adt.internal.project.AndroidManifestHelper;
-import com.android.ide.eclipse.adt.internal.refactoring.changes.AndroidLayoutChange;
-import com.android.ide.eclipse.adt.internal.refactoring.changes.AndroidLayoutChangeDescription;
-import com.android.ide.eclipse.adt.internal.refactoring.changes.AndroidLayoutFileChanges;
-import com.android.ide.eclipse.adt.internal.refactoring.changes.AndroidPackageRenameChange;
-import com.android.sdklib.SdkConstants;
-import com.android.sdklib.xml.AndroidManifest;
-import com.android.sdklib.xml.ManifestData;
-
-import org.eclipse.core.filebuffers.FileBuffers;
-import org.eclipse.core.filebuffers.ITextFileBuffer;
-import org.eclipse.core.filebuffers.ITextFileBufferManager;
-import org.eclipse.core.filebuffers.LocationKind;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.search.IJavaSearchConstants;
-import org.eclipse.jdt.core.search.IJavaSearchScope;
-import org.eclipse.jdt.core.search.SearchEngine;
-import org.eclipse.jdt.core.search.SearchMatch;
-import org.eclipse.jdt.core.search.SearchParticipant;
-import org.eclipse.jdt.core.search.SearchPattern;
-import org.eclipse.jdt.core.search.SearchRequestor;
-import org.eclipse.jdt.internal.corext.refactoring.changes.RenamePackageChange;
-import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.ltk.core.refactoring.Change;
-import org.eclipse.ltk.core.refactoring.CompositeChange;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.w3c.dom.Attr;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * A participant to participate in refactorings that rename a package in an Android project.
- * The class updates android manifest and the layout file
- * The user can suppress refactoring by disabling the "Update references" checkbox
- * <p>
- * Rename participants are registered via the extension point <code>
- * org.eclipse.ltk.core.refactoring.renameParticipants</code>.
- * Extensions to this extension point must therefore extend
- * <code>org.eclipse.ltk.core.refactoring.participants.RenameParticipant</code>.
- * </p>
- */
-@SuppressWarnings("restriction")
-public class AndroidPackageRenameParticipant extends AndroidRenameParticipant {
-
- private IPackageFragment mPackageFragment;
-
- private boolean mIsPackage;
-
- private Set<AndroidLayoutFileChanges> mFileChanges = new HashSet<AndroidLayoutFileChanges>();
-
- @Override
- public Change createChange(IProgressMonitor pm) throws CoreException,
- OperationCanceledException {
- if (pm.isCanceled()) {
- return null;
- }
- if (!getArguments().getUpdateReferences())
- return null;
- IPath pkgPath = mPackageFragment.getPath();
- IJavaProject javaProject = (IJavaProject) mPackageFragment
- .getAncestor(IJavaElement.JAVA_PROJECT);
- IProject project = javaProject.getProject();
- IPath genPath = project.getFullPath().append(SdkConstants.FD_GEN_SOURCES);
- if (genPath.isPrefixOf(pkgPath)) {
- RefactoringUtil.logInfo(getName() + ": Cannot rename generated package.");
- return null;
- }
- CompositeChange result = new CompositeChange(getName());
- if (mAndroidManifest.exists()) {
- if (mAndroidElements.size() > 0 || mIsPackage) {
- getDocument();
- Change change = new AndroidPackageRenameChange(mAndroidManifest, mManager,
- mDocument, mAndroidElements, mNewName, mOldName, mIsPackage);
- if (change != null) {
- result.add(change);
- }
- }
- if (mIsPackage) {
- Change genChange = getGenPackageChange(pm);
- if (genChange != null) {
- result.add(genChange);
- }
- }
- // add layoutChange
- for (AndroidLayoutFileChanges fileChange : mFileChanges) {
- IFile file = fileChange.getFile();
- ITextFileBufferManager lManager = FileBuffers.getTextFileBufferManager();
- lManager.connect(file.getFullPath(), LocationKind.NORMALIZE,
- new NullProgressMonitor());
- ITextFileBuffer buffer = lManager.getTextFileBuffer(file.getFullPath(),
- LocationKind.NORMALIZE);
- IDocument lDocument = buffer.getDocument();
- Change layoutChange = new AndroidLayoutChange(file, lDocument, lManager,
- fileChange.getChanges());
- if (layoutChange != null) {
- result.add(layoutChange);
- }
- }
- }
- return (result.getChildren().length == 0) ? null : result;
- }
-
- /**
- * Returns Android gen package text change
- *
- * @param pm the progress monitor
- *
- * @return Android gen package text change
- * @throws CoreException
- * @throws OperationCanceledException
- */
- public Change getGenPackageChange(IProgressMonitor pm) throws CoreException,
- OperationCanceledException {
- if (mIsPackage) {
- IPackageFragment genJavaPackageFragment = getGenPackageFragment();
- if (genJavaPackageFragment != null && genJavaPackageFragment.exists()) {
- return new RenamePackageChange(genJavaPackageFragment, mNewName, true);
- }
- }
- return null;
- }
-
- /**
- * Return the gen package fragment
- *
- */
- private IPackageFragment getGenPackageFragment() throws JavaModelException {
- IJavaProject javaProject = (IJavaProject) mPackageFragment
- .getAncestor(IJavaElement.JAVA_PROJECT);
- if (javaProject != null && javaProject.isOpen()) {
- IProject project = javaProject.getProject();
- IFolder genFolder = project.getFolder(SdkConstants.FD_GEN_SOURCES);
- if (genFolder.exists()) {
- String javaPackagePath = mAppPackage.replace(".", "/");
- IPath genJavaPackagePath = genFolder.getFullPath().append(javaPackagePath);
- IPackageFragment genPackageFragment = javaProject
- .findPackageFragment(genJavaPackagePath);
- return genPackageFragment;
- }
- }
- return null;
- }
-
- @Override
- public String getName() {
- return "Android Package Rename";
- }
-
- @Override
- protected boolean initialize(final Object element) {
- mIsPackage = false;
- try {
- if (element instanceof IPackageFragment) {
- mPackageFragment = (IPackageFragment) element;
- if (!mPackageFragment.containsJavaResources())
- return false;
- IJavaProject javaProject = (IJavaProject) mPackageFragment
- .getAncestor(IJavaElement.JAVA_PROJECT);
- IProject project = javaProject.getProject();
- IResource manifestResource = project.findMember(AdtConstants.WS_SEP
- + SdkConstants.FN_ANDROID_MANIFEST_XML);
-
- if (manifestResource == null || !manifestResource.exists()
- || !(manifestResource instanceof IFile)) {
- RefactoringUtil.logInfo("Invalid or missing the "
- + SdkConstants.FN_ANDROID_MANIFEST_XML + " in the " + project.getName()
- + " project.");
- return false;
- }
- mAndroidManifest = (IFile) manifestResource;
- String packageName = mPackageFragment.getElementName();
- ManifestData manifestData;
- manifestData = AndroidManifestHelper.parseForData(mAndroidManifest);
- if (manifestData == null) {
- return false;
- }
- mAppPackage = manifestData.getPackage();
- mOldName = packageName;
- mNewName = getArguments().getNewName();
- if (mOldName == null || mNewName == null) {
- return false;
- }
-
- if (RefactoringUtil.isRefactorAppPackage()
- && mAppPackage != null
- && mAppPackage.equals(packageName)) {
- mIsPackage = true;
- }
- mAndroidElements = addAndroidElements();
- try {
- final IType type = javaProject.findType(SdkConstants.CLASS_VIEW);
- SearchPattern pattern = SearchPattern.createPattern("*",
- IJavaSearchConstants.TYPE, IJavaSearchConstants.DECLARATIONS,
- SearchPattern.R_REGEXP_MATCH);
- IJavaSearchScope scope =SearchEngine.createJavaSearchScope(
- new IJavaElement[] { mPackageFragment });
- final HashSet<IType> elements = new HashSet<IType>();
- SearchRequestor requestor = new SearchRequestor() {
-
- @Override
- public void acceptSearchMatch(SearchMatch match) throws CoreException {
- Object elem = match.getElement();
- if (elem instanceof IType) {
- IType eType = (IType) elem;
- IType[] superTypes = JavaModelUtil.getAllSuperTypes(eType,
- new NullProgressMonitor());
- for (int i = 0; i < superTypes.length; i++) {
- if (superTypes[i].equals(type)) {
- elements.add(eType);
- break;
- }
- }
- }
-
- }
- };
- SearchEngine searchEngine = new SearchEngine();
- searchEngine.search(pattern, new SearchParticipant[] {
- SearchEngine.getDefaultSearchParticipant()
- }, scope, requestor, null);
- List<String> views = new ArrayList<String>();
- for (IType elem : elements) {
- views.add(elem.getFullyQualifiedName());
- }
- if (views.size() > 0) {
- String[] classNames = views.toArray(new String[0]);
- addLayoutChanges(project, classNames);
- }
- } catch (CoreException e) {
- RefactoringUtil.log(e);
- }
-
- return mIsPackage || mAndroidElements.size() > 0 || mFileChanges.size() > 0;
- }
- } catch (JavaModelException ignore) {
- }
- return false;
- }
-
- /**
- * Adds layout changes for project
- *
- * @param project the Android project
- * @param classNames the layout classes
- */
- private void addLayoutChanges(IProject project, String[] classNames) {
- try {
- IFolder resFolder = project.getFolder(SdkConstants.FD_RESOURCES);
- IResource[] layoutMembers = resFolder.members();
- for (int j = 0; j < layoutMembers.length; j++) {
- IResource resource = layoutMembers[j];
- if (resource instanceof IFolder
- && resource.exists()
- && resource.getName().startsWith(AndroidConstants.FD_RES_LAYOUT)) {
- IFolder layoutFolder = (IFolder) resource;
- IResource[] members = layoutFolder.members();
- for (int i = 0; i < members.length; i++) {
- IResource member = members[i];
- if ((member instanceof IFile)
- && member.exists()
- && member.getName().endsWith(".xml")) { //$NON-NLS-1$
- IFile file = (IFile) member;
- Set<AndroidLayoutChangeDescription> changes =
- parse(file, classNames);
- if (changes.size() > 0) {
- AndroidLayoutFileChanges fileChange =
- new AndroidLayoutFileChanges(file);
- fileChange.getChanges().addAll(changes);
- mFileChanges.add(fileChange);
- }
- }
- }
- }
- }
- } catch (CoreException e) {
- RefactoringUtil.log(e);
- }
- }
-
- /**
- * Searches the layout file for classes
- *
- * @param file the Android layout file
- * @param classNames the layout classes
- */
- private Set<AndroidLayoutChangeDescription> parse(IFile file, String[] classNames) {
- Set<AndroidLayoutChangeDescription> changes =
- new HashSet<AndroidLayoutChangeDescription>();
- ITextFileBufferManager lManager = null;
- try {
- lManager = FileBuffers.getTextFileBufferManager();
- lManager.connect(file.getFullPath(),
- LocationKind.NORMALIZE, new NullProgressMonitor());
- ITextFileBuffer buffer = lManager.getTextFileBuffer(file.getFullPath(),
- LocationKind.NORMALIZE);
- IDocument lDocument = buffer.getDocument();
- IStructuredModel model = null;
- try {
- model = StructuredModelManager.getModelManager().
- getExistingModelForRead(lDocument);
- if (model == null) {
- if (lDocument instanceof IStructuredDocument) {
- IStructuredDocument structuredDocument = (IStructuredDocument) lDocument;
- model = StructuredModelManager.getModelManager().getModelForRead(
- structuredDocument);
- }
- }
- if (model != null) {
- IDOMModel xmlModel = (IDOMModel) model;
- IDOMDocument xmlDoc = xmlModel.getDocument();
- NodeList nodes = xmlDoc.getElementsByTagName(LayoutConstants.VIEW);
- for (int i = 0; i < nodes.getLength(); i++) {
- Node node = nodes.item(i);
- NamedNodeMap attributes = node.getAttributes();
- if (attributes != null) {
- Node attributeNode = attributes
- .getNamedItem(LayoutConstants.ATTR_CLASS);
- if (attributeNode != null || attributeNode instanceof Attr) {
- Attr attribute = (Attr) attributeNode;
- String value = attribute.getValue();
- if (value != null) {
- for (int j = 0; j < classNames.length; j++) {
- String className = classNames[j];
- if (value.equals(className)) {
- String newClassName = getNewClassName(className);
- AndroidLayoutChangeDescription layoutChange =
- new AndroidLayoutChangeDescription(
- className, newClassName,
- AndroidLayoutChangeDescription.VIEW_TYPE);
- changes.add(layoutChange);
- }
- }
- }
- }
- }
- }
- for (int j = 0; j < classNames.length; j++) {
- String className = classNames[j];
- nodes = xmlDoc.getElementsByTagName(className);
- for (int i = 0; i < nodes.getLength(); i++) {
- String newClassName = getNewClassName(className);
- AndroidLayoutChangeDescription layoutChange =
- new AndroidLayoutChangeDescription(
- className, newClassName,
- AndroidLayoutChangeDescription.STANDALONE_TYPE);
- changes.add(layoutChange);
- }
- }
- }
- } finally {
- if (model != null) {
- model.releaseFromRead();
- }
- }
-
- } catch (CoreException ignore) {
- } finally {
- if (lManager != null) {
- try {
- lManager.disconnect(file.getFullPath(), LocationKind.NORMALIZE,
- new NullProgressMonitor());
- } catch (CoreException ignore) {
- }
- }
- }
- return changes;
- }
-
- /**
- * Returns the new class name
- *
- * @param className the class name
- * @return the new class name
- */
- private String getNewClassName(String className) {
- int lastDot = className.lastIndexOf("."); //$NON-NLS-1$
- if (lastDot < 0) {
- return mNewName;
- }
- String name = className.substring(lastDot, className.length());
- String newClassName = mNewName + name;
- return newClassName;
- }
-
- /**
- * Returns the elements (activity, receiver, service ...)
- * which have to be renamed
- *
- * @return the android elements
- */
- private Map<String, String> addAndroidElements() {
- Map<String, String> androidElements = new HashMap<String, String>();
-
- IDocument document;
- try {
- document = getDocument();
- } catch (CoreException e) {
- RefactoringUtil.log(e);
- if (mManager != null) {
- try {
- mManager.disconnect(mAndroidManifest.getFullPath(), LocationKind.NORMALIZE,
- new NullProgressMonitor());
- } catch (CoreException e1) {
- RefactoringUtil.log(e1);
- }
- }
- document = null;
- return androidElements;
- }
-
- IStructuredModel model = null;
- try {
- model = StructuredModelManager.getModelManager().getExistingModelForRead(document);
- if (model == null) {
- if (document instanceof IStructuredDocument) {
- IStructuredDocument structuredDocument = (IStructuredDocument) document;
- model = StructuredModelManager.getModelManager().getModelForRead(
- structuredDocument);
- }
- }
- if (model != null) {
- IDOMModel xmlModel = (IDOMModel) model;
- IDOMDocument xmlDoc = xmlModel.getDocument();
- add(xmlDoc, androidElements, AndroidManifest.NODE_ACTIVITY,
- AndroidManifest.ATTRIBUTE_NAME);
- add(xmlDoc, androidElements, AndroidManifest.NODE_APPLICATION,
- AndroidManifest.ATTRIBUTE_NAME);
- add(xmlDoc, androidElements, AndroidManifest.NODE_PROVIDER,
- AndroidManifest.ATTRIBUTE_NAME);
- add(xmlDoc, androidElements, AndroidManifest.NODE_RECEIVER,
- AndroidManifest.ATTRIBUTE_NAME);
- add(xmlDoc, androidElements, AndroidManifest.NODE_SERVICE,
- AndroidManifest.ATTRIBUTE_NAME);
- }
- } finally {
- if (model != null) {
- model.releaseFromRead();
- }
- }
-
- return androidElements;
- }
-
- /**
- * Adds the element (activity, receiver, service ...) to the map
- *
- * @param xmlDoc the document
- * @param androidElements the map
- * @param element the element
- */
- private void add(IDOMDocument xmlDoc, Map<String, String> androidElements, String element,
- String argument) {
- NodeList nodes = xmlDoc.getElementsByTagName(element);
- for (int i = 0; i < nodes.getLength(); i++) {
- Node node = nodes.item(i);
- NamedNodeMap attributes = node.getAttributes();
- if (attributes != null) {
- Attr attribute = RefactoringUtil.findAndroidAttributes(attributes, argument);
- if (attribute != null) {
- String value = attribute.getValue();
- if (value != null) {
- String fullName = AndroidManifest.combinePackageAndClassName(mAppPackage,
- value);
- if (RefactoringUtil.isRefactorAppPackage()) {
- if (fullName != null && fullName.startsWith(mAppPackage)) {
- boolean startWithDot = (value.charAt(0) == '.');
- boolean hasDot = (value.indexOf('.') != -1);
- if (!startWithDot && hasDot) {
- androidElements.put(element, value);
- }
- }
- } else {
- if (fullName != null) {
- androidElements.put(element, value);
- }
- }
- }
- }
- }
- }
- }
-
-}
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/org/documents/epl-v10.php
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.ide.eclipse.adt.internal.refactoring.core;
+
+import com.android.AndroidConstants;
+import com.android.ide.common.layout.LayoutConstants;
+import com.android.ide.eclipse.adt.AdtConstants;
+import com.android.ide.eclipse.adt.internal.project.AndroidManifestHelper;
+import com.android.ide.eclipse.adt.internal.refactoring.changes.AndroidLayoutChange;
+import com.android.ide.eclipse.adt.internal.refactoring.changes.AndroidLayoutChangeDescription;
+import com.android.ide.eclipse.adt.internal.refactoring.changes.AndroidLayoutFileChanges;
+import com.android.ide.eclipse.adt.internal.refactoring.changes.AndroidPackageRenameChange;
+import com.android.sdklib.SdkConstants;
+import com.android.sdklib.xml.AndroidManifest;
+import com.android.sdklib.xml.ManifestData;
+
+import org.eclipse.core.filebuffers.FileBuffers;
+import org.eclipse.core.filebuffers.ITextFileBuffer;
+import org.eclipse.core.filebuffers.ITextFileBufferManager;
+import org.eclipse.core.filebuffers.LocationKind;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.search.IJavaSearchConstants;
+import org.eclipse.jdt.core.search.IJavaSearchScope;
+import org.eclipse.jdt.core.search.SearchEngine;
+import org.eclipse.jdt.core.search.SearchMatch;
+import org.eclipse.jdt.core.search.SearchParticipant;
+import org.eclipse.jdt.core.search.SearchPattern;
+import org.eclipse.jdt.core.search.SearchRequestor;
+import org.eclipse.jdt.internal.corext.refactoring.changes.RenamePackageChange;
+import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.CompositeChange;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.w3c.dom.Attr;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * A participant to participate in refactorings that rename a package in an Android project.
+ * The class updates android manifest and the layout file
+ * The user can suppress refactoring by disabling the "Update references" checkbox
+ * <p>
+ * Rename participants are registered via the extension point <code>
+ * org.eclipse.ltk.core.refactoring.renameParticipants</code>.
+ * Extensions to this extension point must therefore extend
+ * <code>org.eclipse.ltk.core.refactoring.participants.RenameParticipant</code>.
+ * </p>
+ */
+@SuppressWarnings("restriction")
+public class AndroidPackageRenameParticipant extends AndroidRenameParticipant {
+
+ private IPackageFragment mPackageFragment;
+
+ private boolean mIsPackage;
+
+ private Set<AndroidLayoutFileChanges> mFileChanges = new HashSet<AndroidLayoutFileChanges>();
+
+ @Override
+ public Change createChange(IProgressMonitor pm) throws CoreException,
+ OperationCanceledException {
+ if (pm.isCanceled()) {
+ return null;
+ }
+ if (!getArguments().getUpdateReferences())
+ return null;
+ IPath pkgPath = mPackageFragment.getPath();
+ IJavaProject javaProject = (IJavaProject) mPackageFragment
+ .getAncestor(IJavaElement.JAVA_PROJECT);
+ IProject project = javaProject.getProject();
+ IPath genPath = project.getFullPath().append(SdkConstants.FD_GEN_SOURCES);
+ if (genPath.isPrefixOf(pkgPath)) {
+ RefactoringUtil.logInfo(getName() + ": Cannot rename generated package.");
+ return null;
+ }
+ CompositeChange result = new CompositeChange(getName());
+ if (mAndroidManifest.exists()) {
+ if (mAndroidElements.size() > 0 || mIsPackage) {
+ getDocument();
+ Change change = new AndroidPackageRenameChange(mAndroidManifest, mManager,
+ mDocument, mAndroidElements, mNewName, mOldName, mIsPackage);
+ if (change != null) {
+ result.add(change);
+ }
+ }
+ if (mIsPackage) {
+ Change genChange = getGenPackageChange(pm);
+ if (genChange != null) {
+ result.add(genChange);
+ }
+ }
+ // add layoutChange
+ for (AndroidLayoutFileChanges fileChange : mFileChanges) {
+ IFile file = fileChange.getFile();
+ ITextFileBufferManager lManager = FileBuffers.getTextFileBufferManager();
+ lManager.connect(file.getFullPath(), LocationKind.NORMALIZE,
+ new NullProgressMonitor());
+ ITextFileBuffer buffer = lManager.getTextFileBuffer(file.getFullPath(),
+ LocationKind.NORMALIZE);
+ IDocument lDocument = buffer.getDocument();
+ Change layoutChange = new AndroidLayoutChange(file, lDocument, lManager,
+ fileChange.getChanges());
+ if (layoutChange != null) {
+ result.add(layoutChange);
+ }
+ }
+ }
+ return (result.getChildren().length == 0) ? null : result;
+ }
+
+ /**
+ * Returns Android gen package text change
+ *
+ * @param pm the progress monitor
+ *
+ * @return Android gen package text change
+ * @throws CoreException
+ * @throws OperationCanceledException
+ */
+ public Change getGenPackageChange(IProgressMonitor pm) throws CoreException,
+ OperationCanceledException {
+ if (mIsPackage) {
+ IPackageFragment genJavaPackageFragment = getGenPackageFragment();
+ if (genJavaPackageFragment != null && genJavaPackageFragment.exists()) {
+ return new RenamePackageChange(genJavaPackageFragment, mNewName, true);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Return the gen package fragment
+ *
+ */
+ private IPackageFragment getGenPackageFragment() throws JavaModelException {
+ IJavaProject javaProject = (IJavaProject) mPackageFragment
+ .getAncestor(IJavaElement.JAVA_PROJECT);
+ if (javaProject != null && javaProject.isOpen()) {
+ IProject project = javaProject.getProject();
+ IFolder genFolder = project.getFolder(SdkConstants.FD_GEN_SOURCES);
+ if (genFolder.exists()) {
+ String javaPackagePath = mAppPackage.replace(".", "/");
+ IPath genJavaPackagePath = genFolder.getFullPath().append(javaPackagePath);
+ IPackageFragment genPackageFragment = javaProject
+ .findPackageFragment(genJavaPackagePath);
+ return genPackageFragment;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public String getName() {
+ return "Android Package Rename";
+ }
+
+ @Override
+ protected boolean initialize(final Object element) {
+ mIsPackage = false;
+ try {
+ if (element instanceof IPackageFragment) {
+ mPackageFragment = (IPackageFragment) element;
+ if (!mPackageFragment.containsJavaResources())
+ return false;
+ IJavaProject javaProject = (IJavaProject) mPackageFragment
+ .getAncestor(IJavaElement.JAVA_PROJECT);
+ IProject project = javaProject.getProject();
+ IResource manifestResource = project.findMember(AdtConstants.WS_SEP
+ + SdkConstants.FN_ANDROID_MANIFEST_XML);
+
+ if (manifestResource == null || !manifestResource.exists()
+ || !(manifestResource instanceof IFile)) {
+ RefactoringUtil.logInfo("Invalid or missing the "
+ + SdkConstants.FN_ANDROID_MANIFEST_XML + " in the " + project.getName()
+ + " project.");
+ return false;
+ }
+ mAndroidManifest = (IFile) manifestResource;
+ String packageName = mPackageFragment.getElementName();
+ ManifestData manifestData;
+ manifestData = AndroidManifestHelper.parseForData(mAndroidManifest);
+ if (manifestData == null) {
+ return false;
+ }
+ mAppPackage = manifestData.getPackage();
+ mOldName = packageName;
+ mNewName = getArguments().getNewName();
+ if (mOldName == null || mNewName == null) {
+ return false;
+ }
+
+ if (RefactoringUtil.isRefactorAppPackage()
+ && mAppPackage != null
+ && mAppPackage.equals(packageName)) {
+ mIsPackage = true;
+ }
+ mAndroidElements = addAndroidElements();
+ try {
+ final IType type = javaProject.findType(SdkConstants.CLASS_VIEW);
+ SearchPattern pattern = SearchPattern.createPattern("*",
+ IJavaSearchConstants.TYPE, IJavaSearchConstants.DECLARATIONS,
+ SearchPattern.R_REGEXP_MATCH);
+ IJavaSearchScope scope =SearchEngine.createJavaSearchScope(
+ new IJavaElement[] { mPackageFragment });
+ final HashSet<IType> elements = new HashSet<IType>();
+ SearchRequestor requestor = new SearchRequestor() {
+
+ @Override
+ public void acceptSearchMatch(SearchMatch match) throws CoreException {
+ Object elem = match.getElement();
+ if (elem instanceof IType) {
+ IType eType = (IType) elem;
+ IType[] superTypes = JavaModelUtil.getAllSuperTypes(eType,
+ new NullProgressMonitor());
+ for (int i = 0; i < superTypes.length; i++) {
+ if (superTypes[i].equals(type)) {
+ elements.add(eType);
+ break;
+ }
+ }
+ }
+
+ }
+ };
+ SearchEngine searchEngine = new SearchEngine();
+ searchEngine.search(pattern, new SearchParticipant[] {
+ SearchEngine.getDefaultSearchParticipant()
+ }, scope, requestor, null);
+ List<String> views = new ArrayList<String>();
+ for (IType elem : elements) {
+ views.add(elem.getFullyQualifiedName());
+ }
+ if (views.size() > 0) {
+ String[] classNames = views.toArray(new String[0]);
+ addLayoutChanges(project, classNames);
+ }
+ } catch (CoreException e) {
+ RefactoringUtil.log(e);
+ }
+
+ return mIsPackage || mAndroidElements.size() > 0 || mFileChanges.size() > 0;
+ }
+ } catch (JavaModelException ignore) {
+ }
+ return false;
+ }
+
+ /**
+ * Adds layout changes for project
+ *
+ * @param project the Android project
+ * @param classNames the layout classes
+ */
+ private void addLayoutChanges(IProject project, String[] classNames) {
+ try {
+ IFolder resFolder = project.getFolder(SdkConstants.FD_RESOURCES);
+ IResource[] layoutMembers = resFolder.members();
+ for (int j = 0; j < layoutMembers.length; j++) {
+ IResource resource = layoutMembers[j];
+ if (resource instanceof IFolder
+ && resource.exists()
+ && resource.getName().startsWith(AndroidConstants.FD_RES_LAYOUT)) {
+ IFolder layoutFolder = (IFolder) resource;
+ IResource[] members = layoutFolder.members();
+ for (int i = 0; i < members.length; i++) {
+ IResource member = members[i];
+ if ((member instanceof IFile)
+ && member.exists()
+ && member.getName().endsWith(".xml")) { //$NON-NLS-1$
+ IFile file = (IFile) member;
+ Set<AndroidLayoutChangeDescription> changes =
+ parse(file, classNames);
+ if (changes.size() > 0) {
+ AndroidLayoutFileChanges fileChange =
+ new AndroidLayoutFileChanges(file);
+ fileChange.getChanges().addAll(changes);
+ mFileChanges.add(fileChange);
+ }
+ }
+ }
+ }
+ }
+ } catch (CoreException e) {
+ RefactoringUtil.log(e);
+ }
+ }
+
+ /**
+ * Searches the layout file for classes
+ *
+ * @param file the Android layout file
+ * @param classNames the layout classes
+ */
+ private Set<AndroidLayoutChangeDescription> parse(IFile file, String[] classNames) {
+ Set<AndroidLayoutChangeDescription> changes =
+ new HashSet<AndroidLayoutChangeDescription>();
+ ITextFileBufferManager lManager = null;
+ try {
+ lManager = FileBuffers.getTextFileBufferManager();
+ lManager.connect(file.getFullPath(),
+ LocationKind.NORMALIZE, new NullProgressMonitor());
+ ITextFileBuffer buffer = lManager.getTextFileBuffer(file.getFullPath(),
+ LocationKind.NORMALIZE);
+ IDocument lDocument = buffer.getDocument();
+ IStructuredModel model = null;
+ try {
+ model = StructuredModelManager.getModelManager().
+ getExistingModelForRead(lDocument);
+ if (model == null) {
+ if (lDocument instanceof IStructuredDocument) {
+ IStructuredDocument structuredDocument = (IStructuredDocument) lDocument;
+ model = StructuredModelManager.getModelManager().getModelForRead(
+ structuredDocument);
+ }
+ }
+ if (model != null) {
+ IDOMModel xmlModel = (IDOMModel) model;
+ IDOMDocument xmlDoc = xmlModel.getDocument();
+ NodeList nodes = xmlDoc.getElementsByTagName(LayoutConstants.VIEW);
+ for (int i = 0; i < nodes.getLength(); i++) {
+ Node node = nodes.item(i);
+ NamedNodeMap attributes = node.getAttributes();
+ if (attributes != null) {
+ Node attributeNode = attributes
+ .getNamedItem(LayoutConstants.ATTR_CLASS);
+ if (attributeNode instanceof Attr) {
+ Attr attribute = (Attr) attributeNode;
+ String value = attribute.getValue();
+ if (value != null) {
+ for (int j = 0; j < classNames.length; j++) {
+ String className = classNames[j];
+ if (value.equals(className)) {
+ String newClassName = getNewClassName(className);
+ AndroidLayoutChangeDescription layoutChange =
+ new AndroidLayoutChangeDescription(
+ className, newClassName,
+ AndroidLayoutChangeDescription.VIEW_TYPE);
+ changes.add(layoutChange);
+ }
+ }
+ }
+ }
+ }
+ }
+ for (int j = 0; j < classNames.length; j++) {
+ String className = classNames[j];
+ nodes = xmlDoc.getElementsByTagName(className);
+ for (int i = 0; i < nodes.getLength(); i++) {
+ String newClassName = getNewClassName(className);
+ AndroidLayoutChangeDescription layoutChange =
+ new AndroidLayoutChangeDescription(
+ className, newClassName,
+ AndroidLayoutChangeDescription.STANDALONE_TYPE);
+ changes.add(layoutChange);
+ }
+ }
+ }
+ } finally {
+ if (model != null) {
+ model.releaseFromRead();
+ }
+ }
+
+ } catch (CoreException ignore) {
+ } finally {
+ if (lManager != null) {
+ try {
+ lManager.disconnect(file.getFullPath(), LocationKind.NORMALIZE,
+ new NullProgressMonitor());
+ } catch (CoreException ignore) {
+ }
+ }
+ }
+ return changes;
+ }
+
+ /**
+ * Returns the new class name
+ *
+ * @param className the class name
+ * @return the new class name
+ */
+ private String getNewClassName(String className) {
+ int lastDot = className.lastIndexOf("."); //$NON-NLS-1$
+ if (lastDot < 0) {
+ return mNewName;
+ }
+ String name = className.substring(lastDot, className.length());
+ String newClassName = mNewName + name;
+ return newClassName;
+ }
+
+ /**
+ * Returns the elements (activity, receiver, service ...)
+ * which have to be renamed
+ *
+ * @return the android elements
+ */
+ private Map<String, String> addAndroidElements() {
+ Map<String, String> androidElements = new HashMap<String, String>();
+
+ IDocument document;
+ try {
+ document = getDocument();
+ } catch (CoreException e) {
+ RefactoringUtil.log(e);
+ if (mManager != null) {
+ try {
+ mManager.disconnect(mAndroidManifest.getFullPath(), LocationKind.NORMALIZE,
+ new NullProgressMonitor());
+ } catch (CoreException e1) {
+ RefactoringUtil.log(e1);
+ }
+ }
+ document = null;
+ return androidElements;
+ }
+
+ IStructuredModel model = null;
+ try {
+ model = StructuredModelManager.getModelManager().getExistingModelForRead(document);
+ if (model == null) {
+ if (document instanceof IStructuredDocument) {
+ IStructuredDocument structuredDocument = (IStructuredDocument) document;
+ model = StructuredModelManager.getModelManager().getModelForRead(
+ structuredDocument);
+ }
+ }
+ if (model != null) {
+ IDOMModel xmlModel = (IDOMModel) model;
+ IDOMDocument xmlDoc = xmlModel.getDocument();
+ add(xmlDoc, androidElements, AndroidManifest.NODE_ACTIVITY,
+ AndroidManifest.ATTRIBUTE_NAME);
+ add(xmlDoc, androidElements, AndroidManifest.NODE_APPLICATION,
+ AndroidManifest.ATTRIBUTE_NAME);
+ add(xmlDoc, androidElements, AndroidManifest.NODE_PROVIDER,
+ AndroidManifest.ATTRIBUTE_NAME);
+ add(xmlDoc, androidElements, AndroidManifest.NODE_RECEIVER,
+ AndroidManifest.ATTRIBUTE_NAME);
+ add(xmlDoc, androidElements, AndroidManifest.NODE_SERVICE,
+ AndroidManifest.ATTRIBUTE_NAME);
+ }
+ } finally {
+ if (model != null) {
+ model.releaseFromRead();
+ }
+ }
+
+ return androidElements;
+ }
+
+ /**
+ * Adds the element (activity, receiver, service ...) to the map
+ *
+ * @param xmlDoc the document
+ * @param androidElements the map
+ * @param element the element
+ */
+ private void add(IDOMDocument xmlDoc, Map<String, String> androidElements, String element,
+ String argument) {
+ NodeList nodes = xmlDoc.getElementsByTagName(element);
+ for (int i = 0; i < nodes.getLength(); i++) {
+ Node node = nodes.item(i);
+ NamedNodeMap attributes = node.getAttributes();
+ if (attributes != null) {
+ Attr attribute = RefactoringUtil.findAndroidAttributes(attributes, argument);
+ if (attribute != null) {
+ String value = attribute.getValue();
+ if (value != null) {
+ String fullName = AndroidManifest.combinePackageAndClassName(mAppPackage,
+ value);
+ if (RefactoringUtil.isRefactorAppPackage()) {
+ if (fullName != null && fullName.startsWith(mAppPackage)) {
+ boolean startWithDot = (value.charAt(0) == '.');
+ boolean hasDot = (value.indexOf('.') != -1);
+ if (!startWithDot && hasDot) {
+ androidElements.put(element, value);
+ }
+ }
+ } else {
+ if (fullName != null) {
+ androidElements.put(element, value);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactoring/core/AndroidRenameParticipant.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactoring/core/AndroidRenameParticipant.java
index dd99a98..5ddca7f 100755..100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactoring/core/AndroidRenameParticipant.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactoring/core/AndroidRenameParticipant.java
@@ -1,84 +1,84 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Eclipse Public License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.eclipse.org/org/documents/epl-v10.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ide.eclipse.adt.internal.refactoring.core;
-
-import org.eclipse.core.filebuffers.FileBuffers;
-import org.eclipse.core.filebuffers.ITextFileBuffer;
-import org.eclipse.core.filebuffers.ITextFileBufferManager;
-import org.eclipse.core.filebuffers.LocationKind;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
-import org.eclipse.ltk.core.refactoring.participants.RenameParticipant;
-
-import java.util.Map;
-
-/**
- * The abstract class for Rename Package and Rename type participants
- *
- */
-public abstract class AndroidRenameParticipant extends RenameParticipant {
-
- protected IFile mAndroidManifest;
-
- protected ITextFileBufferManager mManager;
-
- protected String mOldName;
-
- protected String mNewName;
-
- protected IDocument mDocument;
-
- protected String mAppPackage;
-
- protected Map<String, String> mAndroidElements;
-
- @Override
- public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context)
- throws OperationCanceledException {
- return new RefactoringStatus();
- }
-
- /**
- * @return the document
- * @throws CoreException
- */
- public IDocument getDocument() throws CoreException {
- if (mDocument == null) {
- mManager = FileBuffers.getTextFileBufferManager();
- mManager.connect(mAndroidManifest.getFullPath(), LocationKind.NORMALIZE,
- new NullProgressMonitor());
- ITextFileBuffer buffer = mManager.getTextFileBuffer(mAndroidManifest.getFullPath(),
- LocationKind.NORMALIZE);
- mDocument = buffer.getDocument();
- }
- return mDocument;
- }
-
- /**
- * @return the android manifest file
- */
- public IFile getAndroidManifest() {
- return mAndroidManifest;
- }
-
-}
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/org/documents/epl-v10.php
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.ide.eclipse.adt.internal.refactoring.core;
+
+import org.eclipse.core.filebuffers.FileBuffers;
+import org.eclipse.core.filebuffers.ITextFileBuffer;
+import org.eclipse.core.filebuffers.ITextFileBufferManager;
+import org.eclipse.core.filebuffers.LocationKind;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
+import org.eclipse.ltk.core.refactoring.participants.RenameParticipant;
+
+import java.util.Map;
+
+/**
+ * The abstract class for Rename Package and Rename type participants
+ *
+ */
+public abstract class AndroidRenameParticipant extends RenameParticipant {
+
+ protected IFile mAndroidManifest;
+
+ protected ITextFileBufferManager mManager;
+
+ protected String mOldName;
+
+ protected String mNewName;
+
+ protected IDocument mDocument;
+
+ protected String mAppPackage;
+
+ protected Map<String, String> mAndroidElements;
+
+ @Override
+ public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context)
+ throws OperationCanceledException {
+ return new RefactoringStatus();
+ }
+
+ /**
+ * @return the document
+ * @throws CoreException
+ */
+ public IDocument getDocument() throws CoreException {
+ if (mDocument == null) {
+ mManager = FileBuffers.getTextFileBufferManager();
+ mManager.connect(mAndroidManifest.getFullPath(), LocationKind.NORMALIZE,
+ new NullProgressMonitor());
+ ITextFileBuffer buffer = mManager.getTextFileBuffer(mAndroidManifest.getFullPath(),
+ LocationKind.NORMALIZE);
+ mDocument = buffer.getDocument();
+ }
+ return mDocument;
+ }
+
+ /**
+ * @return the android manifest file
+ */
+ public IFile getAndroidManifest() {
+ return mAndroidManifest;
+ }
+
+}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactoring/core/AndroidTypeMoveParticipant.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactoring/core/AndroidTypeMoveParticipant.java
index 735c595..452b8af 100755..100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactoring/core/AndroidTypeMoveParticipant.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactoring/core/AndroidTypeMoveParticipant.java
@@ -1,418 +1,418 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Eclipse Public License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.eclipse.org/org/documents/epl-v10.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ide.eclipse.adt.internal.refactoring.core;
-
-import com.android.AndroidConstants;
-import com.android.ide.common.layout.LayoutConstants;
-import com.android.ide.eclipse.adt.AdtConstants;
-import com.android.ide.eclipse.adt.internal.project.AndroidManifestHelper;
-import com.android.ide.eclipse.adt.internal.refactoring.changes.AndroidLayoutChange;
-import com.android.ide.eclipse.adt.internal.refactoring.changes.AndroidLayoutChangeDescription;
-import com.android.ide.eclipse.adt.internal.refactoring.changes.AndroidLayoutFileChanges;
-import com.android.ide.eclipse.adt.internal.refactoring.changes.AndroidTypeMoveChange;
-import com.android.sdklib.SdkConstants;
-import com.android.sdklib.xml.AndroidManifest;
-import com.android.sdklib.xml.ManifestData;
-
-import org.eclipse.core.filebuffers.FileBuffers;
-import org.eclipse.core.filebuffers.ITextFileBuffer;
-import org.eclipse.core.filebuffers.ITextFileBufferManager;
-import org.eclipse.core.filebuffers.LocationKind;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.ITypeHierarchy;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.ltk.core.refactoring.Change;
-import org.eclipse.ltk.core.refactoring.CompositeChange;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
-import org.eclipse.ltk.core.refactoring.participants.MoveParticipant;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.w3c.dom.Attr;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * A participant to participate in refactorings that move a type in an Android project.
- * The class updates android manifest and the layout file
- * The user can suppress refactoring by disabling the "Update references" checkbox
- * <p>
- * Rename participants are registered via the extension point <code>
- * org.eclipse.ltk.core.refactoring.moveParticipants</code>.
- * Extensions to this extension point must therefore extend <code>org.eclipse.ltk.core.refactoring.participants.MoveParticipant</code>.
- * </p>
- */
-@SuppressWarnings("restriction")
-public class AndroidTypeMoveParticipant extends MoveParticipant {
-
- protected IFile mAndroidManifest;
-
- protected ITextFileBufferManager mManager;
-
- protected String mOldName;
-
- protected String mNewName;
-
- protected IDocument mDocument;
-
- protected String mJavaPackage;
-
- protected Map<String, String> mAndroidElements;
-
- private Set<AndroidLayoutFileChanges> mFileChanges = new HashSet<AndroidLayoutFileChanges>();
-
- @Override
- public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context)
- throws OperationCanceledException {
- return new RefactoringStatus();
- }
-
- @Override
- public Change createChange(IProgressMonitor pm) throws CoreException,
- OperationCanceledException {
- if (pm.isCanceled()) {
- return null;
- }
- if (!getArguments().getUpdateReferences())
- return null;
- CompositeChange result = new CompositeChange(getName());
- if (mAndroidManifest.exists()) {
- if (mAndroidElements.size() > 0) {
- getDocument();
- Change change = new AndroidTypeMoveChange(mAndroidManifest, mManager, mDocument,
- mAndroidElements, mNewName, mOldName);
- if (change != null) {
- result.add(change);
- }
- }
-
- for (AndroidLayoutFileChanges fileChange : mFileChanges) {
- IFile file = fileChange.getFile();
- ITextFileBufferManager lManager = FileBuffers.getTextFileBufferManager();
- lManager.connect(file.getFullPath(), LocationKind.NORMALIZE,
- new NullProgressMonitor());
- ITextFileBuffer buffer = lManager.getTextFileBuffer(file.getFullPath(),
- LocationKind.NORMALIZE);
- IDocument lDocument = buffer.getDocument();
- Change layoutChange = new AndroidLayoutChange(file, lDocument, lManager,
- fileChange.getChanges());
- if (layoutChange != null) {
- result.add(layoutChange);
- }
- }
- }
- return (result.getChildren().length == 0) ? null : result;
-
- }
-
- /**
- * @return the document
- * @throws CoreException
- */
- public IDocument getDocument() throws CoreException {
- if (mDocument == null) {
- mManager = FileBuffers.getTextFileBufferManager();
- mManager.connect(mAndroidManifest.getFullPath(), LocationKind.NORMALIZE,
- new NullProgressMonitor());
- ITextFileBuffer buffer = mManager.getTextFileBuffer(mAndroidManifest.getFullPath(),
- LocationKind.NORMALIZE);
- mDocument = buffer.getDocument();
- }
- return mDocument;
- }
-
- /**
- * @return the android manifest file
- */
- public IFile getAndroidManifest() {
- return mAndroidManifest;
- }
-
- @Override
- public String getName() {
- return "Android Type Move";
- }
-
- @Override
- protected boolean initialize(Object element) {
-
- if (element instanceof IType) {
- IType type = (IType) element;
- IJavaProject javaProject = (IJavaProject) type.getAncestor(IJavaElement.JAVA_PROJECT);
- IProject project = javaProject.getProject();
- IResource manifestResource = project.findMember(AdtConstants.WS_SEP
- + SdkConstants.FN_ANDROID_MANIFEST_XML);
-
- if (manifestResource == null || !manifestResource.exists()
- || !(manifestResource instanceof IFile)) {
- RefactoringUtil.logInfo("Invalid or missing the "
- + SdkConstants.FN_ANDROID_MANIFEST_XML + " in the " + project.getName()
- + " project.");
- return false;
- }
- mAndroidManifest = (IFile) manifestResource;
- ManifestData manifestData;
- manifestData = AndroidManifestHelper.parseForData(mAndroidManifest);
- if (manifestData == null) {
- return false;
- }
- mJavaPackage = manifestData.getPackage();
- mOldName = type.getFullyQualifiedName();
- Object destination = getArguments().getDestination();
- if (destination instanceof IPackageFragment) {
- IPackageFragment packageFragment = (IPackageFragment) destination;
- mNewName = packageFragment.getElementName() + "." + type.getElementName();
- }
- if (mOldName == null || mNewName == null) {
- return false;
- }
- mAndroidElements = addAndroidElements();
- try {
- ITypeHierarchy typeHierarchy = type.newSupertypeHierarchy(null);
- if (typeHierarchy == null) {
- return false;
- }
- IType[] superTypes = typeHierarchy.getAllSuperclasses(type);
- for (int i = 0; i < superTypes.length; i++) {
- IType superType = superTypes[i];
- String className = superType.getFullyQualifiedName();
- if (className.equals(SdkConstants.CLASS_VIEW)) {
- addLayoutChanges(project, type.getFullyQualifiedName());
- break;
- }
- }
- } catch (JavaModelException ignore) {
- }
- return mAndroidElements.size() > 0 || mFileChanges.size() > 0;
- }
- return false;
- }
-
- /**
- * Adds layout changes for project
- *
- * @param project the Android project
- * @param className the layout classes
- *
- */
- private void addLayoutChanges(IProject project, String className) {
- try {
- IFolder resFolder = project.getFolder(SdkConstants.FD_RESOURCES);
- IFolder layoutFolder = resFolder.getFolder(AndroidConstants.FD_RES_LAYOUT);
- IResource[] members = layoutFolder.members();
- for (int i = 0; i < members.length; i++) {
- IResource member = members[i];
- if ((member instanceof IFile) && member.exists()) {
- IFile file = (IFile) member;
- Set<AndroidLayoutChangeDescription> changes = parse(file, className);
- if (changes.size() > 0) {
- AndroidLayoutFileChanges fileChange = new AndroidLayoutFileChanges(file);
- fileChange.getChanges().addAll(changes);
- mFileChanges.add(fileChange);
- }
- }
- }
- } catch (CoreException e) {
- RefactoringUtil.log(e);
- }
- }
-
- /**
- * Searches the layout file for classes
- *
- * @param file the Android layout file
- * @param className the layout classes
- *
- */
- private Set<AndroidLayoutChangeDescription> parse(IFile file, String className) {
- Set<AndroidLayoutChangeDescription> changes = new HashSet<AndroidLayoutChangeDescription>();
- ITextFileBufferManager lManager = null;
- try {
- lManager = FileBuffers.getTextFileBufferManager();
- lManager.connect(file.getFullPath(), LocationKind.NORMALIZE, new NullProgressMonitor());
- ITextFileBuffer buffer = lManager.getTextFileBuffer(file.getFullPath(),
- LocationKind.NORMALIZE);
- IDocument lDocument = buffer.getDocument();
- IStructuredModel model = null;
- try {
- model = StructuredModelManager.getModelManager().getExistingModelForRead(lDocument);
- if (model == null) {
- if (lDocument instanceof IStructuredDocument) {
- IStructuredDocument structuredDocument = (IStructuredDocument) lDocument;
- model = StructuredModelManager.getModelManager().getModelForRead(
- structuredDocument);
- }
- }
- if (model != null) {
- IDOMModel xmlModel = (IDOMModel) model;
- IDOMDocument xmlDoc = xmlModel.getDocument();
- NodeList nodes = xmlDoc.getElementsByTagName(LayoutConstants.VIEW);
- for (int i = 0; i < nodes.getLength(); i++) {
- Node node = nodes.item(i);
- NamedNodeMap attributes = node.getAttributes();
- if (attributes != null) {
- Node attributeNode =
- attributes.getNamedItem(LayoutConstants.ATTR_CLASS);
- if (attributeNode != null || attributeNode instanceof Attr) {
- Attr attribute = (Attr) attributeNode;
- String value = attribute.getValue();
- if (value != null && value.equals(className)) {
- AndroidLayoutChangeDescription layoutChange =
- new AndroidLayoutChangeDescription(className, mNewName,
- AndroidLayoutChangeDescription.VIEW_TYPE);
- changes.add(layoutChange);
- }
- }
- }
- }
- nodes = xmlDoc.getElementsByTagName(className);
- for (int i = 0; i < nodes.getLength(); i++) {
- AndroidLayoutChangeDescription layoutChange =
- new AndroidLayoutChangeDescription(className, mNewName,
- AndroidLayoutChangeDescription.STANDALONE_TYPE);
- changes.add(layoutChange);
- }
- }
- } finally {
- if (model != null) {
- model.releaseFromRead();
- }
- }
-
- } catch (CoreException ignore) {
- } finally {
- if (lManager != null) {
- try {
- lManager.disconnect(file.getFullPath(), LocationKind.NORMALIZE,
- new NullProgressMonitor());
- } catch (CoreException ignore) {
- }
- }
- }
- return changes;
- }
-
- /**
- * Returns the elements (activity, receiver, service ...)
- * which have to be renamed
- *
- * @return the android elements
- */
- private Map<String, String> addAndroidElements() {
- Map<String, String> androidElements = new HashMap<String, String>();
-
- IDocument document;
- try {
- document = getDocument();
- } catch (CoreException e) {
- RefactoringUtil.log(e);
- if (mManager != null) {
- try {
- mManager.disconnect(mAndroidManifest.getFullPath(), LocationKind.NORMALIZE,
- new NullProgressMonitor());
- } catch (CoreException e1) {
- RefactoringUtil.log(e1);
- }
- }
- document = null;
- return androidElements;
- }
-
- IStructuredModel model = null;
- try {
- model = StructuredModelManager.getModelManager().getExistingModelForRead(document);
- if (model == null) {
- if (document instanceof IStructuredDocument) {
- IStructuredDocument structuredDocument = (IStructuredDocument) document;
- model = StructuredModelManager.getModelManager().getModelForRead(
- structuredDocument);
- }
- }
- if (model != null) {
- IDOMModel xmlModel = (IDOMModel) model;
- IDOMDocument xmlDoc = xmlModel.getDocument();
- add(xmlDoc, androidElements, AndroidManifest.NODE_ACTIVITY,
- AndroidManifest.ATTRIBUTE_NAME);
- add(xmlDoc, androidElements, AndroidManifest.NODE_APPLICATION,
- AndroidManifest.ATTRIBUTE_NAME);
- add(xmlDoc, androidElements, AndroidManifest.NODE_PROVIDER,
- AndroidManifest.ATTRIBUTE_NAME);
- add(xmlDoc, androidElements, AndroidManifest.NODE_RECEIVER,
- AndroidManifest.ATTRIBUTE_NAME);
- add(xmlDoc, androidElements, AndroidManifest.NODE_SERVICE,
- AndroidManifest.ATTRIBUTE_NAME);
- }
- } finally {
- if (model != null) {
- model.releaseFromRead();
- }
- }
-
- return androidElements;
- }
-
- /**
- * Adds the element (activity, receiver, service ...) to the map
- *
- * @param xmlDoc the document
- * @param androidElements the map
- * @param element the element
- */
- private void add(IDOMDocument xmlDoc, Map<String, String> androidElements, String element,
- String argument) {
- NodeList nodes = xmlDoc.getElementsByTagName(element);
- for (int i = 0; i < nodes.getLength(); i++) {
- Node node = nodes.item(i);
- NamedNodeMap attributes = node.getAttributes();
- if (attributes != null) {
- Attr attribute = RefactoringUtil.findAndroidAttributes(attributes, argument);
- if (attribute != null) {
- String value = attribute.getValue();
- if (value != null) {
- String fullName = AndroidManifest.combinePackageAndClassName(mJavaPackage,
- value);
- if (fullName != null && fullName.equals(mOldName)) {
- androidElements.put(element, value);
- }
- }
- }
- }
- }
- }
-
-}
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/org/documents/epl-v10.php
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.ide.eclipse.adt.internal.refactoring.core;
+
+import com.android.AndroidConstants;
+import com.android.ide.common.layout.LayoutConstants;
+import com.android.ide.eclipse.adt.AdtConstants;
+import com.android.ide.eclipse.adt.internal.project.AndroidManifestHelper;
+import com.android.ide.eclipse.adt.internal.refactoring.changes.AndroidLayoutChange;
+import com.android.ide.eclipse.adt.internal.refactoring.changes.AndroidLayoutChangeDescription;
+import com.android.ide.eclipse.adt.internal.refactoring.changes.AndroidLayoutFileChanges;
+import com.android.ide.eclipse.adt.internal.refactoring.changes.AndroidTypeMoveChange;
+import com.android.sdklib.SdkConstants;
+import com.android.sdklib.xml.AndroidManifest;
+import com.android.sdklib.xml.ManifestData;
+
+import org.eclipse.core.filebuffers.FileBuffers;
+import org.eclipse.core.filebuffers.ITextFileBuffer;
+import org.eclipse.core.filebuffers.ITextFileBufferManager;
+import org.eclipse.core.filebuffers.LocationKind;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.ITypeHierarchy;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.CompositeChange;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
+import org.eclipse.ltk.core.refactoring.participants.MoveParticipant;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.w3c.dom.Attr;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * A participant to participate in refactorings that move a type in an Android project.
+ * The class updates android manifest and the layout file
+ * The user can suppress refactoring by disabling the "Update references" checkbox
+ * <p>
+ * Rename participants are registered via the extension point <code>
+ * org.eclipse.ltk.core.refactoring.moveParticipants</code>.
+ * Extensions to this extension point must therefore extend <code>org.eclipse.ltk.core.refactoring.participants.MoveParticipant</code>.
+ * </p>
+ */
+@SuppressWarnings("restriction")
+public class AndroidTypeMoveParticipant extends MoveParticipant {
+
+ protected IFile mAndroidManifest;
+
+ protected ITextFileBufferManager mManager;
+
+ protected String mOldName;
+
+ protected String mNewName;
+
+ protected IDocument mDocument;
+
+ protected String mJavaPackage;
+
+ protected Map<String, String> mAndroidElements;
+
+ private Set<AndroidLayoutFileChanges> mFileChanges = new HashSet<AndroidLayoutFileChanges>();
+
+ @Override
+ public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context)
+ throws OperationCanceledException {
+ return new RefactoringStatus();
+ }
+
+ @Override
+ public Change createChange(IProgressMonitor pm) throws CoreException,
+ OperationCanceledException {
+ if (pm.isCanceled()) {
+ return null;
+ }
+ if (!getArguments().getUpdateReferences())
+ return null;
+ CompositeChange result = new CompositeChange(getName());
+ if (mAndroidManifest.exists()) {
+ if (mAndroidElements.size() > 0) {
+ getDocument();
+ Change change = new AndroidTypeMoveChange(mAndroidManifest, mManager, mDocument,
+ mAndroidElements, mNewName, mOldName);
+ if (change != null) {
+ result.add(change);
+ }
+ }
+
+ for (AndroidLayoutFileChanges fileChange : mFileChanges) {
+ IFile file = fileChange.getFile();
+ ITextFileBufferManager lManager = FileBuffers.getTextFileBufferManager();
+ lManager.connect(file.getFullPath(), LocationKind.NORMALIZE,
+ new NullProgressMonitor());
+ ITextFileBuffer buffer = lManager.getTextFileBuffer(file.getFullPath(),
+ LocationKind.NORMALIZE);
+ IDocument lDocument = buffer.getDocument();
+ Change layoutChange = new AndroidLayoutChange(file, lDocument, lManager,
+ fileChange.getChanges());
+ if (layoutChange != null) {
+ result.add(layoutChange);
+ }
+ }
+ }
+ return (result.getChildren().length == 0) ? null : result;
+
+ }
+
+ /**
+ * @return the document
+ * @throws CoreException
+ */
+ public IDocument getDocument() throws CoreException {
+ if (mDocument == null) {
+ mManager = FileBuffers.getTextFileBufferManager();
+ mManager.connect(mAndroidManifest.getFullPath(), LocationKind.NORMALIZE,
+ new NullProgressMonitor());
+ ITextFileBuffer buffer = mManager.getTextFileBuffer(mAndroidManifest.getFullPath(),
+ LocationKind.NORMALIZE);
+ mDocument = buffer.getDocument();
+ }
+ return mDocument;
+ }
+
+ /**
+ * @return the android manifest file
+ */
+ public IFile getAndroidManifest() {
+ return mAndroidManifest;
+ }
+
+ @Override
+ public String getName() {
+ return "Android Type Move";
+ }
+
+ @Override
+ protected boolean initialize(Object element) {
+
+ if (element instanceof IType) {
+ IType type = (IType) element;
+ IJavaProject javaProject = (IJavaProject) type.getAncestor(IJavaElement.JAVA_PROJECT);
+ IProject project = javaProject.getProject();
+ IResource manifestResource = project.findMember(AdtConstants.WS_SEP
+ + SdkConstants.FN_ANDROID_MANIFEST_XML);
+
+ if (manifestResource == null || !manifestResource.exists()
+ || !(manifestResource instanceof IFile)) {
+ RefactoringUtil.logInfo("Invalid or missing the "
+ + SdkConstants.FN_ANDROID_MANIFEST_XML + " in the " + project.getName()
+ + " project.");
+ return false;
+ }
+ mAndroidManifest = (IFile) manifestResource;
+ ManifestData manifestData;
+ manifestData = AndroidManifestHelper.parseForData(mAndroidManifest);
+ if (manifestData == null) {
+ return false;
+ }
+ mJavaPackage = manifestData.getPackage();
+ mOldName = type.getFullyQualifiedName();
+ Object destination = getArguments().getDestination();
+ if (destination instanceof IPackageFragment) {
+ IPackageFragment packageFragment = (IPackageFragment) destination;
+ mNewName = packageFragment.getElementName() + "." + type.getElementName();
+ }
+ if (mOldName == null || mNewName == null) {
+ return false;
+ }
+ mAndroidElements = addAndroidElements();
+ try {
+ ITypeHierarchy typeHierarchy = type.newSupertypeHierarchy(null);
+ if (typeHierarchy == null) {
+ return false;
+ }
+ IType[] superTypes = typeHierarchy.getAllSuperclasses(type);
+ for (int i = 0; i < superTypes.length; i++) {
+ IType superType = superTypes[i];
+ String className = superType.getFullyQualifiedName();
+ if (className.equals(SdkConstants.CLASS_VIEW)) {
+ addLayoutChanges(project, type.getFullyQualifiedName());
+ break;
+ }
+ }
+ } catch (JavaModelException ignore) {
+ }
+ return mAndroidElements.size() > 0 || mFileChanges.size() > 0;
+ }
+ return false;
+ }
+
+ /**
+ * Adds layout changes for project
+ *
+ * @param project the Android project
+ * @param className the layout classes
+ *
+ */
+ private void addLayoutChanges(IProject project, String className) {
+ try {
+ IFolder resFolder = project.getFolder(SdkConstants.FD_RESOURCES);
+ IFolder layoutFolder = resFolder.getFolder(AndroidConstants.FD_RES_LAYOUT);
+ IResource[] members = layoutFolder.members();
+ for (int i = 0; i < members.length; i++) {
+ IResource member = members[i];
+ if ((member instanceof IFile) && member.exists()) {
+ IFile file = (IFile) member;
+ Set<AndroidLayoutChangeDescription> changes = parse(file, className);
+ if (changes.size() > 0) {
+ AndroidLayoutFileChanges fileChange = new AndroidLayoutFileChanges(file);
+ fileChange.getChanges().addAll(changes);
+ mFileChanges.add(fileChange);
+ }
+ }
+ }
+ } catch (CoreException e) {
+ RefactoringUtil.log(e);
+ }
+ }
+
+ /**
+ * Searches the layout file for classes
+ *
+ * @param file the Android layout file
+ * @param className the layout classes
+ *
+ */
+ private Set<AndroidLayoutChangeDescription> parse(IFile file, String className) {
+ Set<AndroidLayoutChangeDescription> changes = new HashSet<AndroidLayoutChangeDescription>();
+ ITextFileBufferManager lManager = null;
+ try {
+ lManager = FileBuffers.getTextFileBufferManager();
+ lManager.connect(file.getFullPath(), LocationKind.NORMALIZE, new NullProgressMonitor());
+ ITextFileBuffer buffer = lManager.getTextFileBuffer(file.getFullPath(),
+ LocationKind.NORMALIZE);
+ IDocument lDocument = buffer.getDocument();
+ IStructuredModel model = null;
+ try {
+ model = StructuredModelManager.getModelManager().getExistingModelForRead(lDocument);
+ if (model == null) {
+ if (lDocument instanceof IStructuredDocument) {
+ IStructuredDocument structuredDocument = (IStructuredDocument) lDocument;
+ model = StructuredModelManager.getModelManager().getModelForRead(
+ structuredDocument);
+ }
+ }
+ if (model != null) {
+ IDOMModel xmlModel = (IDOMModel) model;
+ IDOMDocument xmlDoc = xmlModel.getDocument();
+ NodeList nodes = xmlDoc.getElementsByTagName(LayoutConstants.VIEW);
+ for (int i = 0; i < nodes.getLength(); i++) {
+ Node node = nodes.item(i);
+ NamedNodeMap attributes = node.getAttributes();
+ if (attributes != null) {
+ Node attributeNode =
+ attributes.getNamedItem(LayoutConstants.ATTR_CLASS);
+ if (attributeNode instanceof Attr) {
+ Attr attribute = (Attr) attributeNode;
+ String value = attribute.getValue();
+ if (value != null && value.equals(className)) {
+ AndroidLayoutChangeDescription layoutChange =
+ new AndroidLayoutChangeDescription(className, mNewName,
+ AndroidLayoutChangeDescription.VIEW_TYPE);
+ changes.add(layoutChange);
+ }
+ }
+ }
+ }
+ nodes = xmlDoc.getElementsByTagName(className);
+ for (int i = 0; i < nodes.getLength(); i++) {
+ AndroidLayoutChangeDescription layoutChange =
+ new AndroidLayoutChangeDescription(className, mNewName,
+ AndroidLayoutChangeDescription.STANDALONE_TYPE);
+ changes.add(layoutChange);
+ }
+ }
+ } finally {
+ if (model != null) {
+ model.releaseFromRead();
+ }
+ }
+
+ } catch (CoreException ignore) {
+ } finally {
+ if (lManager != null) {
+ try {
+ lManager.disconnect(file.getFullPath(), LocationKind.NORMALIZE,
+ new NullProgressMonitor());
+ } catch (CoreException ignore) {
+ }
+ }
+ }
+ return changes;
+ }
+
+ /**
+ * Returns the elements (activity, receiver, service ...)
+ * which have to be renamed
+ *
+ * @return the android elements
+ */
+ private Map<String, String> addAndroidElements() {
+ Map<String, String> androidElements = new HashMap<String, String>();
+
+ IDocument document;
+ try {
+ document = getDocument();
+ } catch (CoreException e) {
+ RefactoringUtil.log(e);
+ if (mManager != null) {
+ try {
+ mManager.disconnect(mAndroidManifest.getFullPath(), LocationKind.NORMALIZE,
+ new NullProgressMonitor());
+ } catch (CoreException e1) {
+ RefactoringUtil.log(e1);
+ }
+ }
+ document = null;
+ return androidElements;
+ }
+
+ IStructuredModel model = null;
+ try {
+ model = StructuredModelManager.getModelManager().getExistingModelForRead(document);
+ if (model == null) {
+ if (document instanceof IStructuredDocument) {
+ IStructuredDocument structuredDocument = (IStructuredDocument) document;
+ model = StructuredModelManager.getModelManager().getModelForRead(
+ structuredDocument);
+ }
+ }
+ if (model != null) {
+ IDOMModel xmlModel = (IDOMModel) model;
+ IDOMDocument xmlDoc = xmlModel.getDocument();
+ add(xmlDoc, androidElements, AndroidManifest.NODE_ACTIVITY,
+ AndroidManifest.ATTRIBUTE_NAME);
+ add(xmlDoc, androidElements, AndroidManifest.NODE_APPLICATION,
+ AndroidManifest.ATTRIBUTE_NAME);
+ add(xmlDoc, androidElements, AndroidManifest.NODE_PROVIDER,
+ AndroidManifest.ATTRIBUTE_NAME);
+ add(xmlDoc, androidElements, AndroidManifest.NODE_RECEIVER,
+ AndroidManifest.ATTRIBUTE_NAME);
+ add(xmlDoc, androidElements, AndroidManifest.NODE_SERVICE,
+ AndroidManifest.ATTRIBUTE_NAME);
+ }
+ } finally {
+ if (model != null) {
+ model.releaseFromRead();
+ }
+ }
+
+ return androidElements;
+ }
+
+ /**
+ * Adds the element (activity, receiver, service ...) to the map
+ *
+ * @param xmlDoc the document
+ * @param androidElements the map
+ * @param element the element
+ */
+ private void add(IDOMDocument xmlDoc, Map<String, String> androidElements, String element,
+ String argument) {
+ NodeList nodes = xmlDoc.getElementsByTagName(element);
+ for (int i = 0; i < nodes.getLength(); i++) {
+ Node node = nodes.item(i);
+ NamedNodeMap attributes = node.getAttributes();
+ if (attributes != null) {
+ Attr attribute = RefactoringUtil.findAndroidAttributes(attributes, argument);
+ if (attribute != null) {
+ String value = attribute.getValue();
+ if (value != null) {
+ String fullName = AndroidManifest.combinePackageAndClassName(mJavaPackage,
+ value);
+ if (fullName != null && fullName.equals(mOldName)) {
+ androidElements.put(element, value);
+ }
+ }
+ }
+ }
+ }
+ }
+
+}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactoring/core/AndroidTypeRenameParticipant.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactoring/core/AndroidTypeRenameParticipant.java
index b80125a..cdf6111 100755..100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactoring/core/AndroidTypeRenameParticipant.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactoring/core/AndroidTypeRenameParticipant.java
@@ -1,383 +1,383 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Eclipse Public License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.eclipse.org/org/documents/epl-v10.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ide.eclipse.adt.internal.refactoring.core;
-
-import com.android.AndroidConstants;
-import com.android.ide.common.layout.LayoutConstants;
-import com.android.ide.eclipse.adt.AdtConstants;
-import com.android.ide.eclipse.adt.internal.project.AndroidManifestHelper;
-import com.android.ide.eclipse.adt.internal.refactoring.changes.AndroidLayoutChange;
-import com.android.ide.eclipse.adt.internal.refactoring.changes.AndroidLayoutChangeDescription;
-import com.android.ide.eclipse.adt.internal.refactoring.changes.AndroidLayoutFileChanges;
-import com.android.ide.eclipse.adt.internal.refactoring.changes.AndroidTypeRenameChange;
-import com.android.sdklib.SdkConstants;
-import com.android.sdklib.xml.AndroidManifest;
-import com.android.sdklib.xml.ManifestData;
-
-import org.eclipse.core.filebuffers.FileBuffers;
-import org.eclipse.core.filebuffers.ITextFileBuffer;
-import org.eclipse.core.filebuffers.ITextFileBufferManager;
-import org.eclipse.core.filebuffers.LocationKind;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.ITypeHierarchy;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.ltk.core.refactoring.Change;
-import org.eclipse.ltk.core.refactoring.CompositeChange;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.w3c.dom.Attr;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * A participant to participate in refactorings that rename a type in an Android project.
- * The class updates android manifest and the layout file
- * The user can suppress refactoring by disabling the "Update references" checkbox
- * <p>
- * Rename participants are registered via the extension point <code>
- * org.eclipse.ltk.core.refactoring.renameParticipants</code>.
- * Extensions to this extension point must therefore extend <code>org.eclipse.ltk.core.refactoring.participants.RenameParticipant</code>.
- * </p>
- */
-@SuppressWarnings("restriction")
-public class AndroidTypeRenameParticipant extends AndroidRenameParticipant {
-
- private Set<AndroidLayoutFileChanges> mFileChanges = new HashSet<AndroidLayoutFileChanges>();
-
- private String mLayoutNewName;
-
- @Override
- public Change createChange(IProgressMonitor pm) throws CoreException,
- OperationCanceledException {
- if (pm.isCanceled()) {
- return null;
- }
- if (!getArguments().getUpdateReferences())
- return null;
- CompositeChange result = new CompositeChange(getName());
- if (mAndroidManifest.exists()) {
- if (mAndroidElements.size() > 0) {
- getDocument();
- Change change = new AndroidTypeRenameChange(mAndroidManifest, mManager, mDocument,
- mAndroidElements, mNewName, mOldName);
- if (change != null) {
- result.add(change);
- }
- }
- // add layoutChange
- for (AndroidLayoutFileChanges fileChange : mFileChanges) {
- IFile file = fileChange.getFile();
- ITextFileBufferManager lManager = FileBuffers.getTextFileBufferManager();
- lManager.connect(file.getFullPath(), LocationKind.NORMALIZE,
- new NullProgressMonitor());
- ITextFileBuffer buffer = lManager.getTextFileBuffer(file.getFullPath(),
- LocationKind.NORMALIZE);
- IDocument lDocument = buffer.getDocument();
- Change layoutChange = new AndroidLayoutChange(file, lDocument, lManager,
- fileChange.getChanges());
- if (layoutChange != null) {
- result.add(layoutChange);
- }
- }
- }
- return (result.getChildren().length == 0) ? null : result;
-
- }
-
- @Override
- public String getName() {
- return "Android Type Rename";
- }
-
- @Override
- protected boolean initialize(Object element) {
-
- if (element instanceof IType) {
- IType type = (IType) element;
- IJavaProject javaProject = (IJavaProject) type.getAncestor(IJavaElement.JAVA_PROJECT);
- IProject project = javaProject.getProject();
- IResource manifestResource = project.findMember(AdtConstants.WS_SEP
- + SdkConstants.FN_ANDROID_MANIFEST_XML);
-
- if (manifestResource == null || !manifestResource.exists()
- || !(manifestResource instanceof IFile)) {
- RefactoringUtil.logInfo("Invalid or missing the "
- + SdkConstants.FN_ANDROID_MANIFEST_XML + " in the " + project.getName()
- + " project.");
- return false;
- }
- mAndroidManifest = (IFile) manifestResource;
- ManifestData manifestData;
- manifestData = AndroidManifestHelper.parseForData(mAndroidManifest);
- if (manifestData == null) {
- return false;
- }
- mAppPackage = manifestData.getPackage();
- mOldName = type.getFullyQualifiedName();
- String packageName = type.getPackageFragment().getElementName();
- mNewName = getArguments().getNewName();
- if (packageName != null) {
- mLayoutNewName = packageName + "." + getArguments().getNewName(); //$NON-NLS-1$
- } else {
- mLayoutNewName = getArguments().getNewName();
- }
- if (mOldName == null || mNewName == null) {
- return false;
- }
- if (!RefactoringUtil.isRefactorAppPackage() && mNewName.indexOf(".") == -1) { //$NON-NLS-1$
- mNewName = packageName + "." + mNewName; //$NON-NLS-1$
- }
- mAndroidElements = addAndroidElements();
- try {
- ITypeHierarchy typeHierarchy = type.newSupertypeHierarchy(null);
- if (typeHierarchy == null) {
- return false;
- }
- IType[] superTypes = typeHierarchy.getAllSuperclasses(type);
- for (int i = 0; i < superTypes.length; i++) {
- IType superType = superTypes[i];
- String className = superType.getFullyQualifiedName();
- if (className.equals(SdkConstants.CLASS_VIEW)) {
- addLayoutChanges(project, type.getFullyQualifiedName());
- break;
- }
- }
- } catch (JavaModelException ignore) {
- }
-
- return mAndroidElements.size() > 0 || mFileChanges.size() > 0;
- }
- return false;
- }
-
- /**
- * Adds layout changes for project
- *
- * @param project the Android project
- * @param className the layout classes
- *
- */
- private void addLayoutChanges(IProject project, String className) {
- try {
- IFolder resFolder = project.getFolder(SdkConstants.FD_RESOURCES);
- IFolder layoutFolder = resFolder.getFolder(AndroidConstants.FD_RES_LAYOUT);
- IResource[] members = layoutFolder.members();
- for (int i = 0; i < members.length; i++) {
- IResource member = members[i];
- if ((member instanceof IFile) && member.exists()) {
- IFile file = (IFile) member;
- Set<AndroidLayoutChangeDescription> changes = parse(file, className);
- if (changes.size() > 0) {
- AndroidLayoutFileChanges fileChange = new AndroidLayoutFileChanges(file);
- fileChange.getChanges().addAll(changes);
- mFileChanges.add(fileChange);
- }
- }
- }
- } catch (CoreException e) {
- RefactoringUtil.log(e);
- }
- }
-
- /**
- * Searches the layout file for classes
- *
- * @param file the Android layout file
- * @param className the layout classes
- *
- */
- private Set<AndroidLayoutChangeDescription> parse(IFile file, String className) {
- Set<AndroidLayoutChangeDescription> changes = new HashSet<AndroidLayoutChangeDescription>();
- ITextFileBufferManager lManager = null;
- try {
- lManager = FileBuffers.getTextFileBufferManager();
- lManager.connect(file.getFullPath(), LocationKind.NORMALIZE, new NullProgressMonitor());
- ITextFileBuffer buffer = lManager.getTextFileBuffer(file.getFullPath(),
- LocationKind.NORMALIZE);
- IDocument lDocument = buffer.getDocument();
- IStructuredModel model = null;
- try {
- model = StructuredModelManager.getModelManager().getExistingModelForRead(lDocument);
- if (model == null) {
- if (lDocument instanceof IStructuredDocument) {
- IStructuredDocument structuredDocument = (IStructuredDocument) lDocument;
- model = StructuredModelManager.getModelManager().getModelForRead(
- structuredDocument);
- }
- }
- if (model != null) {
- IDOMModel xmlModel = (IDOMModel) model;
- IDOMDocument xmlDoc = xmlModel.getDocument();
- NodeList nodes = xmlDoc
- .getElementsByTagName(LayoutConstants.VIEW);
- for (int i = 0; i < nodes.getLength(); i++) {
- Node node = nodes.item(i);
- NamedNodeMap attributes = node.getAttributes();
- if (attributes != null) {
- Node attributeNode =
- attributes.getNamedItem(LayoutConstants.ATTR_CLASS);
- if (attributeNode != null || attributeNode instanceof Attr) {
- Attr attribute = (Attr) attributeNode;
- String value = attribute.getValue();
- if (value != null && value.equals(className)) {
- AndroidLayoutChangeDescription layoutChange =
- new AndroidLayoutChangeDescription(className, mLayoutNewName,
- AndroidLayoutChangeDescription.VIEW_TYPE);
- changes.add(layoutChange);
- }
- }
- }
- }
- nodes = xmlDoc.getElementsByTagName(className);
- for (int i = 0; i < nodes.getLength(); i++) {
- AndroidLayoutChangeDescription layoutChange =
- new AndroidLayoutChangeDescription(className, mLayoutNewName,
- AndroidLayoutChangeDescription.STANDALONE_TYPE);
- changes.add(layoutChange);
- }
- }
- } finally {
- if (model != null) {
- model.releaseFromRead();
- }
- }
-
- } catch (CoreException ignore) {
- } finally {
- if (lManager != null) {
- try {
- lManager.disconnect(file.getFullPath(), LocationKind.NORMALIZE,
- new NullProgressMonitor());
- } catch (CoreException ignore) {
- }
- }
- }
- return changes;
- }
-
- /**
- * Returns the elements (activity, receiver, service ...)
- * which have to be renamed
- *
- * @return the android elements
- *
- */
- private Map<String, String> addAndroidElements() {
- Map<String, String> androidElements = new HashMap<String, String>();
-
- IDocument document;
- try {
- document = getDocument();
- } catch (CoreException e) {
- RefactoringUtil.log(e);
- if (mManager != null) {
- try {
- mManager.disconnect(mAndroidManifest.getFullPath(), LocationKind.NORMALIZE,
- new NullProgressMonitor());
- } catch (CoreException e1) {
- RefactoringUtil.log(e1);
- }
- }
- document = null;
- return androidElements;
- }
-
- IStructuredModel model = null;
- try {
- model = StructuredModelManager.getModelManager().getExistingModelForRead(document);
- if (model == null) {
- if (document instanceof IStructuredDocument) {
- IStructuredDocument structuredDocument = (IStructuredDocument) document;
- model = StructuredModelManager.getModelManager().getModelForRead(
- structuredDocument);
- }
- }
- if (model != null) {
- IDOMModel xmlModel = (IDOMModel) model;
- IDOMDocument xmlDoc = xmlModel.getDocument();
- add(xmlDoc, androidElements, AndroidManifest.NODE_ACTIVITY,
- AndroidManifest.ATTRIBUTE_NAME);
- add(xmlDoc, androidElements, AndroidManifest.NODE_APPLICATION,
- AndroidManifest.ATTRIBUTE_NAME);
- add(xmlDoc, androidElements, AndroidManifest.NODE_PROVIDER,
- AndroidManifest.ATTRIBUTE_NAME);
- add(xmlDoc, androidElements, AndroidManifest.NODE_RECEIVER,
- AndroidManifest.ATTRIBUTE_NAME);
- add(xmlDoc, androidElements, AndroidManifest.NODE_SERVICE,
- AndroidManifest.ATTRIBUTE_NAME);
- }
- } finally {
- if (model != null) {
- model.releaseFromRead();
- }
- }
-
- return androidElements;
- }
-
- /**
- * (non-Javadoc) Adds the element (activity, receiver, service ...) to the map
- *
- * @param xmlDoc the document
- * @param androidElements the map
- * @param element the element
- */
- private void add(IDOMDocument xmlDoc, Map<String, String> androidElements, String element,
- String argument) {
- NodeList nodes = xmlDoc.getElementsByTagName(element);
- for (int i = 0; i < nodes.getLength(); i++) {
- Node node = nodes.item(i);
- NamedNodeMap attributes = node.getAttributes();
- if (attributes != null) {
- Attr attribute = RefactoringUtil.findAndroidAttributes(attributes, argument);
- if (attribute != null) {
- String value = attribute.getValue();
- if (value != null) {
- String fullName = AndroidManifest.combinePackageAndClassName(mAppPackage,
- value);
- if (fullName != null && fullName.equals(mOldName)) {
- androidElements.put(element, value);
- }
- }
- }
- }
- }
- }
-
-
-
-}
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/org/documents/epl-v10.php
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.ide.eclipse.adt.internal.refactoring.core;
+
+import com.android.AndroidConstants;
+import com.android.ide.common.layout.LayoutConstants;
+import com.android.ide.eclipse.adt.AdtConstants;
+import com.android.ide.eclipse.adt.internal.project.AndroidManifestHelper;
+import com.android.ide.eclipse.adt.internal.refactoring.changes.AndroidLayoutChange;
+import com.android.ide.eclipse.adt.internal.refactoring.changes.AndroidLayoutChangeDescription;
+import com.android.ide.eclipse.adt.internal.refactoring.changes.AndroidLayoutFileChanges;
+import com.android.ide.eclipse.adt.internal.refactoring.changes.AndroidTypeRenameChange;
+import com.android.sdklib.SdkConstants;
+import com.android.sdklib.xml.AndroidManifest;
+import com.android.sdklib.xml.ManifestData;
+
+import org.eclipse.core.filebuffers.FileBuffers;
+import org.eclipse.core.filebuffers.ITextFileBuffer;
+import org.eclipse.core.filebuffers.ITextFileBufferManager;
+import org.eclipse.core.filebuffers.LocationKind;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.ITypeHierarchy;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.CompositeChange;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.w3c.dom.Attr;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * A participant to participate in refactorings that rename a type in an Android project.
+ * The class updates android manifest and the layout file
+ * The user can suppress refactoring by disabling the "Update references" checkbox
+ * <p>
+ * Rename participants are registered via the extension point <code>
+ * org.eclipse.ltk.core.refactoring.renameParticipants</code>.
+ * Extensions to this extension point must therefore extend <code>org.eclipse.ltk.core.refactoring.participants.RenameParticipant</code>.
+ * </p>
+ */
+@SuppressWarnings("restriction")
+public class AndroidTypeRenameParticipant extends AndroidRenameParticipant {
+
+ private Set<AndroidLayoutFileChanges> mFileChanges = new HashSet<AndroidLayoutFileChanges>();
+
+ private String mLayoutNewName;
+
+ @Override
+ public Change createChange(IProgressMonitor pm) throws CoreException,
+ OperationCanceledException {
+ if (pm.isCanceled()) {
+ return null;
+ }
+ if (!getArguments().getUpdateReferences())
+ return null;
+ CompositeChange result = new CompositeChange(getName());
+ if (mAndroidManifest.exists()) {
+ if (mAndroidElements.size() > 0) {
+ getDocument();
+ Change change = new AndroidTypeRenameChange(mAndroidManifest, mManager, mDocument,
+ mAndroidElements, mNewName, mOldName);
+ if (change != null) {
+ result.add(change);
+ }
+ }
+ // add layoutChange
+ for (AndroidLayoutFileChanges fileChange : mFileChanges) {
+ IFile file = fileChange.getFile();
+ ITextFileBufferManager lManager = FileBuffers.getTextFileBufferManager();
+ lManager.connect(file.getFullPath(), LocationKind.NORMALIZE,
+ new NullProgressMonitor());
+ ITextFileBuffer buffer = lManager.getTextFileBuffer(file.getFullPath(),
+ LocationKind.NORMALIZE);
+ IDocument lDocument = buffer.getDocument();
+ Change layoutChange = new AndroidLayoutChange(file, lDocument, lManager,
+ fileChange.getChanges());
+ if (layoutChange != null) {
+ result.add(layoutChange);
+ }
+ }
+ }
+ return (result.getChildren().length == 0) ? null : result;
+
+ }
+
+ @Override
+ public String getName() {
+ return "Android Type Rename";
+ }
+
+ @Override
+ protected boolean initialize(Object element) {
+
+ if (element instanceof IType) {
+ IType type = (IType) element;
+ IJavaProject javaProject = (IJavaProject) type.getAncestor(IJavaElement.JAVA_PROJECT);
+ IProject project = javaProject.getProject();
+ IResource manifestResource = project.findMember(AdtConstants.WS_SEP
+ + SdkConstants.FN_ANDROID_MANIFEST_XML);
+
+ if (manifestResource == null || !manifestResource.exists()
+ || !(manifestResource instanceof IFile)) {
+ RefactoringUtil.logInfo("Invalid or missing the "
+ + SdkConstants.FN_ANDROID_MANIFEST_XML + " in the " + project.getName()
+ + " project.");
+ return false;
+ }
+ mAndroidManifest = (IFile) manifestResource;
+ ManifestData manifestData;
+ manifestData = AndroidManifestHelper.parseForData(mAndroidManifest);
+ if (manifestData == null) {
+ return false;
+ }
+ mAppPackage = manifestData.getPackage();
+ mOldName = type.getFullyQualifiedName();
+ String packageName = type.getPackageFragment().getElementName();
+ mNewName = getArguments().getNewName();
+ if (packageName != null) {
+ mLayoutNewName = packageName + "." + getArguments().getNewName(); //$NON-NLS-1$
+ } else {
+ mLayoutNewName = getArguments().getNewName();
+ }
+ if (mOldName == null || mNewName == null) {
+ return false;
+ }
+ if (!RefactoringUtil.isRefactorAppPackage() && mNewName.indexOf(".") == -1) { //$NON-NLS-1$
+ mNewName = packageName + "." + mNewName; //$NON-NLS-1$
+ }
+ mAndroidElements = addAndroidElements();
+ try {
+ ITypeHierarchy typeHierarchy = type.newSupertypeHierarchy(null);
+ if (typeHierarchy == null) {
+ return false;
+ }
+ IType[] superTypes = typeHierarchy.getAllSuperclasses(type);
+ for (int i = 0; i < superTypes.length; i++) {
+ IType superType = superTypes[i];
+ String className = superType.getFullyQualifiedName();
+ if (className.equals(SdkConstants.CLASS_VIEW)) {
+ addLayoutChanges(project, type.getFullyQualifiedName());
+ break;
+ }
+ }
+ } catch (JavaModelException ignore) {
+ }
+
+ return mAndroidElements.size() > 0 || mFileChanges.size() > 0;
+ }
+ return false;
+ }
+
+ /**
+ * Adds layout changes for project
+ *
+ * @param project the Android project
+ * @param className the layout classes
+ *
+ */
+ private void addLayoutChanges(IProject project, String className) {
+ try {
+ IFolder resFolder = project.getFolder(SdkConstants.FD_RESOURCES);
+ IFolder layoutFolder = resFolder.getFolder(AndroidConstants.FD_RES_LAYOUT);
+ IResource[] members = layoutFolder.members();
+ for (int i = 0; i < members.length; i++) {
+ IResource member = members[i];
+ if ((member instanceof IFile) && member.exists()) {
+ IFile file = (IFile) member;
+ Set<AndroidLayoutChangeDescription> changes = parse(file, className);
+ if (changes.size() > 0) {
+ AndroidLayoutFileChanges fileChange = new AndroidLayoutFileChanges(file);
+ fileChange.getChanges().addAll(changes);
+ mFileChanges.add(fileChange);
+ }
+ }
+ }
+ } catch (CoreException e) {
+ RefactoringUtil.log(e);
+ }
+ }
+
+ /**
+ * Searches the layout file for classes
+ *
+ * @param file the Android layout file
+ * @param className the layout classes
+ *
+ */
+ private Set<AndroidLayoutChangeDescription> parse(IFile file, String className) {
+ Set<AndroidLayoutChangeDescription> changes = new HashSet<AndroidLayoutChangeDescription>();
+ ITextFileBufferManager lManager = null;
+ try {
+ lManager = FileBuffers.getTextFileBufferManager();
+ lManager.connect(file.getFullPath(), LocationKind.NORMALIZE, new NullProgressMonitor());
+ ITextFileBuffer buffer = lManager.getTextFileBuffer(file.getFullPath(),
+ LocationKind.NORMALIZE);
+ IDocument lDocument = buffer.getDocument();
+ IStructuredModel model = null;
+ try {
+ model = StructuredModelManager.getModelManager().getExistingModelForRead(lDocument);
+ if (model == null) {
+ if (lDocument instanceof IStructuredDocument) {
+ IStructuredDocument structuredDocument = (IStructuredDocument) lDocument;
+ model = StructuredModelManager.getModelManager().getModelForRead(
+ structuredDocument);
+ }
+ }
+ if (model != null) {
+ IDOMModel xmlModel = (IDOMModel) model;
+ IDOMDocument xmlDoc = xmlModel.getDocument();
+ NodeList nodes = xmlDoc
+ .getElementsByTagName(LayoutConstants.VIEW);
+ for (int i = 0; i < nodes.getLength(); i++) {
+ Node node = nodes.item(i);
+ NamedNodeMap attributes = node.getAttributes();
+ if (attributes != null) {
+ Node attributeNode =
+ attributes.getNamedItem(LayoutConstants.ATTR_CLASS);
+ if (attributeNode instanceof Attr) {
+ Attr attribute = (Attr) attributeNode;
+ String value = attribute.getValue();
+ if (value != null && value.equals(className)) {
+ AndroidLayoutChangeDescription layoutChange =
+ new AndroidLayoutChangeDescription(className, mLayoutNewName,
+ AndroidLayoutChangeDescription.VIEW_TYPE);
+ changes.add(layoutChange);
+ }
+ }
+ }
+ }
+ nodes = xmlDoc.getElementsByTagName(className);
+ for (int i = 0; i < nodes.getLength(); i++) {
+ AndroidLayoutChangeDescription layoutChange =
+ new AndroidLayoutChangeDescription(className, mLayoutNewName,
+ AndroidLayoutChangeDescription.STANDALONE_TYPE);
+ changes.add(layoutChange);
+ }
+ }
+ } finally {
+ if (model != null) {
+ model.releaseFromRead();
+ }
+ }
+
+ } catch (CoreException ignore) {
+ } finally {
+ if (lManager != null) {
+ try {
+ lManager.disconnect(file.getFullPath(), LocationKind.NORMALIZE,
+ new NullProgressMonitor());
+ } catch (CoreException ignore) {
+ }
+ }
+ }
+ return changes;
+ }
+
+ /**
+ * Returns the elements (activity, receiver, service ...)
+ * which have to be renamed
+ *
+ * @return the android elements
+ *
+ */
+ private Map<String, String> addAndroidElements() {
+ Map<String, String> androidElements = new HashMap<String, String>();
+
+ IDocument document;
+ try {
+ document = getDocument();
+ } catch (CoreException e) {
+ RefactoringUtil.log(e);
+ if (mManager != null) {
+ try {
+ mManager.disconnect(mAndroidManifest.getFullPath(), LocationKind.NORMALIZE,
+ new NullProgressMonitor());
+ } catch (CoreException e1) {
+ RefactoringUtil.log(e1);
+ }
+ }
+ document = null;
+ return androidElements;
+ }
+
+ IStructuredModel model = null;
+ try {
+ model = StructuredModelManager.getModelManager().getExistingModelForRead(document);
+ if (model == null) {
+ if (document instanceof IStructuredDocument) {
+ IStructuredDocument structuredDocument = (IStructuredDocument) document;
+ model = StructuredModelManager.getModelManager().getModelForRead(
+ structuredDocument);
+ }
+ }
+ if (model != null) {
+ IDOMModel xmlModel = (IDOMModel) model;
+ IDOMDocument xmlDoc = xmlModel.getDocument();
+ add(xmlDoc, androidElements, AndroidManifest.NODE_ACTIVITY,
+ AndroidManifest.ATTRIBUTE_NAME);
+ add(xmlDoc, androidElements, AndroidManifest.NODE_APPLICATION,
+ AndroidManifest.ATTRIBUTE_NAME);
+ add(xmlDoc, androidElements, AndroidManifest.NODE_PROVIDER,
+ AndroidManifest.ATTRIBUTE_NAME);
+ add(xmlDoc, androidElements, AndroidManifest.NODE_RECEIVER,
+ AndroidManifest.ATTRIBUTE_NAME);
+ add(xmlDoc, androidElements, AndroidManifest.NODE_SERVICE,
+ AndroidManifest.ATTRIBUTE_NAME);
+ }
+ } finally {
+ if (model != null) {
+ model.releaseFromRead();
+ }
+ }
+
+ return androidElements;
+ }
+
+ /**
+ * (non-Javadoc) Adds the element (activity, receiver, service ...) to the map
+ *
+ * @param xmlDoc the document
+ * @param androidElements the map
+ * @param element the element
+ */
+ private void add(IDOMDocument xmlDoc, Map<String, String> androidElements, String element,
+ String argument) {
+ NodeList nodes = xmlDoc.getElementsByTagName(element);
+ for (int i = 0; i < nodes.getLength(); i++) {
+ Node node = nodes.item(i);
+ NamedNodeMap attributes = node.getAttributes();
+ if (attributes != null) {
+ Attr attribute = RefactoringUtil.findAndroidAttributes(attributes, argument);
+ if (attribute != null) {
+ String value = attribute.getValue();
+ if (value != null) {
+ String fullName = AndroidManifest.combinePackageAndClassName(mAppPackage,
+ value);
+ if (fullName != null && fullName.equals(mOldName)) {
+ androidElements.put(element, value);
+ }
+ }
+ }
+ }
+ }
+ }
+
+
+
+}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactoring/core/FixImportsJob.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactoring/core/FixImportsJob.java
index ae40790..d3bdbfd 100755..100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactoring/core/FixImportsJob.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactoring/core/FixImportsJob.java
@@ -1,145 +1,145 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Eclipse Public License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.eclipse.org/org/documents/epl-v10.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ide.eclipse.adt.internal.refactoring.core;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IncrementalProjectBuilder;
-import org.eclipse.core.resources.WorkspaceJob;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.ISourceRange;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.search.TypeNameMatch;
-import org.eclipse.jdt.internal.corext.codemanipulation.CodeGenerationSettings;
-import org.eclipse.jdt.internal.corext.codemanipulation.OrganizeImportsOperation;
-import org.eclipse.jdt.internal.corext.codemanipulation.OrganizeImportsOperation.IChooseImportQuery;
-import org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter;
-import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;
-import org.eclipse.jdt.internal.ui.preferences.JavaPreferencesSettings;
-import org.eclipse.jdt.ui.SharedASTProvider;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.progress.IProgressService;
-
-/**
- * The helper class which fixes the import errors after refactoring
- *
- */
-@SuppressWarnings("restriction")
-public class FixImportsJob extends WorkspaceJob {
-
- private IFile mAndroidManifest;
-
- private String mJavaPackage;
-
- /**
- * Creates a new <code>FixImportsJob</code>
- *
- * @param name the job name
- * @param androidManifest the android manifest file
- * @param javaPackage the android java package
- */
- public FixImportsJob(String name, IFile androidManifest, String javaPackage) {
- super(name);
- this.mAndroidManifest = androidManifest;
- this.mJavaPackage = javaPackage;
- }
-
- @Override
- public IStatus runInWorkspace(final IProgressMonitor monitor) throws CoreException {
- if (mJavaPackage == null || mAndroidManifest == null || !mAndroidManifest.exists()) {
- return Status.CANCEL_STATUS;
- }
- IProject project = mAndroidManifest.getProject();
- IJavaProject javaProject = JavaCore.create(project);
- if (javaProject == null || !javaProject.isOpen()) {
- return Status.CANCEL_STATUS;
- }
- project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
- IMarker[] markers = project.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
- for (int i = 0; i < markers.length; i++) {
- IMarker marker = markers[i];
- IResource resource = marker.getResource();
- try {
- IJavaElement element = JavaCore.create(resource);
- if (element != null && (element instanceof ICompilationUnit)) {
- final ICompilationUnit cu = (ICompilationUnit) element;
- IPackageFragment packageFragment = (IPackageFragment) cu
- .getAncestor(IJavaElement.PACKAGE_FRAGMENT);
- if (packageFragment != null && packageFragment.exists()) {
- String packageName = packageFragment.getElementName();
- if (packageName != null && packageName.startsWith(mJavaPackage)) {
- CompilationUnit astRoot = SharedASTProvider.getAST(cu,
- SharedASTProvider.WAIT_ACTIVE_ONLY, null);
- CodeGenerationSettings settings = JavaPreferencesSettings
- .getCodeGenerationSettings(cu.getJavaProject());
- final boolean hasAmbiguity[] = new boolean[] {
- false
- };
- IChooseImportQuery query = new IChooseImportQuery() {
- public TypeNameMatch[] chooseImports(TypeNameMatch[][] openChoices,
- ISourceRange[] ranges) {
- hasAmbiguity[0] = true;
- return new TypeNameMatch[0];
- }
- };
- final OrganizeImportsOperation op = new OrganizeImportsOperation(cu,
- astRoot, settings.importIgnoreLowercase, !cu.isWorkingCopy(),
- true, query);
- Display.getDefault().asyncExec(new Runnable() {
-
- public void run() {
- try {
- IProgressService progressService = PlatformUI
- .getWorkbench().getProgressService();
- progressService.run(
- true,
- true,
- new WorkbenchRunnableAdapter(op, op
- .getScheduleRule()));
- IEditorPart openEditor = EditorUtility.isOpenInEditor(cu);
- if (openEditor != null) {
- openEditor.doSave(monitor);
- }
- } catch (Throwable e) {
- RefactoringUtil.log(e);
- }
- }
- });
-
- }
- }
- }
- } catch (Throwable e) {
- RefactoringUtil.log(e);
- }
- }
- return Status.OK_STATUS;
- }
-
-}
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/org/documents/epl-v10.php
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.ide.eclipse.adt.internal.refactoring.core;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.resources.WorkspaceJob;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.ISourceRange;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.core.search.TypeNameMatch;
+import org.eclipse.jdt.internal.corext.codemanipulation.CodeGenerationSettings;
+import org.eclipse.jdt.internal.corext.codemanipulation.OrganizeImportsOperation;
+import org.eclipse.jdt.internal.corext.codemanipulation.OrganizeImportsOperation.IChooseImportQuery;
+import org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter;
+import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;
+import org.eclipse.jdt.internal.ui.preferences.JavaPreferencesSettings;
+import org.eclipse.jdt.ui.SharedASTProvider;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.progress.IProgressService;
+
+/**
+ * The helper class which fixes the import errors after refactoring
+ *
+ */
+@SuppressWarnings("restriction")
+public class FixImportsJob extends WorkspaceJob {
+
+ private IFile mAndroidManifest;
+
+ private String mJavaPackage;
+
+ /**
+ * Creates a new <code>FixImportsJob</code>
+ *
+ * @param name the job name
+ * @param androidManifest the android manifest file
+ * @param javaPackage the android java package
+ */
+ public FixImportsJob(String name, IFile androidManifest, String javaPackage) {
+ super(name);
+ this.mAndroidManifest = androidManifest;
+ this.mJavaPackage = javaPackage;
+ }
+
+ @Override
+ public IStatus runInWorkspace(final IProgressMonitor monitor) throws CoreException {
+ if (mJavaPackage == null || mAndroidManifest == null || !mAndroidManifest.exists()) {
+ return Status.CANCEL_STATUS;
+ }
+ IProject project = mAndroidManifest.getProject();
+ IJavaProject javaProject = JavaCore.create(project);
+ if (javaProject == null || !javaProject.isOpen()) {
+ return Status.CANCEL_STATUS;
+ }
+ project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
+ IMarker[] markers = project.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
+ for (int i = 0; i < markers.length; i++) {
+ IMarker marker = markers[i];
+ IResource resource = marker.getResource();
+ try {
+ IJavaElement element = JavaCore.create(resource);
+ if (element != null && (element instanceof ICompilationUnit)) {
+ final ICompilationUnit cu = (ICompilationUnit) element;
+ IPackageFragment packageFragment = (IPackageFragment) cu
+ .getAncestor(IJavaElement.PACKAGE_FRAGMENT);
+ if (packageFragment != null && packageFragment.exists()) {
+ String packageName = packageFragment.getElementName();
+ if (packageName != null && packageName.startsWith(mJavaPackage)) {
+ CompilationUnit astRoot = SharedASTProvider.getAST(cu,
+ SharedASTProvider.WAIT_ACTIVE_ONLY, null);
+ CodeGenerationSettings settings = JavaPreferencesSettings
+ .getCodeGenerationSettings(cu.getJavaProject());
+ final boolean hasAmbiguity[] = new boolean[] {
+ false
+ };
+ IChooseImportQuery query = new IChooseImportQuery() {
+ public TypeNameMatch[] chooseImports(TypeNameMatch[][] openChoices,
+ ISourceRange[] ranges) {
+ hasAmbiguity[0] = true;
+ return new TypeNameMatch[0];
+ }
+ };
+ final OrganizeImportsOperation op = new OrganizeImportsOperation(cu,
+ astRoot, settings.importIgnoreLowercase, !cu.isWorkingCopy(),
+ true, query);
+ Display.getDefault().asyncExec(new Runnable() {
+
+ public void run() {
+ try {
+ IProgressService progressService = PlatformUI
+ .getWorkbench().getProgressService();
+ progressService.run(
+ true,
+ true,
+ new WorkbenchRunnableAdapter(op, op
+ .getScheduleRule()));
+ IEditorPart openEditor = EditorUtility.isOpenInEditor(cu);
+ if (openEditor != null) {
+ openEditor.doSave(monitor);
+ }
+ } catch (Throwable e) {
+ RefactoringUtil.log(e);
+ }
+ }
+ });
+
+ }
+ }
+ }
+ } catch (Throwable e) {
+ RefactoringUtil.log(e);
+ }
+ }
+ return Status.OK_STATUS;
+ }
+
+}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactoring/core/RefactoringUtil.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactoring/core/RefactoringUtil.java
index adc4d5a..4bf1cb3 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactoring/core/RefactoringUtil.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactoring/core/RefactoringUtil.java
@@ -86,7 +86,7 @@ public class RefactoringUtil {
Attr attribute = null;
for (int j = 0; j < attributes.getLength(); j++) {
Node attNode = attributes.item(j);
- if (attNode != null || attNode instanceof Attr) {
+ if (attNode instanceof Attr) {
Attr attr = (Attr) attNode;
String name = attr.getLocalName();
String namespace = attr.getNamespaceURI();
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactorings/extractstring/EnabledTextEditGroup.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactorings/extractstring/EnabledTextEditGroup.java
index 15f6c47..15f6c47 100755..100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactorings/extractstring/EnabledTextEditGroup.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactorings/extractstring/EnabledTextEditGroup.java
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactorings/extractstring/ReplaceStringsVisitor.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactorings/extractstring/ReplaceStringsVisitor.java
index 1a0521b..2f1185c 100755..100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactorings/extractstring/ReplaceStringsVisitor.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactorings/extractstring/ReplaceStringsVisitor.java
@@ -1,481 +1,480 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Eclipse Public License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.eclipse.org/org/documents/epl-v10.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ide.eclipse.adt.internal.refactorings.extractstring;
-
-import org.eclipse.jdt.core.dom.AST;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.ASTVisitor;
-import org.eclipse.jdt.core.dom.Assignment;
-import org.eclipse.jdt.core.dom.ClassInstanceCreation;
-import org.eclipse.jdt.core.dom.Expression;
-import org.eclipse.jdt.core.dom.IMethodBinding;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-import org.eclipse.jdt.core.dom.IVariableBinding;
-import org.eclipse.jdt.core.dom.MethodDeclaration;
-import org.eclipse.jdt.core.dom.MethodInvocation;
-import org.eclipse.jdt.core.dom.Modifier;
-import org.eclipse.jdt.core.dom.Name;
-import org.eclipse.jdt.core.dom.SimpleName;
-import org.eclipse.jdt.core.dom.SimpleType;
-import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
-import org.eclipse.jdt.core.dom.StringLiteral;
-import org.eclipse.jdt.core.dom.Type;
-import org.eclipse.jdt.core.dom.TypeDeclaration;
-import org.eclipse.jdt.core.dom.VariableDeclarationExpression;
-import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
-import org.eclipse.jdt.core.dom.VariableDeclarationStatement;
-import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
-import org.eclipse.text.edits.TextEditGroup;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.TreeMap;
-
-/**
- * Visitor used by {@link ExtractStringRefactoring} to extract a string from an existing
- * Java source and replace it by an Android XML string reference.
- *
- * @see ExtractStringRefactoring#computeJavaChanges
- */
-class ReplaceStringsVisitor extends ASTVisitor {
-
- private static final String CLASS_ANDROID_CONTEXT = "android.content.Context"; //$NON-NLS-1$
- private static final String CLASS_JAVA_CHAR_SEQUENCE = "java.lang.CharSequence"; //$NON-NLS-1$
- private static final String CLASS_JAVA_STRING = "java.lang.String"; //$NON-NLS-1$
-
-
- private final AST mAst;
- private final ASTRewrite mRewriter;
- private final String mOldString;
- private final String mRQualifier;
- private final String mXmlId;
- private final ArrayList<TextEditGroup> mEditGroups;
-
- public ReplaceStringsVisitor(AST ast,
- ASTRewrite astRewrite,
- ArrayList<TextEditGroup> editGroups,
- String oldString,
- String rQualifier,
- String xmlId) {
- mAst = ast;
- mRewriter = astRewrite;
- mEditGroups = editGroups;
- mOldString = oldString;
- mRQualifier = rQualifier;
- mXmlId = xmlId;
- }
-
- @SuppressWarnings("unchecked") //$NON-NLS-1$
- @Override
- public boolean visit(StringLiteral node) {
- if (node.getLiteralValue().equals(mOldString)) {
-
- // We want to analyze the calling context to understand whether we can
- // just replace the string literal by the named int constant (R.id.foo)
- // or if we should generate a Context.getString() call.
- boolean useGetResource = false;
- useGetResource = examineVariableDeclaration(node) ||
- examineMethodInvocation(node) ||
- examineAssignment(node);
-
- Name qualifierName = mAst.newName(mRQualifier + ".string"); //$NON-NLS-1$
- SimpleName idName = mAst.newSimpleName(mXmlId);
- ASTNode newNode = mAst.newQualifiedName(qualifierName, idName);
- boolean disabledChange = false;
- String title = "Replace string by ID";
-
- if (useGetResource) {
- Expression context = methodHasContextArgument(node);
- if (context == null && !isClassDerivedFromContext(node)) {
- // if we don't have a class that derives from Context and
- // we don't have a Context method argument, then try a bit harder:
- // can we find a method or a field that will give us a context?
- context = findContextFieldOrMethod(node);
-
- if (context == null) {
- // If not, let's write Context.getString(), which is technically
- // invalid but makes it a good clue on how to fix it. Since these
- // will not compile, we create a disabled change by default.
- context = mAst.newSimpleName("Context"); //$NON-NLS-1$
- disabledChange = true;
- }
- }
-
- MethodInvocation mi2 = mAst.newMethodInvocation();
- mi2.setName(mAst.newSimpleName("getString")); //$NON-NLS-1$
- mi2.setExpression(context);
- mi2.arguments().add(newNode);
-
- newNode = mi2;
- title = "Replace string by Context.getString(R.string...)";
- }
-
- TextEditGroup editGroup = new EnabledTextEditGroup(title, !disabledChange);
- mEditGroups.add(editGroup);
- mRewriter.replace(node, newNode, editGroup);
- }
- return super.visit(node);
- }
-
- /**
- * Examines if the StringLiteral is part of an assignment corresponding to the
- * a string variable declaration, e.g. String foo = id.
- *
- * The parent fragment is of syntax "var = expr" or "var[] = expr".
- * We want the type of the variable, which is either held by a
- * VariableDeclarationStatement ("type [fragment]") or by a
- * VariableDeclarationExpression. In either case, the type can be an array
- * but for us all that matters is to know whether the type is an int or
- * a string.
- */
- private boolean examineVariableDeclaration(StringLiteral node) {
- VariableDeclarationFragment fragment = findParentClass(node,
- VariableDeclarationFragment.class);
-
- if (fragment != null) {
- ASTNode parent = fragment.getParent();
-
- Type type = null;
- if (parent instanceof VariableDeclarationStatement) {
- type = ((VariableDeclarationStatement) parent).getType();
- } else if (parent instanceof VariableDeclarationExpression) {
- type = ((VariableDeclarationExpression) parent).getType();
- }
-
- if (type instanceof SimpleType) {
- return isJavaString(type.resolveBinding());
- }
- }
-
- return false;
- }
-
- /**
- * Examines if the StringLiteral is part of a assignment to a variable that
- * is a string. We need to lookup the variable to find its type, either in the
- * enclosing method or class type.
- */
- private boolean examineAssignment(StringLiteral node) {
-
- Assignment assignment = findParentClass(node, Assignment.class);
- if (assignment != null) {
- Expression left = assignment.getLeftHandSide();
-
- ITypeBinding typeBinding = left.resolveTypeBinding();
- return isJavaString(typeBinding);
- }
-
- return false;
- }
-
- /**
- * If the expression is part of a method invocation (aka a function call) or a
- * class instance creation (aka a "new SomeClass" constructor call), we try to
- * find the type of the argument being used. If it is a String (most likely), we
- * want to return true (to generate a getString() call). However if there might
- * be a similar method that takes an int, in which case we don't want to do that.
- *
- * This covers the case of Activity.setTitle(int resId) vs setTitle(String str).
- */
- @SuppressWarnings("unchecked") //$NON-NLS-1$
- private boolean examineMethodInvocation(StringLiteral node) {
-
- ASTNode parent = null;
- List arguments = null;
- IMethodBinding methodBinding = null;
-
- MethodInvocation invoke = findParentClass(node, MethodInvocation.class);
- if (invoke != null) {
- parent = invoke;
- arguments = invoke.arguments();
- methodBinding = invoke.resolveMethodBinding();
- } else {
- ClassInstanceCreation newclass = findParentClass(node, ClassInstanceCreation.class);
- if (newclass != null) {
- parent = newclass;
- arguments = newclass.arguments();
- methodBinding = newclass.resolveConstructorBinding();
- }
- }
-
- if (parent != null && arguments != null && methodBinding != null) {
- // We want to know which argument this is.
- // Walk up the hierarchy again to find the immediate child of the parent,
- // which should turn out to be one of the invocation arguments.
- ASTNode child = null;
- for (ASTNode n = node; n != parent; ) {
- ASTNode p = n.getParent();
- if (p == parent) {
- child = n;
- break;
- }
- n = p;
- }
- if (child == null) {
- // This can't happen: a parent of 'node' must be the child of 'parent'.
- return false;
- }
-
- // Find the index
- int index = 0;
- for (Object arg : arguments) {
- if (arg == child) {
- break;
- }
- index++;
- }
-
- if (index == arguments.size()) {
- // This can't happen: one of the arguments of 'invoke' must be 'child'.
- return false;
- }
-
- // Eventually we want to determine if the parameter is a string type,
- // in which case a Context.getString() call must be generated.
- boolean useStringType = false;
-
- // Find the type of that argument
- ITypeBinding[] types = methodBinding.getParameterTypes();
- if (index < types.length) {
- ITypeBinding type = types[index];
- useStringType = isJavaString(type);
- }
-
- // Now that we know that this method takes a String parameter, can we find
- // a variant that would accept an int for the same parameter position?
- if (useStringType) {
- String name = methodBinding.getName();
- ITypeBinding clazz = methodBinding.getDeclaringClass();
- nextMethod: for (IMethodBinding mb2 : clazz.getDeclaredMethods()) {
- if (methodBinding == mb2 || !mb2.getName().equals(name)) {
- continue;
- }
- // We found a method with the same name. We want the same parameters
- // except that the one at 'index' must be an int type.
- ITypeBinding[] types2 = mb2.getParameterTypes();
- int len2 = types2.length;
- if (types.length == len2) {
- for (int i = 0; i < len2; i++) {
- if (i == index) {
- ITypeBinding type2 = types2[i];
- if (!("int".equals(type2.getQualifiedName()))) { //$NON-NLS-1$
- // The argument at 'index' is not an int.
- continue nextMethod;
- }
- } else if (!types[i].equals(types2[i])) {
- // One of the other arguments do not match our original method
- continue nextMethod;
- }
- }
- // If we got here, we found a perfect match: a method with the same
- // arguments except the one at 'index' is an int. In this case we
- // don't need to convert our R.id into a string.
- useStringType = false;
- break;
- }
- }
- }
-
- return useStringType;
- }
- return false;
- }
-
- /**
- * Examines if the StringLiteral is part of a method declaration (a.k.a. a function
- * definition) which takes a Context argument.
- * If such, it returns the name of the variable as a {@link SimpleName}.
- * Otherwise it returns null.
- */
- private SimpleName methodHasContextArgument(StringLiteral node) {
- MethodDeclaration decl = findParentClass(node, MethodDeclaration.class);
- if (decl != null) {
- for (Object obj : decl.parameters()) {
- if (obj instanceof SingleVariableDeclaration) {
- SingleVariableDeclaration var = (SingleVariableDeclaration) obj;
- if (isAndroidContext(var.getType())) {
- return mAst.newSimpleName(var.getName().getIdentifier());
- }
- }
- }
- }
- return null;
- }
-
- /**
- * Walks up the node hierarchy to find the class (aka type) where this statement
- * is used and returns true if this class derives from android.content.Context.
- */
- private boolean isClassDerivedFromContext(StringLiteral node) {
- TypeDeclaration clazz = findParentClass(node, TypeDeclaration.class);
- if (clazz != null) {
- // This is the class that the user is currently writing, so it can't be
- // a Context by itself, it has to be derived from it.
- return isAndroidContext(clazz.getSuperclassType());
- }
- return false;
- }
-
- private Expression findContextFieldOrMethod(StringLiteral node) {
- TypeDeclaration clazz = findParentClass(node, TypeDeclaration.class);
- ITypeBinding clazzType = clazz == null ? null : clazz.resolveBinding();
- return findContextFieldOrMethod(clazzType);
- }
-
- private Expression findContextFieldOrMethod(ITypeBinding clazzType) {
- TreeMap<Integer, Expression> results = new TreeMap<Integer, Expression>();
- findContextCandidates(results, clazzType, 0 /*superType*/);
- if (results.size() > 0) {
- Integer bestRating = results.keySet().iterator().next();
- return results.get(bestRating);
- }
- return null;
- }
-
- /**
- * Find all method or fields that are candidates for providing a Context.
- * There can be various choices amongst this class or its super classes.
- * Sort them by rating in the results map.
- *
- * The best ever choice is to find a method with no argument that returns a Context.
- * The second suitable choice is to find a Context field.
- * The least desirable choice is to find a method with arguments. It's not really
- * desirable since we can't generate these arguments automatically.
- *
- * Methods and fields from supertypes are ignored if they are private.
- *
- * The rating is reversed: the lowest rating integer is used for the best candidate.
- * Because the superType argument is actually a recursion index, this makes the most
- * immediate classes more desirable.
- *
- * @param results The map that accumulates the rating=>expression results. The lower
- * rating number is the best candidate.
- * @param clazzType The class examined.
- * @param superType The recursion index.
- * 0 for the immediate class, 1 for its super class, etc.
- */
- private void findContextCandidates(TreeMap<Integer, Expression> results,
- ITypeBinding clazzType,
- int superType) {
- for (IMethodBinding mb : clazzType.getDeclaredMethods()) {
- // If we're looking at supertypes, we can't use private methods.
- if (superType != 0 && Modifier.isPrivate(mb.getModifiers())) {
- continue;
- }
-
- if (isAndroidContext(mb.getReturnType())) {
- // We found a method that returns something derived from Context.
-
- int argsLen = mb.getParameterTypes().length;
- if (argsLen == 0) {
- // We'll favor any method that takes no argument,
- // That would be the best candidate ever, so we can stop here.
- MethodInvocation mi = mAst.newMethodInvocation();
- mi.setName(mAst.newSimpleName(mb.getName()));
- results.put(Integer.MIN_VALUE, mi);
- return;
- } else {
- // A method with arguments isn't as interesting since we wouldn't
- // know how to populate such arguments. We'll use it if there are
- // no other alternatives. We'll favor the one with the less arguments.
- Integer rating = Integer.valueOf(10000 + 1000 * superType + argsLen);
- if (!results.containsKey(rating)) {
- MethodInvocation mi = mAst.newMethodInvocation();
- mi.setName(mAst.newSimpleName(mb.getName()));
- results.put(rating, mi);
- }
- }
- }
- }
-
- // A direct Context field would be more interesting than a method with
- // arguments. Try to find one.
- for (IVariableBinding var : clazzType.getDeclaredFields()) {
- // If we're looking at supertypes, we can't use private field.
- if (superType != 0 && Modifier.isPrivate(var.getModifiers())) {
- continue;
- }
-
- if (isAndroidContext(var.getType())) {
- // We found such a field. Let's use it.
- Integer rating = Integer.valueOf(superType);
- results.put(rating, mAst.newSimpleName(var.getName()));
- break;
- }
- }
-
- // Examine the super class to see if we can locate a better match
- clazzType = clazzType.getSuperclass();
- if (clazzType != null) {
- findContextCandidates(results, clazzType, superType + 1);
- }
- }
-
- /**
- * Walks up the node hierarchy and returns the first ASTNode of the requested class.
- * Only look at parents.
- *
- * Implementation note: this is a generic method so that it returns the node already
- * casted to the requested type.
- */
- @SuppressWarnings("unchecked")
- private <T extends ASTNode> T findParentClass(ASTNode node, Class<T> clazz) {
- if (node != null) {
- for (node = node.getParent(); node != null; node = node.getParent()) {
- if (node.getClass().equals(clazz)) {
- return (T) node;
- }
- }
- }
- return null;
- }
-
- /**
- * Returns true if the given type is or derives from android.content.Context.
- */
- private boolean isAndroidContext(Type type) {
- if (type != null) {
- return isAndroidContext(type.resolveBinding());
- }
- return false;
- }
-
- /**
- * Returns true if the given type is or derives from android.content.Context.
- */
- private boolean isAndroidContext(ITypeBinding type) {
- for (; type != null; type = type.getSuperclass()) {
- if (CLASS_ANDROID_CONTEXT.equals(type.getQualifiedName())) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Returns true if this type binding represents a String or CharSequence type.
- */
- private boolean isJavaString(ITypeBinding type) {
- for (; type != null; type = type.getSuperclass()) {
- if (CLASS_JAVA_STRING.equals(type.getQualifiedName()) ||
- CLASS_JAVA_CHAR_SEQUENCE.equals(type.getQualifiedName())) {
- return true;
- }
- }
- return false;
- }
-}
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/org/documents/epl-v10.php
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.ide.eclipse.adt.internal.refactorings.extractstring;
+
+import org.eclipse.jdt.core.dom.AST;
+import org.eclipse.jdt.core.dom.ASTNode;
+import org.eclipse.jdt.core.dom.ASTVisitor;
+import org.eclipse.jdt.core.dom.Assignment;
+import org.eclipse.jdt.core.dom.ClassInstanceCreation;
+import org.eclipse.jdt.core.dom.Expression;
+import org.eclipse.jdt.core.dom.IMethodBinding;
+import org.eclipse.jdt.core.dom.ITypeBinding;
+import org.eclipse.jdt.core.dom.IVariableBinding;
+import org.eclipse.jdt.core.dom.MethodDeclaration;
+import org.eclipse.jdt.core.dom.MethodInvocation;
+import org.eclipse.jdt.core.dom.Modifier;
+import org.eclipse.jdt.core.dom.Name;
+import org.eclipse.jdt.core.dom.SimpleName;
+import org.eclipse.jdt.core.dom.SimpleType;
+import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
+import org.eclipse.jdt.core.dom.StringLiteral;
+import org.eclipse.jdt.core.dom.Type;
+import org.eclipse.jdt.core.dom.TypeDeclaration;
+import org.eclipse.jdt.core.dom.VariableDeclarationExpression;
+import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
+import org.eclipse.jdt.core.dom.VariableDeclarationStatement;
+import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
+import org.eclipse.text.edits.TextEditGroup;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.TreeMap;
+
+/**
+ * Visitor used by {@link ExtractStringRefactoring} to extract a string from an existing
+ * Java source and replace it by an Android XML string reference.
+ *
+ * @see ExtractStringRefactoring#computeJavaChanges
+ */
+class ReplaceStringsVisitor extends ASTVisitor {
+
+ private static final String CLASS_ANDROID_CONTEXT = "android.content.Context"; //$NON-NLS-1$
+ private static final String CLASS_JAVA_CHAR_SEQUENCE = "java.lang.CharSequence"; //$NON-NLS-1$
+ private static final String CLASS_JAVA_STRING = "java.lang.String"; //$NON-NLS-1$
+
+
+ private final AST mAst;
+ private final ASTRewrite mRewriter;
+ private final String mOldString;
+ private final String mRQualifier;
+ private final String mXmlId;
+ private final ArrayList<TextEditGroup> mEditGroups;
+
+ public ReplaceStringsVisitor(AST ast,
+ ASTRewrite astRewrite,
+ ArrayList<TextEditGroup> editGroups,
+ String oldString,
+ String rQualifier,
+ String xmlId) {
+ mAst = ast;
+ mRewriter = astRewrite;
+ mEditGroups = editGroups;
+ mOldString = oldString;
+ mRQualifier = rQualifier;
+ mXmlId = xmlId;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public boolean visit(StringLiteral node) {
+ if (node.getLiteralValue().equals(mOldString)) {
+
+ // We want to analyze the calling context to understand whether we can
+ // just replace the string literal by the named int constant (R.id.foo)
+ // or if we should generate a Context.getString() call.
+ boolean useGetResource = false;
+ useGetResource = examineVariableDeclaration(node) ||
+ examineMethodInvocation(node) ||
+ examineAssignment(node);
+
+ Name qualifierName = mAst.newName(mRQualifier + ".string"); //$NON-NLS-1$
+ SimpleName idName = mAst.newSimpleName(mXmlId);
+ ASTNode newNode = mAst.newQualifiedName(qualifierName, idName);
+ boolean disabledChange = false;
+ String title = "Replace string by ID";
+
+ if (useGetResource) {
+ Expression context = methodHasContextArgument(node);
+ if (context == null && !isClassDerivedFromContext(node)) {
+ // if we don't have a class that derives from Context and
+ // we don't have a Context method argument, then try a bit harder:
+ // can we find a method or a field that will give us a context?
+ context = findContextFieldOrMethod(node);
+
+ if (context == null) {
+ // If not, let's write Context.getString(), which is technically
+ // invalid but makes it a good clue on how to fix it. Since these
+ // will not compile, we create a disabled change by default.
+ context = mAst.newSimpleName("Context"); //$NON-NLS-1$
+ disabledChange = true;
+ }
+ }
+
+ MethodInvocation mi2 = mAst.newMethodInvocation();
+ mi2.setName(mAst.newSimpleName("getString")); //$NON-NLS-1$
+ mi2.setExpression(context);
+ mi2.arguments().add(newNode);
+
+ newNode = mi2;
+ title = "Replace string by Context.getString(R.string...)";
+ }
+
+ TextEditGroup editGroup = new EnabledTextEditGroup(title, !disabledChange);
+ mEditGroups.add(editGroup);
+ mRewriter.replace(node, newNode, editGroup);
+ }
+ return super.visit(node);
+ }
+
+ /**
+ * Examines if the StringLiteral is part of an assignment corresponding to the
+ * a string variable declaration, e.g. String foo = id.
+ *
+ * The parent fragment is of syntax "var = expr" or "var[] = expr".
+ * We want the type of the variable, which is either held by a
+ * VariableDeclarationStatement ("type [fragment]") or by a
+ * VariableDeclarationExpression. In either case, the type can be an array
+ * but for us all that matters is to know whether the type is an int or
+ * a string.
+ */
+ private boolean examineVariableDeclaration(StringLiteral node) {
+ VariableDeclarationFragment fragment = findParentClass(node,
+ VariableDeclarationFragment.class);
+
+ if (fragment != null) {
+ ASTNode parent = fragment.getParent();
+
+ Type type = null;
+ if (parent instanceof VariableDeclarationStatement) {
+ type = ((VariableDeclarationStatement) parent).getType();
+ } else if (parent instanceof VariableDeclarationExpression) {
+ type = ((VariableDeclarationExpression) parent).getType();
+ }
+
+ if (type instanceof SimpleType) {
+ return isJavaString(type.resolveBinding());
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Examines if the StringLiteral is part of a assignment to a variable that
+ * is a string. We need to lookup the variable to find its type, either in the
+ * enclosing method or class type.
+ */
+ private boolean examineAssignment(StringLiteral node) {
+
+ Assignment assignment = findParentClass(node, Assignment.class);
+ if (assignment != null) {
+ Expression left = assignment.getLeftHandSide();
+
+ ITypeBinding typeBinding = left.resolveTypeBinding();
+ return isJavaString(typeBinding);
+ }
+
+ return false;
+ }
+
+ /**
+ * If the expression is part of a method invocation (aka a function call) or a
+ * class instance creation (aka a "new SomeClass" constructor call), we try to
+ * find the type of the argument being used. If it is a String (most likely), we
+ * want to return true (to generate a getString() call). However if there might
+ * be a similar method that takes an int, in which case we don't want to do that.
+ *
+ * This covers the case of Activity.setTitle(int resId) vs setTitle(String str).
+ */
+ @SuppressWarnings("unchecked")
+ private boolean examineMethodInvocation(StringLiteral node) {
+
+ ASTNode parent = null;
+ List arguments = null;
+ IMethodBinding methodBinding = null;
+
+ MethodInvocation invoke = findParentClass(node, MethodInvocation.class);
+ if (invoke != null) {
+ parent = invoke;
+ arguments = invoke.arguments();
+ methodBinding = invoke.resolveMethodBinding();
+ } else {
+ ClassInstanceCreation newclass = findParentClass(node, ClassInstanceCreation.class);
+ if (newclass != null) {
+ parent = newclass;
+ arguments = newclass.arguments();
+ methodBinding = newclass.resolveConstructorBinding();
+ }
+ }
+
+ if (parent != null && arguments != null && methodBinding != null) {
+ // We want to know which argument this is.
+ // Walk up the hierarchy again to find the immediate child of the parent,
+ // which should turn out to be one of the invocation arguments.
+ ASTNode child = null;
+ for (ASTNode n = node; n != parent; ) {
+ ASTNode p = n.getParent();
+ if (p == parent) {
+ child = n;
+ break;
+ }
+ n = p;
+ }
+ if (child == null) {
+ // This can't happen: a parent of 'node' must be the child of 'parent'.
+ return false;
+ }
+
+ // Find the index
+ int index = 0;
+ for (Object arg : arguments) {
+ if (arg == child) {
+ break;
+ }
+ index++;
+ }
+
+ if (index == arguments.size()) {
+ // This can't happen: one of the arguments of 'invoke' must be 'child'.
+ return false;
+ }
+
+ // Eventually we want to determine if the parameter is a string type,
+ // in which case a Context.getString() call must be generated.
+ boolean useStringType = false;
+
+ // Find the type of that argument
+ ITypeBinding[] types = methodBinding.getParameterTypes();
+ if (index < types.length) {
+ ITypeBinding type = types[index];
+ useStringType = isJavaString(type);
+ }
+
+ // Now that we know that this method takes a String parameter, can we find
+ // a variant that would accept an int for the same parameter position?
+ if (useStringType) {
+ String name = methodBinding.getName();
+ ITypeBinding clazz = methodBinding.getDeclaringClass();
+ nextMethod: for (IMethodBinding mb2 : clazz.getDeclaredMethods()) {
+ if (methodBinding == mb2 || !mb2.getName().equals(name)) {
+ continue;
+ }
+ // We found a method with the same name. We want the same parameters
+ // except that the one at 'index' must be an int type.
+ ITypeBinding[] types2 = mb2.getParameterTypes();
+ int len2 = types2.length;
+ if (types.length == len2) {
+ for (int i = 0; i < len2; i++) {
+ if (i == index) {
+ ITypeBinding type2 = types2[i];
+ if (!("int".equals(type2.getQualifiedName()))) { //$NON-NLS-1$
+ // The argument at 'index' is not an int.
+ continue nextMethod;
+ }
+ } else if (!types[i].equals(types2[i])) {
+ // One of the other arguments do not match our original method
+ continue nextMethod;
+ }
+ }
+ // If we got here, we found a perfect match: a method with the same
+ // arguments except the one at 'index' is an int. In this case we
+ // don't need to convert our R.id into a string.
+ useStringType = false;
+ break;
+ }
+ }
+ }
+
+ return useStringType;
+ }
+ return false;
+ }
+
+ /**
+ * Examines if the StringLiteral is part of a method declaration (a.k.a. a function
+ * definition) which takes a Context argument.
+ * If such, it returns the name of the variable as a {@link SimpleName}.
+ * Otherwise it returns null.
+ */
+ private SimpleName methodHasContextArgument(StringLiteral node) {
+ MethodDeclaration decl = findParentClass(node, MethodDeclaration.class);
+ if (decl != null) {
+ for (Object obj : decl.parameters()) {
+ if (obj instanceof SingleVariableDeclaration) {
+ SingleVariableDeclaration var = (SingleVariableDeclaration) obj;
+ if (isAndroidContext(var.getType())) {
+ return mAst.newSimpleName(var.getName().getIdentifier());
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Walks up the node hierarchy to find the class (aka type) where this statement
+ * is used and returns true if this class derives from android.content.Context.
+ */
+ private boolean isClassDerivedFromContext(StringLiteral node) {
+ TypeDeclaration clazz = findParentClass(node, TypeDeclaration.class);
+ if (clazz != null) {
+ // This is the class that the user is currently writing, so it can't be
+ // a Context by itself, it has to be derived from it.
+ return isAndroidContext(clazz.getSuperclassType());
+ }
+ return false;
+ }
+
+ private Expression findContextFieldOrMethod(StringLiteral node) {
+ TypeDeclaration clazz = findParentClass(node, TypeDeclaration.class);
+ return clazz == null ? null : findContextFieldOrMethod(clazz.resolveBinding());
+ }
+
+ private Expression findContextFieldOrMethod(ITypeBinding clazzType) {
+ TreeMap<Integer, Expression> results = new TreeMap<Integer, Expression>();
+ findContextCandidates(results, clazzType, 0 /*superType*/);
+ if (results.size() > 0) {
+ Integer bestRating = results.keySet().iterator().next();
+ return results.get(bestRating);
+ }
+ return null;
+ }
+
+ /**
+ * Find all method or fields that are candidates for providing a Context.
+ * There can be various choices amongst this class or its super classes.
+ * Sort them by rating in the results map.
+ *
+ * The best ever choice is to find a method with no argument that returns a Context.
+ * The second suitable choice is to find a Context field.
+ * The least desirable choice is to find a method with arguments. It's not really
+ * desirable since we can't generate these arguments automatically.
+ *
+ * Methods and fields from supertypes are ignored if they are private.
+ *
+ * The rating is reversed: the lowest rating integer is used for the best candidate.
+ * Because the superType argument is actually a recursion index, this makes the most
+ * immediate classes more desirable.
+ *
+ * @param results The map that accumulates the rating=>expression results. The lower
+ * rating number is the best candidate.
+ * @param clazzType The class examined.
+ * @param superType The recursion index.
+ * 0 for the immediate class, 1 for its super class, etc.
+ */
+ private void findContextCandidates(TreeMap<Integer, Expression> results,
+ ITypeBinding clazzType,
+ int superType) {
+ for (IMethodBinding mb : clazzType.getDeclaredMethods()) {
+ // If we're looking at supertypes, we can't use private methods.
+ if (superType != 0 && Modifier.isPrivate(mb.getModifiers())) {
+ continue;
+ }
+
+ if (isAndroidContext(mb.getReturnType())) {
+ // We found a method that returns something derived from Context.
+
+ int argsLen = mb.getParameterTypes().length;
+ if (argsLen == 0) {
+ // We'll favor any method that takes no argument,
+ // That would be the best candidate ever, so we can stop here.
+ MethodInvocation mi = mAst.newMethodInvocation();
+ mi.setName(mAst.newSimpleName(mb.getName()));
+ results.put(Integer.MIN_VALUE, mi);
+ return;
+ } else {
+ // A method with arguments isn't as interesting since we wouldn't
+ // know how to populate such arguments. We'll use it if there are
+ // no other alternatives. We'll favor the one with the less arguments.
+ Integer rating = Integer.valueOf(10000 + 1000 * superType + argsLen);
+ if (!results.containsKey(rating)) {
+ MethodInvocation mi = mAst.newMethodInvocation();
+ mi.setName(mAst.newSimpleName(mb.getName()));
+ results.put(rating, mi);
+ }
+ }
+ }
+ }
+
+ // A direct Context field would be more interesting than a method with
+ // arguments. Try to find one.
+ for (IVariableBinding var : clazzType.getDeclaredFields()) {
+ // If we're looking at supertypes, we can't use private field.
+ if (superType != 0 && Modifier.isPrivate(var.getModifiers())) {
+ continue;
+ }
+
+ if (isAndroidContext(var.getType())) {
+ // We found such a field. Let's use it.
+ Integer rating = Integer.valueOf(superType);
+ results.put(rating, mAst.newSimpleName(var.getName()));
+ break;
+ }
+ }
+
+ // Examine the super class to see if we can locate a better match
+ clazzType = clazzType.getSuperclass();
+ if (clazzType != null) {
+ findContextCandidates(results, clazzType, superType + 1);
+ }
+ }
+
+ /**
+ * Walks up the node hierarchy and returns the first ASTNode of the requested class.
+ * Only look at parents.
+ *
+ * Implementation note: this is a generic method so that it returns the node already
+ * casted to the requested type.
+ */
+ @SuppressWarnings("unchecked")
+ private <T extends ASTNode> T findParentClass(ASTNode node, Class<T> clazz) {
+ if (node != null) {
+ for (node = node.getParent(); node != null; node = node.getParent()) {
+ if (node.getClass().equals(clazz)) {
+ return (T) node;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns true if the given type is or derives from android.content.Context.
+ */
+ private boolean isAndroidContext(Type type) {
+ if (type != null) {
+ return isAndroidContext(type.resolveBinding());
+ }
+ return false;
+ }
+
+ /**
+ * Returns true if the given type is or derives from android.content.Context.
+ */
+ private boolean isAndroidContext(ITypeBinding type) {
+ for (; type != null; type = type.getSuperclass()) {
+ if (CLASS_ANDROID_CONTEXT.equals(type.getQualifiedName())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Returns true if this type binding represents a String or CharSequence type.
+ */
+ private boolean isJavaString(ITypeBinding type) {
+ for (; type != null; type = type.getSuperclass()) {
+ if (CLASS_JAVA_STRING.equals(type.getQualifiedName()) ||
+ CLASS_JAVA_CHAR_SEQUENCE.equals(type.getQualifiedName())) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactorings/renamepackage/ApplicationPackageNameRefactoring.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactorings/renamepackage/ApplicationPackageNameRefactoring.java
index 3df35bc..3df35bc 100755..100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactorings/renamepackage/ApplicationPackageNameRefactoring.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactorings/renamepackage/ApplicationPackageNameRefactoring.java
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactorings/renamepackage/ApplicationPackageNameRefactoringWizard.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactorings/renamepackage/ApplicationPackageNameRefactoringWizard.java
index 3651855..3651855 100755..100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactorings/renamepackage/ApplicationPackageNameRefactoringWizard.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactorings/renamepackage/ApplicationPackageNameRefactoringWizard.java
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/CyclicDependencyValidator.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/CyclicDependencyValidator.java
index 625adc6..809f099 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/CyclicDependencyValidator.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/CyclicDependencyValidator.java
@@ -33,9 +33,7 @@ public class CyclicDependencyValidator implements IInputValidator {
public String isValid(String newText) {
if (mInvalidIds.contains(newText)) {
- return String.format(
- "Cyclic include, not valid",
- newText);
+ return "Cyclic include, not valid";
}
return null;
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ResourceManager.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ResourceManager.java
index e41cde5..cacd8e2 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ResourceManager.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ResourceManager.java
@@ -89,7 +89,7 @@ public final class ResourceManager {
* Interface to be notified of resource changes.
*
* @see ResourceManager#addListener(IResourceListener)
- * @see ResourceManager#removeListener(IResource)
+ * @see ResourceManager#removeListener(IResourceListener)
*/
public interface IResourceListener {
/**
@@ -146,7 +146,7 @@ public final class ResourceManager {
* Removes an {@link IResourceListener}, so that it's not notified of resource changes anymore.
* @param listener the listener to be removed.
*/
- public void removeListener(IResource listener) {
+ public void removeListener(IResourceListener listener) {
synchronized (mListeners) {
mListeners.remove(listener);
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/sdk/ProjectState.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/sdk/ProjectState.java
index 0d58201..d57cdaf 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/sdk/ProjectState.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/sdk/ProjectState.java
@@ -379,13 +379,13 @@ public final class ProjectState {
*
* @return the matching LibraryState or <code>null</code>
*
- * @see #needs(IProject)
+ * @see #needs(ProjectState)
*/
public LibraryState getLibrary(IProject library) {
synchronized (mLibraries) {
for (LibraryState state : mLibraries) {
ProjectState ps = state.getProjectState();
- if (ps != null && ps.equals(library)) {
+ if (ps != null && ps.getProject().equals(library)) {
return state;
}
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/newxmlfile/NewXmlFileCreationPage.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/newxmlfile/NewXmlFileCreationPage.java
index c4f86a6..87ccf09 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/newxmlfile/NewXmlFileCreationPage.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/newxmlfile/NewXmlFileCreationPage.java
@@ -34,8 +34,8 @@ import com.android.ide.eclipse.adt.internal.editors.descriptors.IDescriptorProvi
import com.android.ide.eclipse.adt.internal.editors.menu.descriptors.MenuDescriptors;
import com.android.ide.eclipse.adt.internal.editors.resources.descriptors.ResourcesDescriptors;
import com.android.ide.eclipse.adt.internal.project.BaseProjectHelper;
-import com.android.ide.eclipse.adt.internal.project.ProjectChooserHelper;
import com.android.ide.eclipse.adt.internal.project.BaseProjectHelper.IProjectFilter;
+import com.android.ide.eclipse.adt.internal.project.ProjectChooserHelper;
import com.android.ide.eclipse.adt.internal.resources.ResourceNameValidator;
import com.android.ide.eclipse.adt.internal.sdk.AndroidTargetData;
import com.android.ide.eclipse.adt.internal.sdk.Sdk;
@@ -269,7 +269,7 @@ class NewXmlFileCreationPage extends WizardPage {
return String.format(
"android:orientation=\"vertical\"\n" //$NON-NLS-1$
+ "android:layout_width=\"%1$s\"\n" //$NON-NLS-1$
- + "android:layout_height=\"%1$s\"", //$NON-NLS-1$
+ + "android:layout_height=\"%2$s\"", //$NON-NLS-1$
fill, fill);
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/newxmlfile/NewXmlFileWizard.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/newxmlfile/NewXmlFileWizard.java
index 442568f..7e7362d 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/newxmlfile/NewXmlFileWizard.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/newxmlfile/NewXmlFileWizard.java
@@ -249,7 +249,7 @@ public class NewXmlFileWizard extends Wizard implements INewWizard {
private static boolean createWsParentDirectory(IContainer wsPath) {
if (wsPath.getType() == IResource.FOLDER) {
- if (wsPath == null || wsPath.exists()) {
+ if (wsPath.exists()) {
return true;
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.ddms/.settings/org.eclipse.jdt.core.prefs b/eclipse/plugins/com.android.ide.eclipse.ddms/.settings/org.eclipse.jdt.core.prefs
index 1cb4685..e755df2 100644
--- a/eclipse/plugins/com.android.ide.eclipse.ddms/.settings/org.eclipse.jdt.core.prefs
+++ b/eclipse/plugins/com.android.ide.eclipse.ddms/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,4 @@
-#Wed Mar 09 14:02:32 PST 2011
+#Thu Jun 09 12:26:44 PDT 2011
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
@@ -16,6 +16,7 @@ org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
@@ -24,6 +25,7 @@ org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
@@ -37,11 +39,15 @@ org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
@@ -55,6 +61,7 @@ org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverridin
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
diff --git a/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/.settings/org.eclipse.jdt.core.prefs b/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/.settings/org.eclipse.jdt.core.prefs
index 1cb4685..e755df2 100644
--- a/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/.settings/org.eclipse.jdt.core.prefs
+++ b/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,4 @@
-#Wed Mar 09 14:02:32 PST 2011
+#Thu Jun 09 12:26:44 PDT 2011
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
@@ -16,6 +16,7 @@ org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
@@ -24,6 +25,7 @@ org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
@@ -37,11 +39,15 @@ org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
@@ -55,6 +61,7 @@ org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverridin
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
diff --git a/eclipse/plugins/com.android.ide.eclipse.pdt/.settings/org.eclipse.jdt.core.prefs b/eclipse/plugins/com.android.ide.eclipse.pdt/.settings/org.eclipse.jdt.core.prefs
index 1cb4685..e755df2 100644
--- a/eclipse/plugins/com.android.ide.eclipse.pdt/.settings/org.eclipse.jdt.core.prefs
+++ b/eclipse/plugins/com.android.ide.eclipse.pdt/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,4 @@
-#Wed Mar 09 14:02:32 PST 2011
+#Thu Jun 09 12:26:44 PDT 2011
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
@@ -16,6 +16,7 @@ org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
@@ -24,6 +25,7 @@ org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
@@ -37,11 +39,15 @@ org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
@@ -55,6 +61,7 @@ org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverridin
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/.settings/org.eclipse.jdt.core.prefs b/eclipse/plugins/com.android.ide.eclipse.tests/.settings/org.eclipse.jdt.core.prefs
index 1cb4685..e755df2 100644
--- a/eclipse/plugins/com.android.ide.eclipse.tests/.settings/org.eclipse.jdt.core.prefs
+++ b/eclipse/plugins/com.android.ide.eclipse.tests/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,4 @@
-#Wed Mar 09 14:02:32 PST 2011
+#Thu Jun 09 12:26:44 PDT 2011
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
@@ -16,6 +16,7 @@ org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
@@ -24,6 +25,7 @@ org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
@@ -37,11 +39,15 @@ org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
@@ -55,6 +61,7 @@ org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverridin
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
diff --git a/eclipse/plugins/com.android.ide.eclipse.traceview/.settings/org.eclipse.jdt.core.prefs b/eclipse/plugins/com.android.ide.eclipse.traceview/.settings/org.eclipse.jdt.core.prefs
index 1cb4685..e755df2 100644
--- a/eclipse/plugins/com.android.ide.eclipse.traceview/.settings/org.eclipse.jdt.core.prefs
+++ b/eclipse/plugins/com.android.ide.eclipse.traceview/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,4 @@
-#Wed Mar 09 14:02:32 PST 2011
+#Thu Jun 09 12:26:44 PDT 2011
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
@@ -16,6 +16,7 @@ org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
@@ -24,6 +25,7 @@ org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
@@ -37,11 +39,15 @@ org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
@@ -55,6 +61,7 @@ org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverridin
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
diff --git a/ide_common/.settings/org.eclipse.jdt.core.prefs b/ide_common/.settings/org.eclipse.jdt.core.prefs
index 1cb4685..e755df2 100644
--- a/ide_common/.settings/org.eclipse.jdt.core.prefs
+++ b/ide_common/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,4 @@
-#Wed Mar 09 14:02:32 PST 2011
+#Thu Jun 09 12:26:44 PDT 2011
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
@@ -16,6 +16,7 @@ org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
@@ -24,6 +25,7 @@ org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
@@ -37,11 +39,15 @@ org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
@@ -55,6 +61,7 @@ org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverridin
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
diff --git a/layoutlib_api/.settings/org.eclipse.jdt.core.prefs b/layoutlib_api/.settings/org.eclipse.jdt.core.prefs
index 1cb4685..e755df2 100644
--- a/layoutlib_api/.settings/org.eclipse.jdt.core.prefs
+++ b/layoutlib_api/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,4 @@
-#Wed Mar 09 14:02:32 PST 2011
+#Thu Jun 09 12:26:44 PDT 2011
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
@@ -16,6 +16,7 @@ org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
@@ -24,6 +25,7 @@ org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
@@ -37,11 +39,15 @@ org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
@@ -55,6 +61,7 @@ org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverridin
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
diff --git a/sdkmanager/app/.settings/org.eclipse.jdt.core.prefs b/sdkmanager/app/.settings/org.eclipse.jdt.core.prefs
index a363b10..e755df2 100644
--- a/sdkmanager/app/.settings/org.eclipse.jdt.core.prefs
+++ b/sdkmanager/app/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,4 @@
-#Wed Mar 16 15:11:09 PDT 2011
+#Thu Jun 09 12:26:44 PDT 2011
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
@@ -16,6 +16,7 @@ org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
@@ -24,6 +25,7 @@ org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
@@ -37,11 +39,15 @@ org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
@@ -55,6 +61,7 @@ org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverridin
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
diff --git a/sdkmanager/libs/sdklib/.settings/org.eclipse.jdt.core.prefs b/sdkmanager/libs/sdklib/.settings/org.eclipse.jdt.core.prefs
index cba2e98..e755df2 100644
--- a/sdkmanager/libs/sdklib/.settings/org.eclipse.jdt.core.prefs
+++ b/sdkmanager/libs/sdklib/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,4 @@
-#Wed Mar 16 15:10:56 PDT 2011
+#Thu Jun 09 12:26:44 PDT 2011
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
@@ -16,6 +16,7 @@ org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
@@ -24,6 +25,7 @@ org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
@@ -37,11 +39,15 @@ org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
@@ -55,6 +61,7 @@ org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverridin
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
diff --git a/sdkmanager/libs/sdkuilib/.settings/org.eclipse.jdt.core.prefs b/sdkmanager/libs/sdkuilib/.settings/org.eclipse.jdt.core.prefs
index 17cc168..e755df2 100644
--- a/sdkmanager/libs/sdkuilib/.settings/org.eclipse.jdt.core.prefs
+++ b/sdkmanager/libs/sdkuilib/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,4 @@
-#Wed Mar 16 15:10:22 PDT 2011
+#Thu Jun 09 12:26:44 PDT 2011
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
@@ -16,6 +16,7 @@ org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
@@ -24,6 +25,7 @@ org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
@@ -37,11 +39,15 @@ org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
@@ -55,6 +61,7 @@ org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverridin
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled