Do not pass resource manager to AndroidXmlVisitor and AndroidXmlHandler
This commit is contained in:
+5
-6
@@ -26,10 +26,7 @@ import org.jetbrains.kotlin.lang.resolve.android.AndroidConst
|
||||
import org.jetbrains.kotlin.lang.resolve.android
|
||||
import org.jetbrains.kotlin.lang.resolve.android.idToName
|
||||
|
||||
class AndroidXmlVisitor(
|
||||
val resourceManager: AndroidResourceManager,
|
||||
val elementCallback: (String, String, XmlAttribute) -> Unit
|
||||
) : XmlElementVisitor() {
|
||||
class AndroidXmlVisitor(val elementCallback: (String, String, XmlAttribute) -> Unit) : XmlElementVisitor() {
|
||||
|
||||
override fun visitElement(element: PsiElement) {
|
||||
element.acceptChildren(this)
|
||||
@@ -45,8 +42,10 @@ class AndroidXmlVisitor(
|
||||
val attributeValue = attribute.getValue()
|
||||
if (attributeValue != null) {
|
||||
val classNameAttr = tag?.getAttribute(AndroidConst.CLASS_ATTRIBUTE_NO_NAMESPACE)?.getValue() ?: tag?.getLocalName()
|
||||
val name = idToName(attributeValue)
|
||||
if (name != null) elementCallback(name, classNameAttr!!, attribute)
|
||||
if (classNameAttr != null) {
|
||||
val name = idToName(attributeValue)
|
||||
if (name != null) elementCallback(name, classNameAttr!!, attribute)
|
||||
}
|
||||
}
|
||||
}
|
||||
tag?.acceptChildren(this)
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ public class IDEAndroidResourceManager(val module: Module) : AndroidResourceMana
|
||||
override fun idToXmlAttribute(id: String): PsiElement? {
|
||||
var ret: PsiElement? = null
|
||||
for (file in getLayoutXmlFiles()) {
|
||||
file.accept(AndroidXmlVisitor(this, { retId, wClass, valueElement ->
|
||||
file.accept(AndroidXmlVisitor({ retId, wClass, valueElement ->
|
||||
if (retId == id) ret = valueElement
|
||||
}))
|
||||
}
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ class IDEAndroidUIXmlProcessor(val module: Module) : AndroidUIXmlProcessor(modul
|
||||
|
||||
override fun parseSingleFile(file: PsiFile): List<AndroidWidget> {
|
||||
val widgets = arrayListOf<AndroidWidget>()
|
||||
file.accept(AndroidXmlVisitor(resourceManager, { id, wClass, valueElement ->
|
||||
file.accept(AndroidXmlVisitor({ id, wClass, valueElement ->
|
||||
widgets.add(AndroidWidget(id, wClass))
|
||||
}))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user