Excluding top-level members of library source files when analyzing them lazily

This commit is contained in:
Andrey Breslav
2014-04-10 17:28:38 +04:00
parent d4eb5e58c5
commit f58aca5ddf
@@ -37,6 +37,9 @@ import org.jetbrains.jet.lang.resolve.TopDownAnalysisParameters
import com.intellij.openapi.progress.ProcessCanceledException
import org.jetbrains.jet.lang.resolve.BindingTraceContext
import com.intellij.psi.util.CachedValueProvider
import org.jetbrains.jet.asJava.LightClassUtil
import com.intellij.openapi.roots.libraries.LibraryUtil
import org.jetbrains.jet.lang.resolve.LibrarySourceHacks
private val LOG = Logger.getInstance(javaClass<KotlinResolveCache>())
@@ -59,8 +62,18 @@ class KotlinResolveCache(
ApplicationUtils.warnTimeConsuming(LOG)
try {
for (element in task!!.elements) {
val file = element.getContainingFile() as JetFile
val virtualFile = file.getVirtualFile()
if (LightClassUtil.belongsToKotlinBuiltIns(file)
|| virtualFile != null && LibraryUtil.findLibraryEntry(virtualFile, file.getProject()) != null) {
// Library sources: mark file to skip
file.putUserData(LibrarySourceHacks.SKIP_TOP_LEVEL_MEMBERS, true)
}
}
// todo: look for pre-existing results for this element or its parents
val trace = DelegatingBindingTrace(resolveSession.getBindingContext(), "Trace for resolution of " + task!!.elements.makeString(", "))
val trace = DelegatingBindingTrace(resolveSession.getBindingContext(), "Trace for resolution of " + task.elements.makeString(", "))
val injector = InjectorForTopDownAnalyzerForJvm(
project,
SimpleGlobalContext(resolveSession.getStorageManager(), resolveSession.getExceptionTracker()),