fix xml resolving

- replace VirtualFileListener based approach with direct PsiFile reading
This commit is contained in:
Mikhail Mutcianko
2014-07-25 15:22:52 +04:00
committed by Yan Zhulanow
parent 35b1cb4fc7
commit c24fccc659
3 changed files with 33 additions and 38 deletions
@@ -23,34 +23,14 @@ import java.util.ArrayList
import com.intellij.openapi.vfs.VirtualFileAdapter
import com.intellij.openapi.vfs.VirtualFileEvent
class IDEAndroidUIXmlParser(project: Project): AndroidUIXmlParser() {
class IDEAndroidUIXmlParser(val project: Project): AndroidUIXmlParser() {
override val searchPath: String? = project.getBasePath() + "/res/layout/"
override var androidAppPackage: String = ""
override protected fun lazySetup() {
if (listenerSetUp) return
androidAppPackage = readManifest()._package
val fileManager = VirtualFileManager.getInstance()
val watchDir = fileManager.findFileByUrl("file://" + searchPath)
filesToProcess.addAll(watchDir?.getChildren()?.toArrayList() ?: ArrayList(0))
fileManager.addVirtualFileListener(object : VirtualFileAdapter() {
override fun contentsChanged(event: VirtualFileEvent) {
if (event.getParent() == watchDir)
filesToProcess.add(event.getFile())
}
override fun fileCreated(event: VirtualFileEvent) {
if (event.getParent() == watchDir)
super<VirtualFileAdapter>.fileCreated(event)
}
override fun fileDeleted(event: VirtualFileEvent) {
if (event.getParent() == watchDir) {
// ignore potential synchronisation issues - it doesn't really matter if invalidation and
// file processing will be handled in different passes
invalidateCaches = true
filesToProcess.addAll(watchDir?.getChildren()?.toArrayList() ?: ArrayList(0))
}
}
})
populateQueue(project)
listenerSetUp = true
}
}