Fix WrongIdFormat exception on Android XML widgets with non-@+id/ format
This commit is contained in:
+3
-1
@@ -129,7 +129,9 @@ public class AndroidRenameProcessor : RenamePsiElementProcessor() {
|
||||
if (element == null) return
|
||||
val oldPropName = AndroidResourceUtil.getResourceNameByReferenceText(attribute.getValue())
|
||||
val newPropName = idToName(newName)
|
||||
renameSyntheticProperties(allRenames, newPropName, oldPropName, processor)
|
||||
if (oldPropName != null && newPropName != null) {
|
||||
renameSyntheticProperties(allRenames, newPropName, oldPropName, processor)
|
||||
}
|
||||
}
|
||||
|
||||
private fun renameSyntheticProperties(
|
||||
|
||||
+2
-1
@@ -45,7 +45,8 @@ class AndroidXmlVisitor(
|
||||
val attributeValue = attribute.getValue()
|
||||
if (attributeValue != null) {
|
||||
val classNameAttr = tag?.getAttribute(AndroidConst.CLASS_ATTRIBUTE_NO_NAMESPACE)?.getValue() ?: tag?.getLocalName()
|
||||
elementCallback(idToName(attributeValue), classNameAttr!!, attribute)
|
||||
val name = idToName(attributeValue)
|
||||
if (name != null) elementCallback(name, classNameAttr!!, attribute)
|
||||
}
|
||||
}
|
||||
tag?.acceptChildren(this)
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/item_detail_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ItemDetailActivity"
|
||||
tools:ignore="MergeRootFrame" >
|
||||
|
||||
<Button
|
||||
android:id="@android:id/text1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/login"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Sign in" />
|
||||
|
||||
</FrameLayout>
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.myapp
|
||||
|
||||
import android.app.Activity
|
||||
import android.os.Bundle
|
||||
import java.io.File
|
||||
import kotlinx.android.synthetic.layout.*
|
||||
|
||||
public class MyActivity : Activity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {}
|
||||
val button = login<caret>
|
||||
|
||||
fun f() = login.toString()
|
||||
}
|
||||
|
||||
+6
@@ -59,4 +59,10 @@ public class AndroidFindUsagesTestGenerated extends AbstractAndroidFindUsagesTes
|
||||
String fileName = JetTestUtils.navigationMetadata("plugins/android-idea-plugin/testData/android/findUsages/simple/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("wrongIdFormat")
|
||||
public void testWrongIdFormat() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("plugins/android-idea-plugin/testData/android/findUsages/wrongIdFormat/");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user