Cache XML layout widgets using PsiTreeChangePreprocessor

This commit is contained in:
Yan Zhulanow
2015-02-27 20:46:54 +03:00
parent 3f53cf01d2
commit 6b368e445a
10 changed files with 111 additions and 66 deletions
@@ -14,8 +14,11 @@
<extensions defaultExtensionNs="com.intellij">
<moduleService serviceInterface="org.jetbrains.kotlin.lang.resolve.android.AndroidUIXmlProcessor"
serviceImplementation="org.jetbrains.kotlin.plugin.android.IDEAndroidUIXmlProcessor"/>
<moduleService serviceInterface="org.jetbrains.kotlin.lang.resolve.android.AndroidResourceManager"
serviceImplementation="org.jetbrains.kotlin.plugin.android.IDEAndroidResourceManager"/>
<compileServer.plugin classpath="jps/kotlin-android-extensions-jps.jar;android-compiler-plugin.jar"/>
<gotoDeclarationHandler implementation="org.jetbrains.kotlin.plugin.android.AndroidGotoDeclarationHandler"/>
<psi.treeChangePreprocessor implementation="org.jetbrains.kotlin.lang.resolve.android.AndroidPsiTreeChangePreprocessor"/>
<renamePsiElementProcessor id="KotlinAndroidSyntheticProperty"
implementation="org.jetbrains.kotlin.plugin.android.AndroidRenameProcessor"
order="first"/>
@@ -16,17 +16,23 @@
package org.jetbrains.kotlin.plugin.android
import com.intellij.openapi.components.ServiceManager
import com.intellij.openapi.module.Module
import org.jetbrains.kotlin.plugin.android.IDEAndroidResourceManager
import com.intellij.psi.PsiFile
import org.jetbrains.kotlin.plugin.android.AndroidXmlVisitor
import org.jetbrains.kotlin.lang.resolve.android.AndroidUIXmlProcessor
import org.jetbrains.kotlin.lang.resolve.android.AndroidWidget
import com.intellij.psi.impl.*
import kotlin.properties.*
import org.jetbrains.kotlin.lang.resolve.android.*
class IDEAndroidUIXmlProcessor(val module: Module) : AndroidUIXmlProcessor(module.getProject()) {
override val resourceManager: IDEAndroidResourceManager = IDEAndroidResourceManager(module)
override val psiTreeChangePreprocessor by Delegates.lazy {
module.getProject().getExtensions(PsiTreeChangePreprocessor.EP_NAME).first { it is AndroidPsiTreeChangePreprocessor }
}
override fun parseSingleFile(file: PsiFile): List<AndroidWidget> {
val widgets = arrayListOf<AndroidWidget>()
file.accept(AndroidXmlVisitor(resourceManager, { id, wClass, valueElement ->