From c99b6718c30d75adb36727d3f9feaa4e89c5d181 Mon Sep 17 00:00:00 2001 From: Tor Norbye Date: Wed, 8 Jun 2011 17:19:20 -0700 Subject: 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 --- .../unittests/com/android/ide/eclipse/adt/AdtUtilsTest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'eclipse/plugins/com.android.ide.eclipse.tests') 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")); + } } -- cgit v1.1