Add registry key kotlin.resolve.forceFullResolveOnHighlighting
Relates to ^KT-41195 Relates to ^KT-38687
This commit is contained in:
committed by
Vladimir Dolzhenko
parent
50a16aa9bc
commit
ce1b388668
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.idea.project
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.roots.ProjectRootModificationTracker
|
||||
import com.intellij.openapi.util.registry.Registry
|
||||
import com.intellij.psi.util.CachedValue
|
||||
import com.intellij.psi.util.CachedValueProvider
|
||||
import com.intellij.psi.util.CachedValuesManager
|
||||
@@ -22,6 +23,7 @@ import org.jetbrains.kotlin.context.withProject
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.frontend.di.createContainerForBodyResolve
|
||||
import org.jetbrains.kotlin.idea.DaemonCodeAnalyzerStatusService
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.CodeFragmentAnalyzer
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.util.analyzeControlFlow
|
||||
import org.jetbrains.kotlin.idea.caches.trackers.KotlinCodeBlockModificationListener
|
||||
@@ -50,6 +52,8 @@ class ResolveElementCache(
|
||||
private val codeFragmentAnalyzer: CodeFragmentAnalyzer
|
||||
) : BodyResolveCache {
|
||||
|
||||
private val forcedFullResolveOnHighlighting = Registry.`is`("kotlin.resolve.force.full.resolve.on.highlighting", true)
|
||||
|
||||
private class CachedFullResolve(val bindingContext: BindingContext, resolveElement: KtElement) {
|
||||
private val modificationStamp: Long? = modificationStamp(resolveElement)
|
||||
|
||||
@@ -162,7 +166,11 @@ class ResolveElementCache(
|
||||
// neither result of PARTIAL nor result of PARTIAL_WITH_CFA analyses could be reused by FULL analysis.
|
||||
//
|
||||
// Force perform FULL analysis to avoid redundant analysis for the current selected files.
|
||||
if (bodyResolveMode != BodyResolveMode.FULL && bodyResolveMode != BodyResolveMode.PARTIAL_FOR_COMPLETION && (!isUnitTestMode() || forceFullAnalysisModeInTests)) {
|
||||
if (bodyResolveMode != BodyResolveMode.FULL &&
|
||||
bodyResolveMode != BodyResolveMode.PARTIAL_FOR_COMPLETION &&
|
||||
(!isUnitTestMode() || forceFullAnalysisModeInTests) &&
|
||||
forcedFullResolveOnHighlighting && DaemonCodeAnalyzerStatusService.getInstance(project).daemonRunning
|
||||
) {
|
||||
val virtualFile = resolveElement.containingFile.virtualFile
|
||||
// applicable for real (physical) files only
|
||||
if (virtualFile != null && FileEditorManager.getInstance(resolveElement.project).selectedFiles.any { it == virtualFile }) {
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea
|
||||
|
||||
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.fileEditor.FileEditor
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.idea.util.application.getServiceSafe
|
||||
|
||||
class DaemonCodeAnalyzerStatusService(project: Project) : Disposable {
|
||||
companion object {
|
||||
fun getInstance(project: Project): DaemonCodeAnalyzerStatusService = project.getServiceSafe()
|
||||
}
|
||||
|
||||
@Volatile
|
||||
var daemonRunning: Boolean = false
|
||||
private set
|
||||
|
||||
init {
|
||||
val messageBusConnection = project.messageBus.connect(this)
|
||||
messageBusConnection.subscribe(DaemonCodeAnalyzer.DAEMON_EVENT_TOPIC, object : DaemonCodeAnalyzer.DaemonListener {
|
||||
override fun daemonStarting(fileEditors: MutableCollection<FileEditor>) {
|
||||
daemonRunning = true
|
||||
}
|
||||
|
||||
override fun daemonFinished(fileEditors: MutableCollection<FileEditor>) {
|
||||
daemonRunning = false
|
||||
}
|
||||
|
||||
override fun daemonCancelEventOccurred(reason: String) {
|
||||
daemonRunning = false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun dispose() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea
|
||||
|
||||
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.fileEditor.FileEditor
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.idea.util.application.getServiceSafe
|
||||
|
||||
class DaemonCodeAnalyzerStatusService(project: Project) : Disposable {
|
||||
companion object {
|
||||
fun getInstance(project: Project): DaemonCodeAnalyzerStatusService = project.getServiceSafe()
|
||||
}
|
||||
|
||||
@Volatile
|
||||
var daemonRunning: Boolean = false
|
||||
private set
|
||||
|
||||
init {
|
||||
val messageBusConnection = project.messageBus.connect(this)
|
||||
messageBusConnection.subscribe(DaemonCodeAnalyzer.DAEMON_EVENT_TOPIC, object : DaemonCodeAnalyzer.DaemonListener {
|
||||
override fun daemonStarting(fileEditors: MutableCollection<out FileEditor>) {
|
||||
daemonRunning = true
|
||||
}
|
||||
|
||||
override fun daemonFinished(fileEditors: MutableCollection<out FileEditor>) {
|
||||
daemonRunning = false
|
||||
}
|
||||
|
||||
override fun daemonCancelEventOccurred(reason: String) {
|
||||
daemonRunning = false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun dispose() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -179,6 +179,8 @@
|
||||
<projectService serviceInterface="org.jetbrains.kotlin.idea.caches.resolve.ResolutionAnchorCacheService"
|
||||
serviceImplementation="org.jetbrains.kotlin.idea.caches.resolve.ResolutionAnchorCacheServiceImpl"/>
|
||||
|
||||
<projectService serviceImplementation="org.jetbrains.kotlin.idea.DaemonCodeAnalyzerStatusService"/>
|
||||
|
||||
<projectService serviceInterface="org.jetbrains.kotlin.resolve.ResolutionAnchorProvider"
|
||||
serviceImplementation="org.jetbrains.kotlin.idea.caches.resolve.KotlinIdeResolutionAnchorService"/>
|
||||
|
||||
@@ -292,11 +294,15 @@
|
||||
|
||||
<errorHandler implementation="org.jetbrains.kotlin.idea.reporter.KotlinReportSubmitter"/>
|
||||
|
||||
<registryKey
|
||||
key="kotlin.dispatch.thread.resolve.check"
|
||||
description="Whether to enable the check for resolve activated from the write action"
|
||||
defaultValue="false"
|
||||
restartRequired="false"/>
|
||||
<registryKey key="kotlin.dispatch.thread.resolve.check"
|
||||
description="Whether to enable the check for resolve activated from the write action"
|
||||
defaultValue="false"
|
||||
restartRequired="false"/>
|
||||
|
||||
<registryKey key="kotlin.resolve.force.full.resolve.on.highlighting"
|
||||
description="Force to perform full resolve on highlighting"
|
||||
defaultValue="true"
|
||||
restartRequired="false"/>
|
||||
|
||||
<iconProvider implementation="org.jetbrains.kotlin.idea.KotlinIconProvider"/>
|
||||
<gotoSymbolContributor implementation="org.jetbrains.kotlin.idea.goto.KotlinGotoSymbolContributor"/>
|
||||
|
||||
Reference in New Issue
Block a user