aboutsummaryrefslogtreecommitdiffstats
path: root/eclipse/plugins/com.android.ide.eclipse.tests
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2011-06-08 17:19:20 -0700
committerTor Norbye <tnorbye@google.com>2011-06-08 17:19:20 -0700
commitc99b6718c30d75adb36727d3f9feaa4e89c5d181 (patch)
treec89cfdca6c40cf61c301ad912142ea6f18eda578 /eclipse/plugins/com.android.ide.eclipse.tests
parent52a4e9a3afd7aecd06801b42d2ba8786ce824921 (diff)
downloadsdk-c99b6718c30d75adb36727d3f9feaa4e89c5d181.zip
sdk-c99b6718c30d75adb36727d3f9feaa4e89c5d181.tar.gz
sdk-c99b6718c30d75adb36727d3f9feaa4e89c5d181.tar.bz2
Suggest similar class names or missing pkgs in the error console
If the layout XML file contains typos, the rendering will fail and the canvas will list the missing classes along with hyperlinks to create a new class, configure the build path etc. This changeset looks for "typos" in the view names and if it finds a similar real view class, either among the Android views or among the custom views in the current project, then it will add a hyperlink suggestion to fix the XML by editing the name to the correct spelling. It also handles the scenario where you have typed in a custom view class name correctly, but have forgotten to include its package. In a followup changeset this functionality will be available from the XML editing quick assistant as well. Change-Id: Iaefd3f503795e25e6eb38353c60c645061d4814e
Diffstat (limited to 'eclipse/plugins/com.android.ide.eclipse.tests')
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/AdtUtilsTest.java12
1 files changed, 12 insertions, 0 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/AdtUtilsTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/AdtUtilsTest.java
index 2589841..6f56f73 100644
--- a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/AdtUtilsTest.java
+++ b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/AdtUtilsTest.java
@@ -45,4 +45,16 @@ public class AdtUtilsTest extends TestCase {
assertSame("Foo", AdtUtils.capitalize("Foo"));
assertNull(null, AdtUtils.capitalize(null));
}
+
+ public void testEditDistance() {
+ // editing kitten to sitting has edit distance 3:
+ // replace k with s
+ // replace e with i
+ // append g
+ assertEquals(3, AdtUtils.editDistance("kitten", "sitting"));
+
+ assertEquals(3, AdtUtils.editDistance("saturday", "sunday"));
+ assertEquals(1, AdtUtils.editDistance("button", "bitton"));
+ assertEquals(6, AdtUtils.editDistance("radiobutton", "bitton"));
+ }
}