Disable completion binding context caching by default
Now it opt-in in internal mode, due duplication problems #KT-19191 fixed
This commit is contained in:
+11
@@ -58,6 +58,8 @@ class CompletionBindingContextProvider(project: Project) {
|
|||||||
companion object {
|
companion object {
|
||||||
fun getInstance(project: Project): CompletionBindingContextProvider
|
fun getInstance(project: Project): CompletionBindingContextProvider
|
||||||
= project.getComponent(CompletionBindingContextProvider::class.java)
|
= project.getComponent(CompletionBindingContextProvider::class.java)
|
||||||
|
|
||||||
|
var ENABLED = false
|
||||||
}
|
}
|
||||||
|
|
||||||
private class CompletionData(
|
private class CompletionData(
|
||||||
@@ -86,6 +88,15 @@ class CompletionBindingContextProvider(project: Project) {
|
|||||||
|
|
||||||
|
|
||||||
fun getBindingContext(position: PsiElement, resolutionFacade: ResolutionFacade): BindingContext {
|
fun getBindingContext(position: PsiElement, resolutionFacade: ResolutionFacade): BindingContext {
|
||||||
|
return if (ENABLED) {
|
||||||
|
_getBindingContext(position, resolutionFacade)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
resolutionFacade.analyze(position.parentsWithSelf.firstIsInstance<KtElement>(), BodyResolveMode.PARTIAL_FOR_COMPLETION)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun _getBindingContext(position: PsiElement, resolutionFacade: ResolutionFacade): BindingContext {
|
||||||
assert(!position.isPhysical) // position is in synthetic file
|
assert(!position.isPhysical) // position is in synthetic file
|
||||||
|
|
||||||
val inStatement = position.findStatementInBlock()
|
val inStatement = position.findStatementInBlock()
|
||||||
|
|||||||
+5
@@ -37,6 +37,8 @@ abstract class AbstractCompletionIncrementalResolveTest : KotlinLightCodeInsight
|
|||||||
override fun getProjectDescriptor() = KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE
|
override fun getProjectDescriptor() = KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE
|
||||||
|
|
||||||
protected fun doTest(testPath: String) {
|
protected fun doTest(testPath: String) {
|
||||||
|
CompletionBindingContextProvider.ENABLED = true
|
||||||
|
try {
|
||||||
val file = File(testPath)
|
val file = File(testPath)
|
||||||
val hasCaretMarker = FileUtil.loadFile(file, true).contains("<caret>")
|
val hasCaretMarker = FileUtil.loadFile(file, true).contains("<caret>")
|
||||||
myFixture.configureByFile(testPath)
|
myFixture.configureByFile(testPath)
|
||||||
@@ -96,5 +98,8 @@ abstract class AbstractCompletionIncrementalResolveTest : KotlinLightCodeInsight
|
|||||||
additionalValidDirectives = listOf(TYPE_DIRECTIVE_PREFIX, BACKSPACES_DIRECTIVE_PREFIX))
|
additionalValidDirectives = listOf(TYPE_DIRECTIVE_PREFIX, BACKSPACES_DIRECTIVE_PREFIX))
|
||||||
|
|
||||||
KotlinTestUtils.assertEqualsToFile(File(file.parent, file.nameWithoutExtension + ".log"), testLog.toString())
|
KotlinTestUtils.assertEqualsToFile(File(file.parent, file.nameWithoutExtension + ".log"), testLog.toString())
|
||||||
|
} finally {
|
||||||
|
CompletionBindingContextProvider.ENABLED = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -146,6 +146,10 @@
|
|||||||
text="Local scenario"/>
|
text="Local scenario"/>
|
||||||
</group>
|
</group>
|
||||||
|
|
||||||
|
<action id="CompletionBindingContextCachingToggleAction"
|
||||||
|
class="org.jetbrains.kotlin.idea.actions.internal.CompletionBindingContextCachingToggleAction"
|
||||||
|
text="Enable completion binding context caching"/>
|
||||||
|
|
||||||
<action id="CheckComponentsUsageSearchAction" class="org.jetbrains.kotlin.idea.actions.internal.CheckComponentsUsageSearchAction"
|
<action id="CheckComponentsUsageSearchAction" class="org.jetbrains.kotlin.idea.actions.internal.CheckComponentsUsageSearchAction"
|
||||||
text="Check Component Functions Usage Search"/>
|
text="Check Component Functions Usage Search"/>
|
||||||
|
|
||||||
|
|||||||
+35
@@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2017 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.kotlin.idea.actions.internal
|
||||||
|
|
||||||
|
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||||
|
import com.intellij.openapi.actionSystem.ToggleAction
|
||||||
|
import org.jetbrains.kotlin.idea.completion.CompletionBindingContextProvider
|
||||||
|
|
||||||
|
class CompletionBindingContextCachingToggleAction : ToggleAction() {
|
||||||
|
override fun isSelected(e: AnActionEvent?): Boolean =
|
||||||
|
CompletionBindingContextProvider.ENABLED
|
||||||
|
|
||||||
|
|
||||||
|
override fun setSelected(e: AnActionEvent?, state: Boolean) {
|
||||||
|
CompletionBindingContextProvider.ENABLED = state
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun update(e: AnActionEvent) {
|
||||||
|
e.presentation.isEnabledAndVisible = KotlinInternalMode.enabled
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user