Refactoring: handle base AndroidResource class (in order to support <fragment>)

This commit is contained in:
Yan Zhulanow
2015-04-03 16:27:13 +03:00
parent 2cf478c864
commit bc4a342a38
7 changed files with 88 additions and 50 deletions
@@ -44,10 +44,9 @@ class AndroidXmlVisitor(val elementCallback: (String, String, XmlAttribute) -> U
if (idAttributeValue != null) {
val classAttributeValue = tag?.getAttribute(AndroidConst.CLASS_ATTRIBUTE_NO_NAMESPACE)?.getValue()
val xmlType = classAttributeValue ?: localName
val widgetType = xmlType.let { getRealWidgetType(it) }
if (isResourceDeclarationOrUsage(idAttributeValue)) {
val name = idToName(idAttributeValue)
if (name != null) elementCallback(name, widgetType, idAttribute)
if (name != null) elementCallback(name, xmlType, idAttribute)
}
}
}
@@ -41,10 +41,10 @@ class IDEAndroidUIXmlProcessor(val module: Module) : AndroidUIXmlProcessor(modul
}
}
override fun parseLayout(files: List<PsiFile>): List<AndroidWidget> {
val widgets = arrayListOf<AndroidWidget>()
override fun parseLayout(files: List<PsiFile>): List<AndroidResource> {
val widgets = arrayListOf<AndroidResource>()
val visitor = AndroidXmlVisitor { id, widgetType, attribute ->
widgets.add(AndroidWidget(id, widgetType))
widgets.add(parseAndroidResource(id, widgetType))
}
files.forEach { it.accept(visitor) }