aboutsummaryrefslogtreecommitdiffstats
path: root/eclipse
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2012-03-06 17:50:42 -0800
committerTor Norbye <tnorbye@google.com>2012-03-06 17:50:42 -0800
commit9a654c3e45ec87e29d0644ab6fb3c830fa73e5ba (patch)
treeb144195ee457671ec3b9d077b11bc9a4d530c462 /eclipse
parentcd3617b0c4d32a23f0dbe71cfaed40fdba5f9865 (diff)
downloadsdk-9a654c3e45ec87e29d0644ab6fb3c830fa73e5ba.zip
sdk-9a654c3e45ec87e29d0644ab6fb3c830fa73e5ba.tar.gz
sdk-9a654c3e45ec87e29d0644ab6fb3c830fa73e5ba.tar.bz2
Misc Lint Fixes
This changeset contains fixes for several unrelated reported lint bugs: 26505: Default disabled rules that are explicitly enabled do not activate 26467: Lint says ByteBuffer.array is API 9+ but it's really API 1+ 26501: Warning "This tag and its children can be replaced by one <TextView/> and a compound drawable" is not always correct (Partially fixed) It also fixes the following bugs: - The quickfix for the typography detector did not work for the fraction warning (replacing 1/2 with the half unicode symbol etc) - A couple of XML detectors did not check for SuppressLint on the associated root node - Add a --exitcode flag, and only set the exit code to non-zero if that flag is specified. Also fix the code such that non-fatal errors also contribute to the exit code. - Make the HTML reporter classes public to help Maven integration. Change-Id: I60f5fdcb2a465d51fa58bb918a195b373096d54b
Diffstat (limited to 'eclipse')
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/UseCompoundDrawableRefactoring.java12
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/UseCompoundDrawableRefactoringTest.java5
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound5-expected-7.xml9
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound5.info3
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound5.xml18
5 files changed, 47 insertions, 0 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/UseCompoundDrawableRefactoring.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/UseCompoundDrawableRefactoring.java
index 0480cda..53b8f49 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/UseCompoundDrawableRefactoring.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/UseCompoundDrawableRefactoring.java
@@ -56,6 +56,7 @@ import org.eclipse.text.edits.MultiTextEdit;
import org.eclipse.text.edits.ReplaceEdit;
import org.eclipse.text.edits.TextEdit;
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
@@ -283,6 +284,17 @@ public class UseCompoundDrawableRefactoring extends VisualRefactoring {
setAndroidAttribute(newTextElement, androidNsPrefix, drawableAttribute, src);
+ // If the removed LinearLayout is the root container, transfer its namespace
+ // declaration to the TextView
+ if (layout.getParentNode() instanceof Document) {
+ List<Attr> declarations = findNamespaceAttributes(layout);
+ for (Attr attribute : declarations) {
+ if (attribute instanceof IndexedRegion) {
+ newTextElement.setAttribute(attribute.getName(), attribute.getValue());
+ }
+ }
+ }
+
// Update any layout references to the layout to point to the text view
String layoutId = getId(layout);
if (layoutId.length() > 0) {
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/UseCompoundDrawableRefactoringTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/UseCompoundDrawableRefactoringTest.java
index 04b9b1a..c1a5ca4 100644
--- a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/UseCompoundDrawableRefactoringTest.java
+++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/UseCompoundDrawableRefactoringTest.java
@@ -57,6 +57,11 @@ public class UseCompoundDrawableRefactoringTest extends RefactoringTest {
checkRefactoring("refactoring/usecompound/compound_all.xml", "@+id/layout3");
}
+ public void test7() throws Exception {
+ // Test converting where a namespace needs to be migrated
+ checkRefactoring("refactoring/usecompound/compound5.xml", "@+id/layout");
+ }
+
private void checkRefactoring(String basename, String id) throws Exception {
IFile file = getLayoutFile(getProject(), basename);
TestContext info = setupTestContext(file, basename);
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound5-expected-7.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound5-expected-7.xml
new file mode 100644
index 0000000..e909811
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound5-expected-7.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/TextView1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:drawableBottom="@drawable/ic_launcher"
+ android:text="Hello World" >
+
+</TextView> \ No newline at end of file
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound5.info b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound5.info
new file mode 100644
index 0000000..8eb5c4b
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound5.info
@@ -0,0 +1,3 @@
+android.widget.LinearLayout [0,74,480,800] <LinearLayout>
+ android.widget.TextView [0,0,107,26] <TextView>
+ android.widget.ImageView [0,26,72,98] <ImageView>
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound5.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound5.xml
new file mode 100644
index 0000000..49c0594
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound5.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:id="@+id/layout"
+ android:orientation="vertical" >
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Hello World" />
+
+ <ImageView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:src="@drawable/ic_launcher" />
+
+</LinearLayout>