KT-11308 Hide kotlin.jvm.internal package contents from completion and auto-import

#KT-11308 fixed
This commit is contained in:
Simon Ogorodnik
2017-01-17 22:58:05 +03:00
parent 5c52bdc684
commit 4ca10c61fd
9 changed files with 90 additions and 9 deletions
@@ -16,7 +16,6 @@
package org.jetbrains.kotlin.idea.core
import com.intellij.codeInsight.JavaProjectCodeInsightSettings
import com.intellij.openapi.progress.ProgressManager
import com.intellij.psi.PsiFile
import com.intellij.psi.PsiMember
@@ -32,7 +31,6 @@ import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.idea.caches.KotlinShortNamesCache
import org.jetbrains.kotlin.idea.caches.resolve.*
import org.jetbrains.kotlin.idea.core.extension.KotlinIndicesHelperExtension
import org.jetbrains.kotlin.idea.imports.importableFqName
import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
import org.jetbrains.kotlin.idea.resolve.frontendService
import org.jetbrains.kotlin.idea.search.excludeKotlinSources
@@ -73,7 +71,7 @@ class KotlinIndicesHelper(
private val descriptorFilter: (DeclarationDescriptor) -> Boolean = filter@ {
if (it.isHiddenInResolution(resolutionFacade.frontendService<LanguageVersionSettings>())) return@filter false
if (!visibilityFilter(it)) return@filter false
if (applyExcludeSettings && isExcludedFromAutoImport(it)) return@filter false
if (applyExcludeSettings && it.isExcludedFromAutoImport(project)) return@filter false
true
}
@@ -429,11 +427,6 @@ class KotlinIndicesHelper(
}
}
private fun isExcludedFromAutoImport(descriptor: DeclarationDescriptor): Boolean {
val fqName = descriptor.importableFqName?.asString() ?: return false
return JavaProjectCodeInsightSettings.getSettings(project).isExcluded(fqName)
}
private inline fun <reified TDescriptor : Any> KtNamedDeclaration.resolveToDescriptors(): Collection<TDescriptor> {
return resolveToDescriptorsWithHack({ true }).filterIsInstance<TDescriptor>()
}
@@ -0,0 +1,37 @@
/*
* 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.core
import com.intellij.codeInsight.JavaProjectCodeInsightSettings
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.idea.imports.importableFqName
private val exclusions =
listOf(
"kotlin.jvm.internal",
"kotlin.coroutines.intrinsics"
)
private fun shouldBeHiddenAsInternalImplementationDetail(fqName: String) = exclusions.any { fqName.startsWith(it) }
fun DeclarationDescriptor.isExcludedFromAutoImport(project: Project): Boolean {
val fqName = importableFqName?.asString() ?: return false
return JavaProjectCodeInsightSettings.getSettings(project).isExcluded(fqName) ||
shouldBeHiddenAsInternalImplementationDetail(fqName)
}