diff --git a/idea/idea-analysis/src/org/jetbrains/jet/plugin/caches/resolve/KotlinCacheService.kt b/idea/idea-analysis/src/org/jetbrains/jet/plugin/caches/resolve/KotlinCacheService.kt index afffc383ef4..142ae1e23eb 100644 --- a/idea/idea-analysis/src/org/jetbrains/jet/plugin/caches/resolve/KotlinCacheService.kt +++ b/idea/idea-analysis/src/org/jetbrains/jet/plugin/caches/resolve/KotlinCacheService.kt @@ -90,7 +90,9 @@ public class KotlinCacheService(val project: Project) { project, globalResolveSessionProvider(platform, logProcessCanceled = true, moduleFilter = { it.isLibraryClasses() }, - dependencies = listOf(ProjectRootModificationTracker.getInstance(project))) + dependencies = listOf( + LibraryModificationTracker.getInstance(project), + ProjectRootModificationTracker.getInstance(project))) ) val modulesCache = KotlinResolveCache( @@ -124,7 +126,10 @@ public class KotlinCacheService(val project: Project) { } else -> { if (syntheticFileModule.isLibraryClasses()) { - LOG.error("Creating cache with synthetic file ($file) in classes of library $syntheticFileModule") + //NOTE: this code should not be called for sdk or library classes + // currently the only known scenario is when we cannot determine that file is a library source + // (file under both classes and sources root) + LOG.warn("Creating cache with synthetic file ($file) in classes of library $syntheticFileModule") } KotlinResolveCache( project, diff --git a/idea/idea-analysis/src/org/jetbrains/jet/plugin/caches/resolve/LibraryModificationTracker.kt b/idea/idea-analysis/src/org/jetbrains/jet/plugin/caches/resolve/LibraryModificationTracker.kt new file mode 100644 index 00000000000..41ac99e4cbc --- /dev/null +++ b/idea/idea-analysis/src/org/jetbrains/jet/plugin/caches/resolve/LibraryModificationTracker.kt @@ -0,0 +1,55 @@ +/* + * Copyright 2010-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.plugin.caches.resolve + +import com.intellij.openapi.util.SimpleModificationTracker +import com.intellij.openapi.project.Project +import com.intellij.openapi.components.ServiceManager +import com.intellij.openapi.vfs.VirtualFileManager +import com.intellij.openapi.vfs.impl.BulkVirtualFileListenerAdapter +import com.intellij.openapi.vfs.VirtualFileAdapter +import com.intellij.openapi.vfs.VirtualFileEvent +import com.intellij.openapi.vfs.VirtualFileMoveEvent +import com.intellij.openapi.roots.ProjectFileIndex +import kotlin.platform.platformStatic + +class LibraryModificationTracker(project: Project) : SimpleModificationTracker() { + class object { + platformStatic fun getInstance(project: Project) = ServiceManager.getService(project, javaClass())!! + } + + { + val connection = project.getMessageBus().connect() + connection.subscribe(VirtualFileManager.VFS_CHANGES, BulkVirtualFileListenerAdapter( + object : VirtualFileAdapter() { + override fun fileCreated(event: VirtualFileEvent) = processEvent(event) + override fun beforeFileMovement(event: VirtualFileMoveEvent) = processEvent(event) + override fun beforeContentsChange(event: VirtualFileEvent) = processEvent(event) + override fun beforeFileDeletion(event: VirtualFileEvent) = processEvent(event) + } + )) + } + + val projectFileIndex = ProjectFileIndex.SERVICE.getInstance(project) + + fun processEvent(event: VirtualFileEvent) { + if (projectFileIndex.isInLibraryClasses(event.getFile())) { + incModificationCount() + } + } +} + diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml index f5e3a64515b..f1a091bd97f 100644 --- a/idea/src/META-INF/plugin.xml +++ b/idea/src/META-INF/plugin.xml @@ -166,6 +166,9 @@ + +