[kotlin] Add intention to show/hide Kotlin inlay hints

#KTIJ-214 Fixed

GitOrigin-RevId: 2b6ce81d05664f6587d3491fa3ce1b58393203c6
This commit is contained in:
Vladimir Dolzhenko
2022-05-07 18:05:56 +00:00
committed by intellij-monorepo-bot
parent 360a5e7f69
commit 1a3d9b66e8
471 changed files with 932 additions and 221 deletions
@@ -7,6 +7,7 @@ import com.intellij.psi.PsiFile
import org.jetbrains.kotlin.idea.quickfix.AbstractQuickFixMultiFileTest
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.test.utils.IgnoreTests
import java.io.File
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
@@ -26,7 +27,7 @@ abstract class AbstractHighLevelQuickFixMultiFileTest : AbstractQuickFixMultiFil
override fun checkForUnexpectedErrors(file: KtFile) {}
override fun checkAvailableActionsAreExpected(file: PsiFile, actions: Collection<IntentionAction>) {}
override fun checkAvailableActionsAreExpected(file: File, actions: Collection<IntentionAction>) {}
private fun Path.getAfterFileIfExists(): Path? {
val afterFileName = fileName.toString().removeSuffix(".before.Main.kt") + ".after.kt"
@@ -455,6 +455,25 @@ hints.settings.types.return=Function return types
hints.settings.types.parameter=Function parameter types
hints.settings.values.ranges=Ranges
hints.settings.show.types.property=Show property type hints
hints.settings.dont.show.types.property=Do not show property type hints
hints.settings.show.types.variable=Show local variable type hints
hints.settings.dont.show.types.variable=Do not show local variable type hints
hints.settings.show.types.return=Show function return type hints
hints.title.show.argument.name.enabled=Show argument name hints
hints.title.dont.show.argument.name.enabled=Do not show argument name hints
hints.settings.dont.show.types.return=Do not show function return type hints
hints.settings.show.types.parameter=Show function parameter type hints
hints.settings.dont.show.types.parameter=Do not show function parameter type hints
hints.settings.show.lambda.return=Show return expression hints
hints.settings.dont.show.lambda.return=Do not show return expression hints
hints.settings.show.lambda.receivers.parameters=Show implicit receiver and parameter hints
hints.settings.dont.show.lambda.receivers.parameters=Do not show implicit receiver and parameter hints
hints.settings.show.suspending=Show suspending call hints
hints.settings.dont.show.suspending=Do not show suspending call hints
hints.settings.show.ranges=Show range hints
hints.settings.dont.show.ranges=Do not show range hints
hints.settings.lambdas=Lambdas
hints.settings.lambda.return=Return expressions
hints.settings.lambda.receivers.parameters=Implicit receivers and parameters
@@ -0,0 +1,79 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.kotlin.idea.codeInsight.hints
import com.intellij.codeInsight.CodeInsightBundle
import com.intellij.codeInsight.hints.*
import com.intellij.codeInsight.intention.HighPriorityAction
import com.intellij.codeInsight.intention.IntentionAction
import com.intellij.codeInspection.util.IntentionName
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiFile
import com.intellij.psi.util.PsiTreeUtil
import org.jetbrains.kotlin.idea.KotlinLanguage
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
@Suppress("IntentionDescriptionNotFoundInspection")
class EnableKotlinTypeHintsOption : IntentionAction, HighPriorityAction {
@IntentionName
private var lastOptionName = ""
override fun getText(): String = lastOptionName
override fun getFamilyName(): String = CodeInsightBundle.message("inlay.hints.intention.family.name")
override fun isAvailable(project: Project, editor: Editor, file: PsiFile): Boolean {
val element = findElement(editor, file) ?: return false
lastOptionName = ""
for (hintType in HintType.values()) {
findSetting(hintType, project, element)?.let {
val enabled = it.isEnabled(hintType)
lastOptionName = if (enabled) hintType.hideDescription else hintType.showDescription
return true
}
}
return false
}
override fun invoke(project: Project, editor: Editor, file: PsiFile) {
val element = findElement(editor, file) ?: return
for (hintType in HintType.values()) {
findSetting(hintType, project, element)?.let {
val enabled = it.isEnabled(hintType)
it.enable(hintType, !enabled)
InlayHintsPassFactory.forceHintsUpdateOnNextPass()
return
}
}
}
override fun startInWriteAction(): Boolean = false
private fun findElement(editor: Editor, file: PsiFile): PsiElement? {
if (file !is KtFile) return null
val offset = editor.caretModel.offset
val leaf1 = file.findElementAt(offset)
val leaf2 = file.findElementAt(offset - 1)
return if (leaf1 != null && leaf2 != null) PsiTreeUtil.findCommonParent(leaf1, leaf2) else null
}
private fun findSetting(hintType: HintType, project: Project, element: PsiElement): KotlinAbstractHintsProvider.HintsSettings? {
if (!hintType.isApplicable(element)) return null
val hintsSettings = InlayHintsSettings.instance()
val providerInfos = InlayHintsProviderFactory.EP.extensionList
.flatMap { it.getProvidersInfo(project) }
.filter { it.language == KotlinLanguage.INSTANCE }
val provider = providerInfos
.firstOrNull {
val hintsProvider = it.provider as? KotlinAbstractHintsProvider ?: return@firstOrNull false
hintsProvider.isHintSupported(hintType)
}
?.provider?.safeAs<KotlinAbstractHintsProvider<KotlinAbstractHintsProvider.HintsSettings>>() ?: return null
val settingsKey = provider.key
return hintsSettings.findSettings(settingsKey, KotlinLanguage.INSTANCE, provider::createSettings)
}
}
@@ -4,7 +4,7 @@ package org.jetbrains.kotlin.idea.codeInsight.hints
import com.intellij.codeInsight.hints.InlayInfo
import com.intellij.codeInsight.hints.Option
import com.intellij.openapi.application.ApplicationManager
import com.intellij.codeInspection.util.IntentionName
import com.intellij.psi.PsiElement
import org.jetbrains.annotations.Nls
import org.jetbrains.kotlin.idea.KotlinBundle
@@ -20,39 +20,50 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
@Suppress("UnstableApiUsage")
enum class HintType(@Nls private val showDesc: String, defaultEnabled: Boolean) {
enum class HintType(
@Nls private val description: String,
@Nls @IntentionName val showDescription: String,
@Nls @IntentionName val hideDescription: String,
defaultEnabled: Boolean
) {
PROPERTY_HINT(
KotlinBundle.message("hints.settings.types.property"),
KotlinBundle.message("hints.settings.show.types.property"),
KotlinBundle.message("hints.settings.dont.show.types.property"),
false
) {
override fun provideHintDetails(elem: PsiElement): List<InlayInfoDetails> {
return providePropertyTypeHint(elem)
override fun provideHintDetails(e: PsiElement): List<InlayInfoDetails> {
return providePropertyTypeHint(e)
}
override fun isApplicable(elem: PsiElement): Boolean = elem is KtProperty && elem.getReturnTypeReference() == null && !elem.isLocal
override fun isApplicable(e: PsiElement): Boolean = e is KtProperty && e.getReturnTypeReference() == null && !e.isLocal
},
LOCAL_VARIABLE_HINT(
KotlinBundle.message("hints.settings.types.variable"),
KotlinBundle.message("hints.settings.show.types.variable"),
KotlinBundle.message("hints.settings.dont.show.types.variable"),
false
) {
override fun provideHintDetails(elem: PsiElement): List<InlayInfoDetails> {
return providePropertyTypeHint(elem)
override fun provideHintDetails(e: PsiElement): List<InlayInfoDetails> {
return providePropertyTypeHint(e)
}
override fun isApplicable(elem: PsiElement): Boolean =
(elem is KtProperty && elem.getReturnTypeReference() == null && elem.isLocal) ||
(elem is KtParameter && elem.isLoopParameter && elem.typeReference == null) ||
(elem is KtDestructuringDeclarationEntry && elem.getReturnTypeReference() == null)
override fun isApplicable(e: PsiElement): Boolean =
(e is KtProperty && e.getReturnTypeReference() == null && e.isLocal) ||
(e is KtParameter && e.isLoopParameter && e.typeReference == null) ||
(e is KtDestructuringDeclarationEntry && e.getReturnTypeReference() == null)
},
FUNCTION_HINT(
KotlinBundle.message("hints.settings.types.return"),
KotlinBundle.message("hints.settings.show.types.return"),
KotlinBundle.message("hints.settings.dont.show.types.return"),
false
) {
override fun provideHintDetails(elem: PsiElement): List<InlayInfoDetails> {
(elem as? KtNamedFunction)?.let { namedFunc ->
override fun provideHintDetails(e: PsiElement): List<InlayInfoDetails> {
(e as? KtNamedFunction)?.let { namedFunc ->
namedFunc.valueParameterList?.let { paramList ->
provideTypeHint(namedFunc, paramList.endOffset)?.let { return listOf(it) }
}
@@ -60,16 +71,18 @@ enum class HintType(@Nls private val showDesc: String, defaultEnabled: Boolean)
return emptyList()
}
override fun isApplicable(elem: PsiElement): Boolean =
elem is KtNamedFunction && !(elem.hasBlockBody() || elem.hasDeclaredReturnType())
override fun isApplicable(e: PsiElement): Boolean =
e is KtNamedFunction && !(e.hasBlockBody() || e.hasDeclaredReturnType())
},
PARAMETER_TYPE_HINT(
KotlinBundle.message("hints.settings.types.parameter"),
KotlinBundle.message("hints.settings.show.types.parameter"),
KotlinBundle.message("hints.settings.dont.show.types.parameter"),
false
) {
override fun provideHintDetails(elem: PsiElement): List<InlayInfoDetails> {
(elem as? KtParameter)?.let { param ->
override fun provideHintDetails(e: PsiElement): List<InlayInfoDetails> {
(e as? KtParameter)?.let { param ->
param.nameIdentifier?.let { ident ->
provideTypeHint(param, ident.endOffset)?.let { return listOf(it) }
}
@@ -77,30 +90,34 @@ enum class HintType(@Nls private val showDesc: String, defaultEnabled: Boolean)
return emptyList()
}
override fun isApplicable(elem: PsiElement): Boolean = elem is KtParameter && elem.typeReference == null && !elem.isLoopParameter
override fun isApplicable(e: PsiElement): Boolean = e is KtParameter && e.typeReference == null && !e.isLoopParameter
},
PARAMETER_HINT(
KotlinBundle.message("hints.title.argument.name.enabled"),
KotlinBundle.message("hints.title.show.argument.name.enabled"),
KotlinBundle.message("hints.title.dont.show.argument.name.enabled"),
true
) {
override fun provideHints(elem: PsiElement): List<InlayInfo> {
val callElement = elem.getStrictParentOfType<KtCallElement>() ?: return emptyList()
override fun provideHints(e: PsiElement): List<InlayInfo> {
val callElement = e.getStrictParentOfType<KtCallElement>() ?: return emptyList()
return provideArgumentNameHints(callElement)
}
override fun isApplicable(elem: PsiElement): Boolean = elem is KtValueArgumentList
override fun isApplicable(e: PsiElement): Boolean = e is KtValueArgumentList
},
LAMBDA_RETURN_EXPRESSION(
KotlinBundle.message("hints.settings.lambda.return"),
KotlinBundle.message("hints.settings.show.lambda.return"),
KotlinBundle.message("hints.settings.dont.show.lambda.return"),
true
) {
override fun isApplicable(elem: PsiElement) =
elem is KtExpression && elem !is KtFunctionLiteral && !elem.isNameReferenceInCall()
override fun isApplicable(e: PsiElement) =
e is KtExpression && e !is KtFunctionLiteral && !e.isNameReferenceInCall()
override fun provideHintDetails(elem: PsiElement): List<InlayInfoDetails> {
elem.safeAs<KtExpression>()?.let { expression ->
override fun provideHintDetails(e: PsiElement): List<InlayInfoDetails> {
e.safeAs<KtExpression>()?.let { expression ->
provideLambdaReturnValueHints(expression)?.let { return listOf(it) }
}
return emptyList()
@@ -109,12 +126,14 @@ enum class HintType(@Nls private val showDesc: String, defaultEnabled: Boolean)
LAMBDA_IMPLICIT_PARAMETER_RECEIVER(
KotlinBundle.message("hints.settings.lambda.receivers.parameters"),
KotlinBundle.message("hints.settings.show.lambda.receivers.parameters"),
KotlinBundle.message("hints.settings.dont.show.lambda.receivers.parameters"),
true
) {
override fun isApplicable(elem: PsiElement) = elem is KtFunctionLiteral
override fun isApplicable(e: PsiElement) = e is KtFunctionLiteral
override fun provideHintDetails(elem: PsiElement): List<InlayInfoDetails> {
elem.safeAs<KtFunctionLiteral>()?.parent.safeAs<KtLambdaExpression>()?.let { expression ->
override fun provideHintDetails(e: PsiElement): List<InlayInfoDetails> {
e.safeAs<KtFunctionLiteral>()?.parent.safeAs<KtLambdaExpression>()?.let { expression ->
provideLambdaImplicitHints(expression)?.let { return it }
}
return emptyList()
@@ -123,24 +142,28 @@ enum class HintType(@Nls private val showDesc: String, defaultEnabled: Boolean)
SUSPENDING_CALL(
KotlinBundle.message("hints.settings.suspending"),
KotlinBundle.message("hints.settings.show.suspending"),
KotlinBundle.message("hints.settings.dont.show.suspending"),
false
) {
override fun isApplicable(elem: PsiElement) = elem.isNameReferenceInCall() && isApplicationInternalMode()
override fun isApplicable(e: PsiElement) = e.isNameReferenceInCall() && isApplicationInternalMode()
override fun provideHints(elem: PsiElement): List<InlayInfo> {
val callExpression = elem.parent as? KtCallExpression ?: return emptyList()
override fun provideHints(e: PsiElement): List<InlayInfo> {
val callExpression = e.parent as? KtCallExpression ?: return emptyList()
return provideSuspendingCallHint(callExpression)?.let { listOf(it) } ?: emptyList()
}
},
RANGES(
KotlinBundle.message("hints.settings.ranges"),
KotlinBundle.message("hints.settings.show.ranges"),
KotlinBundle.message("hints.settings.dont.show.ranges"),
true
) {
override fun isApplicable(elem: PsiElement): Boolean = elem is KtBinaryExpression && elem.isRangeExpression()
override fun isApplicable(e: PsiElement): Boolean = e is KtBinaryExpression && e.isRangeExpression()
override fun provideHintDetails(elem: PsiElement): List<InlayInfoDetails> {
val binaryExpression = elem.safeAs<KtBinaryExpression>() ?: return emptyList()
override fun provideHintDetails(e: PsiElement): List<InlayInfoDetails> {
val binaryExpression = e.safeAs<KtBinaryExpression>() ?: return emptyList()
val leftExp = binaryExpression.left ?: return emptyList()
val rightExp = binaryExpression.right ?: return emptyList()
@@ -167,20 +190,20 @@ enum class HintType(@Nls private val showDesc: String, defaultEnabled: Boolean)
};
companion object {
fun resolve(elem: PsiElement): List<HintType> =
values().filter { it.isApplicable(elem) }
fun resolve(e: PsiElement): List<HintType> =
values().filter { it.isApplicable(e) }
fun resolveToEnabled(elem: PsiElement?): HintType? =
elem?.let { resolve(it) }?.firstOrNull { it.enabled }
fun resolveToEnabled(e: PsiElement?): HintType? =
e?.let { resolve(it) }?.firstOrNull { it.enabled }
}
abstract fun isApplicable(elem: PsiElement): Boolean
open fun provideHints(elem: PsiElement): List<InlayInfo> = emptyList()
open fun provideHintDetails(elem: PsiElement): List<InlayInfoDetails> {
return provideHints(elem).map { InlayInfoDetails(it, listOf(TextInlayInfoDetail(it.text))) }
abstract fun isApplicable(e: PsiElement): Boolean
open fun provideHints(e: PsiElement): List<InlayInfo> = emptyList()
open fun provideHintDetails(e: PsiElement): List<InlayInfoDetails> {
return provideHints(e).map { InlayInfoDetails(it, listOf(TextInlayInfoDetail(it.text))) }
}
val option = Option("SHOW_${this.name}", { this.showDesc }, defaultEnabled)
val option = Option("SHOW_${this.name}", { this.description }, defaultEnabled)
val enabled
get() = option.get()
}
@@ -7,6 +7,7 @@ import com.intellij.codeInsight.hints.presentation.InlayPresentation
import com.intellij.codeInsight.hints.presentation.InsetPresentation
import com.intellij.codeInsight.hints.presentation.MenuOnClickPresentation
import com.intellij.codeInsight.hints.presentation.PresentationFactory
import com.intellij.lang.Language
import com.intellij.openapi.editor.Document
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.fileTypes.FileType
@@ -33,6 +34,10 @@ abstract class KotlinAbstractHintsProvider<T : Any> : InlayHintsProvider<T> {
abstract fun isElementSupported(resolved: HintType?, settings: T): Boolean
open fun isHintSupported(hintType: HintType): Boolean = false
override fun isLanguageSupported(language: Language): Boolean = language == KotlinLanguage.INSTANCE
override fun createFile(project: Project, fileType: FileType, document: Document): PsiFile =
createKtFile(project, document, fileType)
@@ -155,4 +160,10 @@ abstract class KotlinAbstractHintsProvider<T : Any> : InlayHintsProvider<T> {
}
data class PresentationAndSettings(val presentation: InlayPresentation, val offset: Int, val relatesToPrecedingText: Boolean)
abstract class HintsSettings {
abstract fun isEnabled(hintType: HintType): Boolean
abstract fun enable(hintType: HintType, enable: Boolean)
}
}
@@ -7,12 +7,14 @@ import com.intellij.codeInsight.hints.SettingsKey
import com.intellij.codeInsight.hints.chain.AbstractCallChainHintsProvider
import com.intellij.codeInsight.hints.presentation.InlayPresentation
import com.intellij.codeInsight.hints.presentation.PresentationFactory
import com.intellij.lang.Language
import com.intellij.openapi.editor.Document
import com.intellij.openapi.fileTypes.FileType
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiFile
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.KotlinLanguage
import org.jetbrains.kotlin.idea.caches.resolve.safeAnalyzeNonSourceRootCode
import org.jetbrains.kotlin.idea.parameterInfo.HintsTypeRenderer
import org.jetbrains.kotlin.psi.*
@@ -55,6 +57,8 @@ class KotlinCallChainHintsProvider : AbstractCallChainHintsProvider<KtQualifiedE
override val description: String
get() = KotlinBundle.message("inlay.kotlin.call.chains.hints")
override fun isLanguageSupported(language: Language): Boolean = language == KotlinLanguage.INSTANCE
override fun createFile(project: Project, fileType: FileType, document: Document): PsiFile =
KotlinAbstractHintsProvider.createKtFile(project, document, fileType)
@@ -2,7 +2,9 @@
package org.jetbrains.kotlin.idea.codeInsight.hints
import com.intellij.codeInsight.hints.VcsCodeAuthorInlayHintsProvider
import com.intellij.lang.Language
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.idea.KotlinLanguage
import org.jetbrains.kotlin.idea.codeInsight.codevision.KotlinCodeVisionUsagesCollector.Companion.CLASS_LOCATION
import org.jetbrains.kotlin.idea.codeInsight.codevision.KotlinCodeVisionUsagesCollector.Companion.FUNCTION_LOCATION
import org.jetbrains.kotlin.idea.codeInsight.codevision.KotlinCodeVisionUsagesCollector.Companion.logCodeAuthorClicked
@@ -11,6 +13,8 @@ import org.jetbrains.kotlin.psi.psiUtil.containingClassOrObject
internal class KotlinCodeAuthorInlayHintsProvider : VcsCodeAuthorInlayHintsProvider() {
override fun isLanguageSupported(language: Language): Boolean = language == KotlinLanguage.INSTANCE
override fun isAccepted(element: PsiElement): Boolean =
when (element) {
is KtClassOrObject -> isAcceptedClassOrObject(element)
@@ -2,6 +2,7 @@
package org.jetbrains.kotlin.idea.codeInsight.hints
import com.intellij.application.options.editor.CheckboxDescriptor
import com.intellij.codeInsight.hints.InlayHintsPassFactory
import com.intellij.codeInsight.hints.settings.InlaySettingsProvider
import com.intellij.ide.ui.OptionsSearchTopHitProvider
import com.intellij.ide.ui.search.OptionDescription
@@ -44,6 +45,7 @@ class KotlinInlayHintsTopHitProvider : OptionsSearchTopHitProvider.ProjectLevelP
with(it) {
isEnabled = newValue
apply()
InlayHintsPassFactory.forceHintsUpdateOnNextPass()
}
})
).asOptionDescriptor()
@@ -59,6 +61,7 @@ class KotlinInlayHintsTopHitProvider : OptionsSearchTopHitProvider.ProjectLevelP
it.isEnabled = true
}
it.apply()
InlayHintsPassFactory.forceHintsUpdateOnNextPass()
})
).asOptionDescriptor()
}
@@ -16,7 +16,21 @@ class KotlinLambdasHintsProvider : KotlinAbstractHintsProvider<KotlinLambdasHint
data class Settings(
var returnExpressions: Boolean = true,
var implicitReceiversAndParams: Boolean = true,
)
): HintsSettings() {
override fun isEnabled(hintType: HintType): Boolean =
when(hintType) {
HintType.LAMBDA_RETURN_EXPRESSION -> returnExpressions
HintType.LAMBDA_IMPLICIT_PARAMETER_RECEIVER -> implicitReceiversAndParams
else -> false
}
override fun enable(hintType: HintType, enable: Boolean) =
when(hintType) {
HintType.LAMBDA_RETURN_EXPRESSION -> returnExpressions = enable
HintType.LAMBDA_IMPLICIT_PARAMETER_RECEIVER -> implicitReceiversAndParams = enable
else -> Unit
}
}
override val key: SettingsKey<Settings> = SettingsKey("kotlin.lambdas.hints")
override val name: String = KotlinBundle.message("hints.settings.lambdas")
@@ -29,13 +43,15 @@ class KotlinLambdasHintsProvider : KotlinAbstractHintsProvider<KotlinLambdasHint
return KotlinBundle.getMessage(key)
}
override fun isElementSupported(resolved: HintType?, settings: Settings): Boolean {
return when (resolved) {
override fun isElementSupported(resolved: HintType?, settings: Settings): Boolean =
when (resolved) {
HintType.LAMBDA_RETURN_EXPRESSION -> settings.returnExpressions
HintType.LAMBDA_IMPLICIT_PARAMETER_RECEIVER -> settings.implicitReceiversAndParams
else -> false
}
}
override fun isHintSupported(hintType: HintType): Boolean =
hintType == HintType.LAMBDA_RETURN_EXPRESSION || hintType == HintType.LAMBDA_IMPLICIT_PARAMETER_RECEIVER
override fun createConfigurable(settings: Settings): ImmediateConfigurable {
return object : ImmediateConfigurable {
@@ -18,7 +18,25 @@ class KotlinReferencesTypeHintsProvider : KotlinAbstractHintsProvider<KotlinRefe
var localVariableType: Boolean = false,
var functionReturnType: Boolean = false,
var parameterType: Boolean = false
)
): HintsSettings() {
override fun isEnabled(hintType: HintType) =
when(hintType) {
HintType.PROPERTY_HINT -> propertyType
HintType.LOCAL_VARIABLE_HINT -> localVariableType
HintType.FUNCTION_HINT -> functionReturnType
HintType.PARAMETER_TYPE_HINT -> parameterType
else -> false
}
override fun enable(hintType: HintType, enable: Boolean) =
when(hintType) {
HintType.PROPERTY_HINT -> propertyType = enable
HintType.LOCAL_VARIABLE_HINT -> localVariableType = enable
HintType.FUNCTION_HINT -> functionReturnType = enable
HintType.PARAMETER_TYPE_HINT -> parameterType = enable
else -> Unit
}
}
override val key: SettingsKey<Settings> = SettingsKey("kotlin.references.types.hints")
override val name: String = KotlinBundle.message("hints.settings.types")
@@ -76,6 +94,10 @@ class KotlinReferencesTypeHintsProvider : KotlinAbstractHintsProvider<KotlinRefe
}
}
override fun isHintSupported(hintType: HintType): Boolean =
hintType == HintType.PROPERTY_HINT || hintType == HintType.LOCAL_VARIABLE_HINT ||
hintType == HintType.FUNCTION_HINT || hintType == HintType.PARAMETER_TYPE_HINT
override val previewText: String = """
val property = listOf(1, 2, 3).filter { num -> num % 2 == 0 }
@@ -11,7 +11,19 @@ class KotlinValuesHintsProvider : KotlinAbstractHintsProvider<KotlinValuesHintsP
data class Settings(
var ranges: Boolean = true
)
): HintsSettings() {
override fun isEnabled(hintType: HintType): Boolean =
when (hintType) {
HintType.RANGES -> ranges
else -> false
}
override fun enable(hintType: HintType, enable: Boolean) =
when (hintType) {
HintType.RANGES -> ranges = enable
else -> Unit
}
}
override val key: SettingsKey<Settings> = SettingsKey("kotlin.values.hints")
override val name: String = KotlinBundle.message("hints.settings.values.ranges")
@@ -37,12 +49,13 @@ class KotlinValuesHintsProvider : KotlinAbstractHintsProvider<KotlinValuesHintsP
}
override fun isElementSupported(resolved: HintType?, settings: Settings): Boolean {
return when (resolved) {
override fun isElementSupported(resolved: HintType?, settings: Settings): Boolean =
when (resolved) {
HintType.RANGES -> settings.ranges
else -> false
}
}
override fun isHintSupported(hintType: HintType): Boolean = hintType == HintType.RANGES
override val previewText: String? = null
@@ -10980,6 +10980,24 @@ public abstract class IntentionTestGenerated extends AbstractIntentionTest {
}
}
@RunWith(JUnit3RunnerWithInners.class)
@TestMetadata("testData/intentions/inlayHints")
public static class InlayHints extends AbstractIntentionTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
@TestMetadata("localVariable.kt")
public void testLocalVariable() throws Exception {
runTest("testData/intentions/inlayHints/localVariable.kt");
}
@TestMetadata("property.kt")
public void testProperty() throws Exception {
runTest("testData/intentions/inlayHints/property.kt");
}
}
@RunWith(JUnit3RunnerWithInners.class)
@TestMetadata("testData/intentions/insertCurlyBracesToTemplate")
public static class InsertCurlyBracesToTemplate extends AbstractIntentionTest {
@@ -111,7 +111,8 @@ abstract class AbstractQuickFixMultiFileTest : KotlinLightCodeInsightFixtureTest
}
private fun doMultiFileTest(beforeFileName: String) {
val multiFileText = FileUtil.loadFile(File(beforeFileName), true)
val mainFile = File(beforeFileName)
val multiFileText = FileUtil.loadFile(mainFile, true)
val subFiles = TestFiles.createTestFiles(
"single.kt",
@@ -150,6 +151,7 @@ abstract class AbstractQuickFixMultiFileTest : KotlinLightCodeInsightFixtureTest
}
doAction(
mainFile,
text,
file,
editor,
@@ -177,7 +179,7 @@ abstract class AbstractQuickFixMultiFileTest : KotlinLightCodeInsightFixtureTest
}
actualTestFile.append("// FILE: ").append(afterFile.path).append("\n").append(afterText)
KotlinTestUtils.assertEqualsToFile(File(beforeFileName), actualTestFile.toString())
KotlinTestUtils.assertEqualsToFile(mainFile, actualTestFile.toString())
}
} else {
TestCase.assertNull(".after file should not exist", afterFile)
@@ -228,6 +230,7 @@ abstract class AbstractQuickFixMultiFileTest : KotlinLightCodeInsightFixtureTest
}
doAction(
mainFile,
text,
file,
editor,
@@ -281,7 +284,7 @@ abstract class AbstractQuickFixMultiFileTest : KotlinLightCodeInsightFixtureTest
DirectiveBasedActionUtils.checkForUnexpectedErrors(file)
}
protected open fun checkAvailableActionsAreExpected(file: PsiFile, actions: Collection<IntentionAction>) {
protected open fun checkAvailableActionsAreExpected(file: File, actions: Collection<IntentionAction>) {
DirectiveBasedActionUtils.checkAvailableActionsAreExpected(file, availableActions)
}
@@ -313,6 +316,7 @@ abstract class AbstractQuickFixMultiFileTest : KotlinLightCodeInsightFixtureTest
availableActions.firstOrNull { pattern.matcher(it.text).matches() }
fun doAction(
mainFile: File,
text: String,
file: PsiFile,
editor: Editor,
@@ -321,7 +325,7 @@ abstract class AbstractQuickFixMultiFileTest : KotlinLightCodeInsightFixtureTest
getAvailableActions: () -> List<IntentionAction>,
doHighlighting: () -> List<HighlightInfo>,
shouldBeAvailableAfterExecution: Boolean = false,
checkAvailableActionsAreExpected: (PsiFile, Collection<IntentionAction>) -> Unit =
checkAvailableActionsAreExpected: (File, Collection<IntentionAction>) -> Unit =
DirectiveBasedActionUtils::checkAvailableActionsAreExpected
) {
val pattern = if (text.startsWith("/"))
@@ -346,7 +350,7 @@ abstract class AbstractQuickFixMultiFileTest : KotlinLightCodeInsightFixtureTest
StringUtil.join(infos, "\n")
)
} else {
checkAvailableActionsAreExpected(file, availableActions)
checkAvailableActionsAreExpected(mainFile, availableActions)
}
} else {
if (!actionShouldBeAvailable) {
@@ -8,6 +8,7 @@ import com.intellij.codeInsight.intention.IntentionAction
import com.intellij.openapi.ui.Messages
import com.intellij.openapi.ui.TestDialog
import com.intellij.openapi.ui.TestDialogManager
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.testFramework.IdeaTestUtil
import com.intellij.testFramework.UsefulTestCase
import junit.framework.ComparisonFailure
@@ -44,9 +45,23 @@ abstract class AbstractQuickFixMultiModuleTest : AbstractMultiModuleTest(), Quic
}
}
private fun VirtualFile.toIOFile(): File? {
val paths = mutableListOf<String>()
var vFile: VirtualFile? = this
while (vFile != null) {
vFile.sourceIOFile()?.let {
return File(it, paths.reversed().joinToString("/"))
}
paths.add(vFile.name)
vFile = vFile.parent
}
return null
}
private fun doQuickFixTest(dirPath: String) {
val actionFile = project.findFileWithCaret()
val virtualFile = actionFile.virtualFile!!
val mainFile = virtualFile.toIOFile()?.takeIf(File::exists) ?: error("unable to lookup source io file")
configureByExistingFile(virtualFile)
val actionFileText = actionFile.text
val actionFileName = actionFile.name
@@ -79,6 +94,7 @@ abstract class AbstractQuickFixMultiModuleTest : AbstractMultiModuleTest(), Quic
val log = try {
AbstractQuickFixMultiFileTest.doAction(
mainFile,
text,
file,
editor,
@@ -15,9 +15,11 @@ import com.intellij.openapi.roots.DependencyScope
import com.intellij.openapi.roots.ModuleRootModificationUtil
import com.intellij.openapi.roots.OrderRootType
import com.intellij.openapi.roots.libraries.PersistentLibraryKind
import com.intellij.openapi.util.Key
import com.intellij.openapi.util.Ref
import com.intellij.openapi.util.io.FileUtil
import com.intellij.openapi.vfs.LocalFileSystem
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.PsiFile
import com.intellij.testFramework.IdeaTestUtil
import com.intellij.testFramework.PsiTestUtil
@@ -84,6 +86,8 @@ abstract class AbstractMultiModuleTest : DaemonAnalyzerTestCase() {
return super.createModule(path, moduleType)
}
fun VirtualFile.sourceIOFile(): File? = getUserData(sourceIOFile)
fun addRoot(module: Module, sourceDirInTestData: File, isTestRoot: Boolean, transformContainedFiles: ((File) -> Unit)? = null) {
val tmpDir = createTempDirectory()
@@ -97,6 +101,7 @@ abstract class AbstractMultiModuleTest : DaemonAnalyzerTestCase() {
}
val virtualTempDir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(tmpRootDir)!!
virtualTempDir.putUserData(sourceIOFile, sourceDirInTestData)
virtualTempDir.refresh(false, isTestRoot)
PsiTestUtil.addSourceRoot(module, virtualTempDir, isTestRoot)
}
@@ -179,6 +184,8 @@ abstract class AbstractMultiModuleTest : DaemonAnalyzerTestCase() {
}
}
private val sourceIOFile: Key<File> = Key("sourceIOFile")
fun Module.createFacet(
platformKind: TargetPlatform? = null,
useProjectSettings: Boolean = true
@@ -0,0 +1 @@
org.jetbrains.kotlin.idea.codeInsight.hints.EnableKotlinTypeHintsOption
@@ -0,0 +1,6 @@
// IS_APPLICABLE: true
// AFTER-WARNING: Variable 'q' is never used
fun foo() {
val s = ""
val q<caret> = s
}
@@ -0,0 +1,6 @@
// IS_APPLICABLE: true
// AFTER-WARNING: Variable 'q' is never used
fun foo() {
val s = ""
val q<caret> = s
}
@@ -0,0 +1,3 @@
// IS_APPLICABLE: true
val s = ""
val q<caret> = s
@@ -0,0 +1,3 @@
// IS_APPLICABLE: true
val s = ""
val q<caret> = s
@@ -1,4 +1,5 @@
// "Add '@Throws' annotation" "false"
// ACTION: Do not show return expression hints
fun test() {
<caret>throw Throwable()
@@ -1,4 +1,5 @@
// "Add '@Throws' annotation" "false"
// ACTION: Do not show return expression hints
fun test() {
<caret>throw Throwable()
@@ -3,6 +3,7 @@
// ACTION: Convert member to extension
// ACTION: Convert to block body
// ACTION: Create expected class in common module testModule_Common
// ACTION: Do not show return expression hints
// ACTION: Move to companion object
// ACTION: Remove 'actual' modifier
// ACTION: Remove explicit type specification
@@ -1,6 +1,7 @@
// "Create expected class in common module testModule_Common" "false"
// DISABLE-ERRORS
// ACTION: Apply all 'Remove modifier' fixes in file
// ACTION: Do not show return expression hints
// ACTION: Remove 'actual' modifier
class Some(val x: Int, val y: Int) {
@@ -1,5 +1,6 @@
// "Add 'CancellationException::class'" "false"
// ERROR: @Throws on suspend declaration must have CancellationException (or any of its superclasses) listed
// ACTION: Do not show return expression hints
// ACTION: Make internal
// ACTION: Make private
@@ -1,5 +1,6 @@
// "Add 'CancellationException::class'" "false"
// ERROR: @Throws must have non-empty class list
// ACTION: Do not show return expression hints
// ACTION: Make internal
// ACTION: Make private
// ACTION: Remove annotation
@@ -1,5 +1,6 @@
// "Add 'CancellationException::class'" "false"
// ERROR: @Throws must have non-empty class list
// ACTION: Do not show return expression hints
// ACTION: Make internal
// ACTION: Make private
// ACTION: Remove annotation
@@ -4,6 +4,7 @@
// ACTION: Apply all 'Add modifier' fixes in file
// ACTION: Convert member to extension
// ACTION: Convert property to function
// ACTION: Do not show return expression hints
// ACTION: Introduce backing property
// ACTION: Make 'b' 'abstract'
// ACTION: Move to companion object
@@ -4,6 +4,7 @@
// ACTION: Apply all 'Add modifier' fixes in file
// ACTION: Convert member to extension
// ACTION: Convert property to function
// ACTION: Do not show return expression hints
// ACTION: Introduce backing property
// ACTION: Make 'b' 'abstract'
// ACTION: Move to companion object
@@ -4,6 +4,7 @@
// ACTION: Apply all 'Add modifier' fixes in file
// ACTION: Convert member to extension
// ACTION: Convert property to function
// ACTION: Do not show return expression hints
// ACTION: Introduce backing property
// ACTION: Make 'b' 'abstract'
// ACTION: Move to companion object
@@ -4,6 +4,7 @@
// ACTION: Apply all 'Add modifier' fixes in file
// ACTION: Convert member to extension
// ACTION: Convert property to function
// ACTION: Do not show return expression hints
// ACTION: Introduce backing property
// ACTION: Make 'b' 'abstract'
// ACTION: Move to companion object
@@ -2,6 +2,7 @@
// ERROR: Class 'End' is not abstract and does not implement abstract member public abstract val a: Int defined in IFoo
// ACTION: Apply all 'Add modifier' fixes in file
// ACTION: Create test
// ACTION: Do not show return expression hints
// ACTION: Implement members
// ACTION: Make 'End' 'abstract'
// ACTION: Rename file to End.kt
@@ -1,5 +1,6 @@
// "Add 'actual' modifier" "false"
// ACTION: Create test
// ACTION: Do not show return expression hints
// ACTION: Rename file to Foo.kt
// KTIJ-19789 No diagnostic "actual is missing" on top-level class/function/property in IDE
@@ -1,5 +1,6 @@
// "Add 'actual' modifier" "false"
// ACTION: Create test
// ACTION: Do not show return expression hints
// KTIJ-19789 No diagnostic "actual is missing" on top-level class/function/property in IDE
@@ -1,6 +1,7 @@
// "Convert property getter to initializer" "false"
// ERROR: Expected declaration must not have a body
// ACTION: Convert to block body
// ACTION: Do not show return expression hints
expect class C {
val p: Int
<caret>get() = 1
@@ -1,3 +1,4 @@
// "Create test" "false"
// ACTION: Do not show return expression hints
// ACTION: Rename file to Foo.kt
expect class <caret>Foo
@@ -4,6 +4,7 @@
// ACTION: Create enum 'Foo'
// ACTION: Create interface 'Foo'
// ACTION: Create type parameter 'Foo' in function 'use'
// ACTION: Do not show return expression hints
// ACTION: Enable a trailing comma by default in the formatter
// ERROR: Unresolved reference: Foo
package bar
@@ -1,5 +1,6 @@
// "Convert member to extension" "false"
// ACTION: Convert property to function
// ACTION: Do not show return expression hints
// ACTION: Move to companion object
expect class Foo {
@@ -1,6 +1,7 @@
// "Safe delete 'foo'" "false"
// TOOL: org.jetbrains.kotlin.idea.inspections.UnusedSymbolInspection
// ACTION: Convert member to extension
// ACTION: Do not show return expression hints
// ACTION: Move to companion object
actual class My {
@@ -1,6 +1,7 @@
// "Safe delete 'foo'" "false"
// TOOL: org.jetbrains.kotlin.idea.inspections.UnusedSymbolInspection
// ACTION: Convert member to extension
// ACTION: Do not show return expression hints
// ACTION: Move to companion object
actual class My {
@@ -1,6 +1,7 @@
// "Make not-nullable" "false"
// TOOL: org.jetbrains.kotlin.idea.inspections.RedundantNullableReturnTypeInspection
// ACTION: Convert to block body
// ACTION: Do not show return expression hints
// ACTION: Remove explicit type specification
actual class MyClass {
@@ -1,6 +1,7 @@
// "Make not-nullable" "false"
// TOOL: org.jetbrains.kotlin.idea.inspections.RedundantNullableReturnTypeInspection
// ACTION: Convert to block body
// ACTION: Do not show return expression hints
// ACTION: Remove explicit type specification
actual fun runAction(block: () -> Unit): Any?<caret> = block()
@@ -2,6 +2,7 @@
// TOOL: org.jetbrains.kotlin.idea.inspections.RedundantNullableReturnTypeInspection
// ACTION: Convert property initializer to getter
// ACTION: Convert to lazy property
// ACTION: Do not show return expression hints
// ACTION: Remove explicit type specification
actual val prop: Any?<caret> = 42
@@ -2,8 +2,9 @@
// ERROR: Class 'A' is not abstract and does not implement abstract member public abstract fun foo(): String defined in I
// ERROR: Primary constructor is required for value class
// ACTION: Create test
// ACTION: Implement members
// ACTION: Do not show return expression hints
// ACTION: Extract 'A' from current file
// ACTION: Implement members
// ACTION: Rename file to A.kt
interface I {
fun foo(): String
@@ -1,6 +1,7 @@
// "Add annotation target" "false"
// WITH_STDLIB
// ACTION: Convert to ordinary property
// ACTION: Do not show return expression hints
// ACTION: Introduce import alias
// ACTION: Make internal
// ACTION: Make private
@@ -1,6 +1,7 @@
// "Add annotation target" "false"
// WITH_STDLIB
// ACTION: Convert to ordinary property
// ACTION: Do not show return expression hints
// ACTION: Introduce import alias
// ACTION: Make internal
// ACTION: Make private
@@ -3,6 +3,7 @@
// ACTION: Create extension function 'Foo.component2'
// ACTION: Create member function 'Foo.component1'
// ACTION: Create member function 'Foo.component2'
// ACTION: Do not show return expression hints
// ACTION: Enable a trailing comma by default in the formatter
// ACTION: Put arguments on separate lines
// ERROR: Cannot create an instance of an abstract class
@@ -3,6 +3,7 @@
// ACTION: Create extension function 'Test.Foo.component2'
// ACTION: Create member function 'Test.Foo.component1'
// ACTION: Create member function 'Test.Foo.component2'
// ACTION: Do not show return expression hints
// ACTION: Enable a trailing comma by default in the formatter
// ACTION: Put arguments on separate lines
// ERROR: Destructuring declaration initializer of type Test.Foo must have a 'component1()' function
@@ -3,6 +3,7 @@
// ACTION: Create extension function 'Foo.component2'
// ACTION: Create member function 'Foo.component1'
// ACTION: Create member function 'Foo.component2'
// ACTION: Do not show return expression hints
// ACTION: Enable a trailing comma by default in the formatter
// ACTION: Put arguments on separate lines
// ERROR: Destructuring declaration initializer of type Foo must have a 'component1()' function
@@ -3,6 +3,7 @@
// ACTION: Create extension function 'Foo.component2'
// ACTION: Create member function 'Foo.component1'
// ACTION: Create member function 'Foo.component2'
// ACTION: Do not show return expression hints
// ACTION: Enable a trailing comma by default in the formatter
// ACTION: Put arguments on separate lines
// ERROR: Destructuring declaration initializer of type Foo must have a 'component1()' function
@@ -3,6 +3,7 @@
// ACTION: Create extension function 'Foo.component2'
// ACTION: Create member function 'Foo.component1'
// ACTION: Create member function 'Foo.component2'
// ACTION: Do not show return expression hints
// ACTION: Enable a trailing comma by default in the formatter
// ERROR: Destructuring declaration initializer of type Foo must have a 'component1()' function
// ERROR: Destructuring declaration initializer of type Foo must have a 'component2()' function
@@ -3,6 +3,7 @@
// ACTION: Create extension function 'Foo.component2'
// ACTION: Create member function 'Foo.component1'
// ACTION: Create member function 'Foo.component2'
// ACTION: Do not show return expression hints
// ACTION: Enable a trailing comma by default in the formatter
// ACTION: Put arguments on separate lines
// ERROR: Destructuring declaration initializer of type Foo must have a 'component1()' function
@@ -3,6 +3,7 @@
// ACTION: Create extension function 'Foo.component2'
// ACTION: Create member function 'Foo.component1'
// ACTION: Create member function 'Foo.component2'
// ACTION: Do not show return expression hints
// ACTION: Enable a trailing comma by default in the formatter
// ACTION: Put arguments on separate lines
// ERROR: Destructuring declaration initializer of type Foo must have a 'component1()' function
@@ -3,6 +3,7 @@
// ACTION: Create extension function 'Foo.component2'
// ACTION: Create member function 'Foo.component1'
// ACTION: Create member function 'Foo.component2'
// ACTION: Do not show return expression hints
// ACTION: Enable a trailing comma by default in the formatter
// ACTION: Put arguments on separate lines
// ERROR: Cannot access '<init>': it is protected in 'Foo'
@@ -3,6 +3,7 @@
// ACTION: Create extension function 'Foo.component2'
// ACTION: Create member function 'Foo.component1'
// ACTION: Create member function 'Foo.component2'
// ACTION: Do not show return expression hints
// ACTION: Enable a trailing comma by default in the formatter
// ACTION: Put arguments on separate lines
// ERROR: Destructuring declaration initializer of type Foo must have a 'component1()' function
@@ -1,5 +1,6 @@
// "Add default constructor to expect class" "false"
// ENABLE_MULTIPLATFORM
// ACTION: Do not show return expression hints
// ACTION: Make internal
// ACTION: Make private
// ACTION: Remove constructor call
@@ -1,4 +1,5 @@
// "Add '== true'" "false"
// ACTION: Do not show return expression hints
// DISABLE-ERRORS
class Foo {
fun bar() = ""
@@ -1,4 +1,5 @@
// "Add non-null asserted (!!) call" "false"
// ACTION: Do not show return expression hints
// ACTION: Replace with a 'forEach' function call
// ACTION: Surround with null check
// ERROR: Not nullable value required to call an 'iterator()' method on for-loop range
@@ -1,6 +1,7 @@
// "Add non-null asserted (!!) call" "false"
// ACTION: Add 'toString()' call
// ACTION: Change type of 'x' to 'String?'
// ACTION: Do not show return expression hints
// ERROR: Type mismatch: inferred type is String? but String was expected
fun foo(arg: String?) {
@@ -2,6 +2,7 @@
// ACTION: Add non-null asserted (!!) call
// ACTION: Convert to run
// ACTION: Convert to with
// ACTION: Do not show return expression hints
// ACTION: Remove braces from 'if' statement
// ACTION: Replace 'if' expression with safe access expression
@@ -2,6 +2,7 @@
// ACTION: Add non-null asserted (!!) call
// ACTION: Convert to run
// ACTION: Convert to with
// ACTION: Do not show return expression hints
// ACTION: Remove braces from 'if' statement
// ACTION: Replace 'if' expression with safe access expression
@@ -1,4 +1,5 @@
// "Add initializer" "false"
// ACTION: Do not show return expression hints
fun test() {
<caret>val n: Int
}
@@ -1,5 +1,6 @@
// "Add initializer" "false"
// ACTION: Add getter
// ACTION: Do not show return expression hints
// ACTION: Make internal
// ACTION: Make private
// ERROR: Extension property must have accessors or be abstract
@@ -1,5 +1,6 @@
// "Add initializer" "false"
// ACTION: Add getter
// ACTION: Do not show return expression hints
// ACTION: Make internal
// ACTION: Make private
// ERROR: Extension property must have accessors or be abstract
@@ -2,6 +2,7 @@
// WITH_STDLIB
// ACTION: Convert to ordinary property
// ACTION: Create test
// ACTION: Do not show return expression hints
// ACTION: Make internal
// ACTION: Make private
<caret>val n: Int by lazy { 0 }
@@ -1,5 +1,6 @@
// "Add initializer" "false"
// ACTION: Create test
// ACTION: Do not show return expression hints
// ACTION: Make internal
// ACTION: Make private
// ACTION: Remove explicit type specification
@@ -1,6 +1,7 @@
// "Add 'return' before the expression" "false"
// ERROR: A 'return' expression required in a function with a block body ('{...}')
// ACTION: Compiler warning 'UNUSED_EXPRESSION' options
// ACTION: Do not show return expression hints
// ACTION: Introduce local variable
fun test(): Boolean {
@@ -1,4 +1,5 @@
// "Add 'return' before the expression" "false"
// ACTION: Do not show return expression hints
fun test(): Nothing {
<caret>throw Throwable("Error")
@@ -2,6 +2,7 @@
// WITH_STDLIB
// ACTION: Add full qualifier
// ACTION: Compiler warning 'UNUSED_EXPRESSION' options
// ACTION: Do not show return expression hints
// ACTION: Introduce import alias
// ACTION: Introduce local variable
// ERROR: A 'return' expression required in a function with a block body ('{...}')
@@ -1,14 +1,15 @@
// "Add 'return' before the expression" "false"
// WITH_STDLIB
// ACTION: Compiler warning 'UNUSED_EXPRESSION' options
// ACTION: Create local variable 'FunctionReference'
// ACTION: Create object 'FunctionReference'
// ACTION: Create parameter 'FunctionReference'
// ACTION: Create property 'FunctionReference'
// ACTION: Create annotation 'FunctionReference'
// ACTION: Create class 'FunctionReference'
// ACTION: Create enum 'FunctionReference'
// ACTION: Create interface 'FunctionReference'
// ACTION: Create local variable 'FunctionReference'
// ACTION: Create object 'FunctionReference'
// ACTION: Create parameter 'FunctionReference'
// ACTION: Create property 'FunctionReference'
// ACTION: Do not show return expression hints
// ACTION: Introduce local variable
// ACTION: Rename reference
// ERROR: Unresolved reference: FunctionReference
@@ -1,5 +1,6 @@
// "Change type arguments to <*>" "false"
// ACTION: Compiler warning 'UNCHECKED_CAST' options
// ACTION: Do not show return expression hints
fun test(a: Any) {
(a as List<Boolean><caret>).bar()
}
@@ -1,5 +1,6 @@
// "Change type arguments to <*, *>" "false"
// ACTION: Compiler warning 'UNCHECKED_CAST' options
// ACTION: Do not show return expression hints
fun test(a: Any) {
(a as Map<Int, Boolean><caret>).bar()
}
@@ -1,5 +1,6 @@
// "Change type arguments to <*>" "false"
// ACTION: Compiler warning 'UNCHECKED_CAST' options
// ACTION: Do not show return expression hints
fun <T> test(list: List<*>): List<T> {
return list as List<T><caret>
}
@@ -1,5 +1,6 @@
// "Change type arguments to <*>" "false"
// ACTION: Compiler warning 'UNCHECKED_CAST' options
// ACTION: Do not show return expression hints
fun <T> test(list: List<*>) {
val a: List<T> = list as List<T><caret>
}
@@ -1,5 +1,6 @@
// "Assign to property" "false"
// ACTION: Converts the assignment statement to an expression
// ACTION: Do not show return expression hints
// ERROR: Val cannot be reassigned
class Test {
var bar = 1
@@ -1,5 +1,6 @@
// "Assign to property" "false"
// ACTION: Converts the assignment statement to an expression
// ACTION: Do not show return expression hints
// ERROR: Val cannot be reassigned
class Test(var bar: Int) {
fun test(foo: Int) {
@@ -1,5 +1,6 @@
// "Assign to property" "false"
// ACTION: Converts the assignment statement to an expression
// ACTION: Do not show return expression hints
// ERROR: Val cannot be reassigned
class Test {
var foo = "1"
@@ -1,5 +1,6 @@
// "Assign to property" "false"
// ACTION: Converts the assignment statement to an expression
// ACTION: Do not show return expression hints
// ERROR: Val cannot be reassigned
class Test(var foo: String) {
fun test(foo: Int) {
@@ -1,5 +1,6 @@
// "Assign to property" "false"
// ACTION: Converts the assignment statement to an expression
// ACTION: Do not show return expression hints
// ERROR: Val cannot be reassigned
class Test(foo: Int) {
fun test(foo: Int) {
@@ -1,5 +1,6 @@
// "Assign to property" "false"
// ACTION: Converts the assignment statement to an expression
// ACTION: Do not show return expression hints
// ERROR: Val cannot be reassigned
class Test {
val foo = 1
@@ -1,5 +1,6 @@
// "Assign to property" "false"
// ACTION: Converts the assignment statement to an expression
// ACTION: Do not show return expression hints
// ERROR: Val cannot be reassigned
class Test(val foo: Int) {
fun test(foo: Int) {
@@ -1,6 +1,7 @@
// "Import" "false"
// WITH_STDLIB
// ACTION: Create extension function 'List<String>.maxByOrNull'
// ACTION: Do not show return expression hints
// ERROR: Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: <br>public inline fun <T, R : Comparable<TypeVariable(R)>> Array<out TypeVariable(T)>.maxByOrNull(selector: (TypeVariable(T)) -> TypeVariable(R)): TypeVariable(T)? defined in kotlin.collections<br>public inline fun <R : Comparable<TypeVariable(R)>> BooleanArray.maxByOrNull(selector: (Boolean) -> TypeVariable(R)): Boolean? defined in kotlin.collections<br>public inline fun <R : Comparable<TypeVariable(R)>> ByteArray.maxByOrNull(selector: (Byte) -> TypeVariable(R)): Byte? defined in kotlin.collections<br>public inline fun <R : Comparable<TypeVariable(R)>> CharArray.maxByOrNull(selector: (Char) -> TypeVariable(R)): Char? defined in kotlin.collections<br>public inline fun <R : Comparable<TypeVariable(R)>> CharSequence.maxByOrNull(selector: (Char) -> TypeVariable(R)): Char? defined in kotlin.text<br>public inline fun <R : Comparable<TypeVariable(R)>> DoubleArray.maxByOrNull(selector: (Double) -> TypeVariable(R)): Double? defined in kotlin.collections<br>public inline fun <R : Comparable<TypeVariable(R)>> FloatArray.maxByOrNull(selector: (Float) -> TypeVariable(R)): Float? defined in kotlin.collections<br>public inline fun <R : Comparable<TypeVariable(R)>> IntArray.maxByOrNull(selector: (Int) -> TypeVariable(R)): Int? defined in kotlin.collections<br>public inline fun <R : Comparable<TypeVariable(R)>> LongArray.maxByOrNull(selector: (Long) -> TypeVariable(R)): Long? defined in kotlin.collections<br>public inline fun <R : Comparable<TypeVariable(R)>> ShortArray.maxByOrNull(selector: (Short) -> TypeVariable(R)): Short? defined in kotlin.collections<br>public inline fun <R : Comparable<TypeVariable(R)>> UByteArray.maxByOrNull(selector: (UByte) -> TypeVariable(R)): UByte? defined in kotlin.collections<br>public inline fun <R : Comparable<TypeVariable(R)>> UIntArray.maxByOrNull(selector: (UInt) -> TypeVariable(R)): UInt? defined in kotlin.collections<br>public inline fun <R : Comparable<TypeVariable(R)>> ULongArray.maxByOrNull(selector: (ULong) -> TypeVariable(R)): ULong? defined in kotlin.collections<br>public inline fun <R : Comparable<TypeVariable(R)>> UShortArray.maxByOrNull(selector: (UShort) -> TypeVariable(R)): UShort? defined in kotlin.collections<br>public inline fun <T, R : Comparable<TypeVariable(R)>> Iterable<TypeVariable(T)>.maxByOrNull(selector: (TypeVariable(T)) -> TypeVariable(R)): TypeVariable(T)? defined in kotlin.collections<br>public inline fun <K, V, R : Comparable<TypeVariable(R)>> Map<out TypeVariable(K), TypeVariable(V)>.maxByOrNull(selector: (Map.Entry<TypeVariable(K), TypeVariable(V)>) -> TypeVariable(R)): Map.Entry<TypeVariable(K), TypeVariable(V)>? defined in kotlin.collections<br>public inline fun <T, R : Comparable<TypeVariable(R)>> Sequence<TypeVariable(T)>.maxByOrNull(selector: (TypeVariable(T)) -> TypeVariable(R)): TypeVariable(T)? defined in kotlin.sequences
// ERROR: Unresolved reference: it
fun <T> test(list: List<String>) {
@@ -1,6 +1,7 @@
// "Import" "false"
// WITH_STDLIB
// ACTION: Create extension function 'List<String>.maxByOrNull'
// ACTION: Do not show return expression hints
// ERROR: Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: <br>public inline fun <T, R : Comparable<TypeVariable(R)>> Array<out TypeVariable(T)>.maxByOrNull(selector: (TypeVariable(T)) -> TypeVariable(R)): TypeVariable(T)? defined in kotlin.collections<br>public inline fun <R : Comparable<TypeVariable(R)>> BooleanArray.maxByOrNull(selector: (Boolean) -> TypeVariable(R)): Boolean? defined in kotlin.collections<br>public inline fun <R : Comparable<TypeVariable(R)>> ByteArray.maxByOrNull(selector: (Byte) -> TypeVariable(R)): Byte? defined in kotlin.collections<br>public inline fun <R : Comparable<TypeVariable(R)>> CharArray.maxByOrNull(selector: (Char) -> TypeVariable(R)): Char? defined in kotlin.collections<br>public inline fun <R : Comparable<TypeVariable(R)>> DoubleArray.maxByOrNull(selector: (Double) -> TypeVariable(R)): Double? defined in kotlin.collections<br>public inline fun <R : Comparable<TypeVariable(R)>> FloatArray.maxByOrNull(selector: (Float) -> TypeVariable(R)): Float? defined in kotlin.collections<br>public inline fun <R : Comparable<TypeVariable(R)>> IntArray.maxByOrNull(selector: (Int) -> TypeVariable(R)): Int? defined in kotlin.collections<br>public inline fun <R : Comparable<TypeVariable(R)>> LongArray.maxByOrNull(selector: (Long) -> TypeVariable(R)): Long? defined in kotlin.collections<br>public inline fun <R : Comparable<TypeVariable(R)>> ShortArray.maxByOrNull(selector: (Short) -> TypeVariable(R)): Short? defined in kotlin.collections<br>public inline fun <R : Comparable<TypeVariable(R)>> UByteArray.maxByOrNull(selector: (UByte) -> TypeVariable(R)): UByte? defined in kotlin.collections<br>public inline fun <R : Comparable<TypeVariable(R)>> UIntArray.maxByOrNull(selector: (UInt) -> TypeVariable(R)): UInt? defined in kotlin.collections<br>public inline fun <R : Comparable<TypeVariable(R)>> ULongArray.maxByOrNull(selector: (ULong) -> TypeVariable(R)): ULong? defined in kotlin.collections<br>public inline fun <R : Comparable<TypeVariable(R)>> UShortArray.maxByOrNull(selector: (UShort) -> TypeVariable(R)): UShort? defined in kotlin.collections<br>public inline fun <T, R : Comparable<TypeVariable(R)>> Iterable<TypeVariable(T)>.maxByOrNull(selector: (TypeVariable(T)) -> TypeVariable(R)): TypeVariable(T)? defined in kotlin.collections<br>public inline fun <K, V, R : Comparable<TypeVariable(R)>> Map<out TypeVariable(K), TypeVariable(V)>.maxByOrNull(selector: (Map.Entry<TypeVariable(K), TypeVariable(V)>) -> TypeVariable(R)): Map.Entry<TypeVariable(K), TypeVariable(V)>? defined in kotlin.collections
// ERROR: Unresolved reference: it
import kotlin.collections.maxByOrNull
@@ -2,6 +2,7 @@
// ACTION: Create extension function 'A.ext'
// ACTION: Create function 'ext'
// ACTION: Create member function 'A.ext'
// ACTION: Do not show return expression hints
// ACTION: Rename reference
// ERROR: Unresolved reference: ext
package p
@@ -1,4 +1,5 @@
// "Import" "false"
// ACTION: Do not show return expression hints
// ACTION: Rename reference
// ERROR: Unresolved reference: genericExt
package p
@@ -1,4 +1,5 @@
// "Import" "false"
// ACTION: Do not show return expression hints
// ACTION: Rename reference
// ERROR: Unresolved reference: ext
package p
@@ -2,6 +2,7 @@
// ACTION: Create extension function 'A.bar'
// ACTION: Create function 'bar'
// ACTION: Create member function 'A.bar'
// ACTION: Do not show return expression hints
// ACTION: Rename reference
// ERROR: Unresolved reference: bar
package p
@@ -3,6 +3,7 @@
// ACTION: Convert to apply
// ACTION: Convert to run
// ACTION: Convert to with
// ACTION: Do not show return expression hints
// ACTION: Rename reference
// ERROR: Unresolved reference: ext
@@ -1,4 +1,5 @@
// "Import" "false"
// ACTION: Do not show return expression hints
// ACTION: Rename reference
// ERROR: Unresolved reference: ext
package p
@@ -3,6 +3,7 @@
// ACTION: Convert to with
// ACTION: Create extension function 'Base.foo'
// ACTION: Create member function 'Base.foo'
// ACTION: Do not show return expression hints
// ACTION: Rename reference
// ERROR: Unresolved reference: foo
@@ -3,6 +3,7 @@
// ACTION: Convert to with
// ACTION: Create extension function 'Base.defaultFun'
// ACTION: Create member function 'Base.defaultFun'
// ACTION: Do not show return expression hints
// ACTION: Rename reference
// ERROR: Unresolved reference: defaultFun
@@ -2,6 +2,7 @@
// ACTION: Create extension function 'Base.foo'
// ACTION: Create function 'foo'
// ACTION: Create member function 'Base.foo'
// ACTION: Do not show return expression hints
// ERROR: Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: <br>public final fun Other.foo(): Unit defined in p.Base
package p
@@ -2,6 +2,7 @@
// ACTION: Create extension function 'Base.defaultFun'
// ACTION: Create function 'defaultFun'
// ACTION: Create member function 'Base.defaultFun'
// ACTION: Do not show return expression hints
// ACTION: Rename reference
// ERROR: Unresolved reference: defaultFun
package p
@@ -1,5 +1,6 @@
// "Import" "false"
// ACTION: Create function 'ext'
// ACTION: Do not show return expression hints
// ACTION: Rename reference
// ERROR: Unresolved reference: ext
package p
@@ -2,6 +2,7 @@
// "Import" "false"
// ERROR: Type 'String' has no method 'getValue(Nothing?, KProperty<*>)' and thus it cannot serve as a delegate
// ACTION: Convert to 'buildString' call
// ACTION: Do not show return expression hints
// ACTION: To raw string literal
package b
@@ -2,15 +2,16 @@
// WITH_STDLIB
// LANGUAGE_VERSION: 1.2
// ACTION: Compiler warning 'UNUSED_EXPRESSION' options
// ACTION: Create local variable 'CoroutineImpl'
// ACTION: Create object 'CoroutineImpl'
// ACTION: Create parameter 'CoroutineImpl'
// ACTION: Create property 'CoroutineImpl'
// ACTION: Introduce local variable
// ACTION: Create annotation 'CoroutineImpl'
// ACTION: Create class 'CoroutineImpl'
// ACTION: Create enum 'CoroutineImpl'
// ACTION: Create interface 'CoroutineImpl'
// ACTION: Create local variable 'CoroutineImpl'
// ACTION: Create object 'CoroutineImpl'
// ACTION: Create parameter 'CoroutineImpl'
// ACTION: Create property 'CoroutineImpl'
// ACTION: Do not show return expression hints
// ACTION: Introduce local variable
// ACTION: Rename reference
// ERROR: Unresolved reference: CoroutineImpl
@@ -2,6 +2,7 @@
// WITH_STDLIB
// LANGUAGE_VERSION: 1.2
// ACTION: Create function 'suspendCoroutineOrReturn'
// ACTION: Do not show return expression hints
// ACTION: Rename reference
// ERROR: Unresolved reference: suspendCoroutineOrReturn
@@ -1,14 +1,15 @@
// "Import" "false"
// WITH_STDLIB
// ACTION: Compiler warning 'UNUSED_EXPRESSION' options
// ACTION: Create local variable 'FunctionReference'
// ACTION: Create object 'FunctionReference'
// ACTION: Create parameter 'FunctionReference'
// ACTION: Create property 'FunctionReference'
// ACTION: Create annotation 'FunctionReference'
// ACTION: Create class 'FunctionReference'
// ACTION: Create enum 'FunctionReference'
// ACTION: Create interface 'FunctionReference'
// ACTION: Create local variable 'FunctionReference'
// ACTION: Create object 'FunctionReference'
// ACTION: Create parameter 'FunctionReference'
// ACTION: Create property 'FunctionReference'
// ACTION: Do not show return expression hints
// ACTION: Introduce local variable
// ACTION: Rename reference
// ERROR: Unresolved reference: FunctionReference
@@ -1,6 +1,7 @@
// "Import" "false"
// ACTION: Create extension function 'H?.inc'
// ACTION: Create member function 'H.inc'
// ACTION: Do not show return expression hints
// ACTION: Replace overloaded operator with function call
// ERROR: Unresolved reference: ++
@@ -3,6 +3,7 @@
// ACTION: Create extension property 'A.Companion.foo'
// ACTION: Create member property 'A.Companion.foo'
// ACTION: Create object 'foo'
// ACTION: Do not show return expression hints
// ACTION: Rename reference
// ERROR: Unresolved reference: foo

Some files were not shown because too many files have changed in this diff Show More