KT-34582 Exclude kotlin.coroutines.experimental package from completion and auto-import

- Exclusion happens only when `ReleaseCoroutines` feature is supported
- Add `LANGUAGE_VERSION` to few tests to make sure that previous exclusions still work when `experimental` package is not excluded entirely
- ^KT-34582 Fixed
This commit is contained in:
Roman Golyshev
2019-12-24 17:08:00 +03:00
committed by Roman Golyshev
parent 8399614de8
commit 42deb7db48
7 changed files with 34 additions and 0 deletions
@@ -7,8 +7,10 @@ package org.jetbrains.kotlin.idea.core
import com.intellij.codeInsight.JavaProjectCodeInsightSettings
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.idea.imports.importableFqName
import org.jetbrains.kotlin.idea.project.languageVersionSettings
import org.jetbrains.kotlin.psi.KtFile
@@ -25,8 +27,19 @@ private val exclusions =
private fun shouldBeHiddenAsInternalImplementationDetail(fqName: String, locationFqName: String) =
exclusions.any { fqName.startsWith(it) } && (locationFqName.isBlank() || !fqName.startsWith(locationFqName))
/**
* We do not want to show nothing from "kotlin.coroutines.experimental" when release coroutines are available,
* since in 1.3 this package is obsolete.
*
* However, we still want to show this package when release coroutines are not available.
*/
private fun usesOutdatedCoroutinesPackage(fqName: String, inFile: KtFile): Boolean =
fqName.startsWith("kotlin.coroutines.experimental.") &&
inFile.languageVersionSettings.supportsFeature(LanguageFeature.ReleaseCoroutines)
fun DeclarationDescriptor.isExcludedFromAutoImport(project: Project, inFile: KtFile?): Boolean {
val fqName = importableFqName?.asString() ?: return false
return JavaProjectCodeInsightSettings.getSettings(project).isExcluded(fqName) ||
(inFile != null && usesOutdatedCoroutinesPackage(fqName, inFile)) ||
shouldBeHiddenAsInternalImplementationDetail(fqName, inFile?.packageFqName?.asString() ?: "")
}