172: Try to remove unneeded commits in 172 branch
Revert "[Unneeded?] Revert "ExpressionOfTypeProcessor: get member name in read action"" This reverts commit 7ec59fc Revert "[Unneeded] Revert "AbstractNavigateToLibraryTest: fix for invalid files"" This reverts commit 9e80c60 Revert "[Unneeded?] Revert "AbstractExtractionTest: fix for invalid files"" This reverts commit 0b2113b Revert "[Unneeded] Revert "AbstractIntentionTest: `isApplicableOnPooled` made run under ProgressIndicator"" This reverts commit a41c247
This commit is contained in:
+3
-2
@@ -335,10 +335,11 @@ class ExpressionsOfTypeProcessor(
|
|||||||
val searchRequestCollector = SearchRequestCollector(SearchSession())
|
val searchRequestCollector = SearchRequestCollector(SearchSession())
|
||||||
val resultProcessor = StaticMemberRequestResultProcessor(member, classes)
|
val resultProcessor = StaticMemberRequestResultProcessor(member, classes)
|
||||||
|
|
||||||
|
val memberName = runReadAction { member.name }
|
||||||
for (klass in classes) {
|
for (klass in classes) {
|
||||||
val request = klass.name + "." + declarationName
|
val request = klass.name + "." + declarationName
|
||||||
|
|
||||||
testLog { "Searched references to static ${member.name} in non-Java files by request $request" }
|
testLog { "Searched references to static $memberName in non-Java files by request $request" }
|
||||||
searchRequestCollector.searchWord(
|
searchRequestCollector.searchWord(
|
||||||
request,
|
request,
|
||||||
classUseScope(klass).intersectWith(memberScope), UsageSearchContext.IN_CODE, true, member, resultProcessor)
|
classUseScope(klass).intersectWith(memberScope), UsageSearchContext.IN_CODE, true, member, resultProcessor)
|
||||||
@@ -347,7 +348,7 @@ class ExpressionsOfTypeProcessor(
|
|||||||
if (qualifiedName != null) {
|
if (qualifiedName != null) {
|
||||||
val importAllUnderRequest = qualifiedName + ".*"
|
val importAllUnderRequest = qualifiedName + ".*"
|
||||||
|
|
||||||
testLog { "Searched references to static ${member.name} in non-Java files by request $importAllUnderRequest" }
|
testLog { "Searched references to static $memberName in non-Java files by request $importAllUnderRequest" }
|
||||||
searchRequestCollector.searchWord(
|
searchRequestCollector.searchWord(
|
||||||
importAllUnderRequest,
|
importAllUnderRequest,
|
||||||
classUseScope(klass).intersectWith(memberScope), UsageSearchContext.IN_CODE, true, member, resultProcessor)
|
classUseScope(klass).intersectWith(memberScope), UsageSearchContext.IN_CODE, true, member, resultProcessor)
|
||||||
|
|||||||
+1
-1
@@ -41,13 +41,13 @@ abstract class AbstractNavigateToLibraryTest : KotlinCodeInsightTestCase() {
|
|||||||
abstract val expectedFileExt: String
|
abstract val expectedFileExt: String
|
||||||
|
|
||||||
protected fun doTestEx(path: String, additionalConfig: (() -> Unit)? = null) {
|
protected fun doTestEx(path: String, additionalConfig: (() -> Unit)? = null) {
|
||||||
configureByFile(path)
|
|
||||||
module.configureAs(getProjectDescriptor())
|
module.configureAs(getProjectDescriptor())
|
||||||
|
|
||||||
if (additionalConfig != null) {
|
if (additionalConfig != null) {
|
||||||
additionalConfig()
|
additionalConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
configureByFile(path)
|
||||||
NavigationChecker.checkAnnotatedCode(file, File(path.replace(".kt", expectedFileExt)))
|
NavigationChecker.checkAnnotatedCode(file, File(path.replace(".kt", expectedFileExt)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,10 @@ package org.jetbrains.kotlin.idea.intentions
|
|||||||
import com.google.common.collect.Lists
|
import com.google.common.collect.Lists
|
||||||
import com.intellij.codeInsight.intention.IntentionAction
|
import com.intellij.codeInsight.intention.IntentionAction
|
||||||
import com.intellij.openapi.application.ApplicationManager
|
import com.intellij.openapi.application.ApplicationManager
|
||||||
|
import com.intellij.openapi.progress.ProgressIndicator
|
||||||
|
import com.intellij.openapi.progress.ProgressManager
|
||||||
|
import com.intellij.openapi.progress.Task
|
||||||
|
import com.intellij.openapi.progress.util.ProgressIndicatorBase
|
||||||
import com.intellij.openapi.util.Computable
|
import com.intellij.openapi.util.Computable
|
||||||
import com.intellij.openapi.util.SystemInfo
|
import com.intellij.openapi.util.SystemInfo
|
||||||
import com.intellij.openapi.util.io.FileUtil
|
import com.intellij.openapi.util.io.FileUtil
|
||||||
@@ -39,6 +43,8 @@ import org.jetbrains.kotlin.test.KotlinTestUtils
|
|||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import java.util.concurrent.CompletableFuture
|
||||||
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
abstract class AbstractIntentionTest : KotlinLightCodeInsightFixtureTestCase() {
|
abstract class AbstractIntentionTest : KotlinLightCodeInsightFixtureTestCase() {
|
||||||
protected open fun intentionFileName(): String = ".intention"
|
protected open fun intentionFileName(): String = ".intention"
|
||||||
@@ -124,12 +130,29 @@ abstract class AbstractIntentionTest : KotlinLightCodeInsightFixtureTestCase() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun <T> computeUnderProgressIndicatorAndWait(compute: () -> T): T {
|
||||||
|
val result = CompletableFuture<T>()
|
||||||
|
val progressIndicator = ProgressIndicatorBase()
|
||||||
|
try {
|
||||||
|
val task = object : Task.Backgroundable(project, "isApplicable", false) {
|
||||||
|
override fun run(indicator: ProgressIndicator) {
|
||||||
|
result.complete(compute())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ProgressManager.getInstance().runProcessWithProgressAsynchronously(task, progressIndicator)
|
||||||
|
return result.get(10, TimeUnit.SECONDS)
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
progressIndicator.cancel()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
private fun doTestFor(mainFilePath: String, pathToFiles: Map<String, PsiFile>, intentionAction: IntentionAction, fileText: String) {
|
private fun doTestFor(mainFilePath: String, pathToFiles: Map<String, PsiFile>, intentionAction: IntentionAction, fileText: String) {
|
||||||
val isApplicableString = InTextDirectivesUtils.findStringWithPrefixes(fileText, "// ${isApplicableDirectiveName()}: ")
|
val isApplicableString = InTextDirectivesUtils.findStringWithPrefixes(fileText, "// ${isApplicableDirectiveName()}: ")
|
||||||
val isApplicableExpected = isApplicableString == null || isApplicableString == "true"
|
val isApplicableExpected = isApplicableString == null || isApplicableString == "true"
|
||||||
|
|
||||||
val isApplicableOnPooled = ApplicationManager.getApplication().executeOnPooledThread(java.util.concurrent.Callable { ApplicationManager.getApplication().runReadAction(Computable { intentionAction.isAvailable(project, editor, file) }) }).get()
|
val isApplicableOnPooled = computeUnderProgressIndicatorAndWait { ApplicationManager.getApplication().runReadAction(Computable { intentionAction.isAvailable(project, editor, file) }) }
|
||||||
|
|
||||||
val isApplicableOnEdt = intentionAction.isAvailable(project, editor, file)
|
val isApplicableOnEdt = intentionAction.isAvailable(project, editor, file)
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -341,15 +341,15 @@ abstract class AbstractExtractionTest : KotlinLightCodeInsightFixtureTestCase()
|
|||||||
name != mainFileName && name.startsWith("$mainFileBaseName.") && (name.endsWith(".kt") || name.endsWith(".java"))
|
name != mainFileName && name.startsWith("$mainFileBaseName.") && (name.endsWith(".kt") || name.endsWith(".java"))
|
||||||
}
|
}
|
||||||
val extraFilesToPsi = extraFiles.associateBy { fixture.configureByFile(it.name) }
|
val extraFilesToPsi = extraFiles.associateBy { fixture.configureByFile(it.name) }
|
||||||
val file = fixture.configureByFile(mainFileName)
|
val fileText = FileUtil.loadFile(File(path), true)
|
||||||
|
|
||||||
val addKotlinRuntime = InTextDirectivesUtils.findStringWithPrefixes(file.text, "// WITH_RUNTIME") != null
|
val addKotlinRuntime = InTextDirectivesUtils.findStringWithPrefixes(fileText, "// WITH_RUNTIME") != null
|
||||||
if (addKotlinRuntime) {
|
if (addKotlinRuntime) {
|
||||||
ConfigLibraryUtil.configureKotlinRuntimeAndSdk(myModule, PluginTestCaseBase.mockJdk())
|
ConfigLibraryUtil.configureKotlinRuntimeAndSdk(myModule, PluginTestCaseBase.mockJdk())
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
checkExtract(ExtractTestFiles(path, file, extraFilesToPsi), checkAdditionalAfterdata, action)
|
checkExtract(ExtractTestFiles(path, fixture.configureByFile(mainFileName), extraFilesToPsi), checkAdditionalAfterdata, action)
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
if (addKotlinRuntime) {
|
if (addKotlinRuntime) {
|
||||||
|
|||||||
Reference in New Issue
Block a user