diff --git a/idea/performanceTests/test/org/jetbrains/kotlin/idea/testFramework/projectRoutines.kt b/idea/performanceTests/test/org/jetbrains/kotlin/idea/testFramework/projectRoutines.kt index 2f59e29a227..c8173ce4dac 100644 --- a/idea/performanceTests/test/org/jetbrains/kotlin/idea/testFramework/projectRoutines.kt +++ b/idea/performanceTests/test/org/jetbrains/kotlin/idea/testFramework/projectRoutines.kt @@ -25,7 +25,7 @@ import com.intellij.psi.impl.PsiDocumentManagerBase import com.intellij.testFramework.ExtensionTestUtil import com.intellij.testFramework.runInEdtAndWait import com.intellij.util.ui.UIUtil -import org.jetbrains.kotlin.idea.parameterInfo.HintType +import org.jetbrains.kotlin.idea.codeInsight.hints.HintType import org.jetbrains.kotlin.idea.perf.util.logMessage import org.jetbrains.kotlin.idea.test.runPostStartupActivitiesOnce import java.nio.file.Paths diff --git a/idea/performanceTests/test/org/jetbrains/kotlin/idea/testFramework/projectRoutines.kt.192 b/idea/performanceTests/test/org/jetbrains/kotlin/idea/testFramework/projectRoutines.kt.192 index ecd2802c7c8..4648dfc3ce7 100644 --- a/idea/performanceTests/test/org/jetbrains/kotlin/idea/testFramework/projectRoutines.kt.192 +++ b/idea/performanceTests/test/org/jetbrains/kotlin/idea/testFramework/projectRoutines.kt.192 @@ -21,7 +21,7 @@ import com.intellij.psi.impl.PsiDocumentManagerBase import com.intellij.testFramework.PlatformTestUtil import com.intellij.testFramework.runInEdtAndWait import com.intellij.util.ui.UIUtil -import org.jetbrains.kotlin.idea.parameterInfo.HintType +import org.jetbrains.kotlin.idea.codeInsight.hints.HintType import org.jetbrains.kotlin.idea.test.runPostStartupActivitiesOnce fun commitAllDocuments() { diff --git a/idea/resources-en/messages/KotlinBundle.properties b/idea/resources-en/messages/KotlinBundle.properties index 3ba44828fa8..2c53788ac8e 100644 --- a/idea/resources-en/messages/KotlinBundle.properties +++ b/idea/resources-en/messages/KotlinBundle.properties @@ -401,21 +401,29 @@ livetemplate.description.exval=Extension read-only property livetemplate.description.exvar=Extension read-write property hints.progress.calculating.parameter.info=Calculating parameter info -hints.title.property.type.enabled=Show property type hints + +hints.settings.common.items=Show hints for: +hints.settings.parameters=Parameter names +hints.settings.types=Types +hints.settings.types.property=Property types +hints.settings.types.variable=Local variable types +hints.settings.types.return=Function return types +hints.settings.types.parameter=Function parameter types + +hints.settings.lambdas=Lambdas +hints.settings.lambda.return=Return expressions +hints.settings.lambda.receivers.parameters=Implicit receivers and parameters + +hints.settings.suspending=Suspending calls + hints.title.property.type.disabled=Do not show property type hints -hints.title.locals.type.enabled=Show local variable type hints hints.title.locals.type.disabled=Do not show local variable type hints -hints.title.function.type.enabled=Show function return type hints hints.title.function.type.disabled=Do not show function return type hints -hints.title.parameter.type.enabled=Show parameter type hints hints.title.parameter.type.disabled=Do not show parameter type hints -hints.title.argument.name.enabled=Show argument name hints +hints.title.argument.name.enabled=Argument name hints.title.argument.name.disabled=Do not show argument name hints -hints.title.return.expression.enabled=Show lambda return expression hints hints.title.return.expression.disabled=Do not show lambda return expression hints -hints.title.implicit.parameters.enabled=Show hints for implicit receivers and parameters of lambdas hints.title.implicit.parameters.disabled=Do not show hints for implicit receivers and parameters of lambdas -hints.title.suspend.calls.enabled=Show hints for suspending calls hints.title.suspend.calls.disabled=Do not show hints for suspending calls presentation.text.paren=({0}) diff --git a/idea/resources/META-INF/inspections.xml b/idea/resources/META-INF/inspections.xml index 275db50cb5c..ef1379e64e9 100644 --- a/idea/resources/META-INF/inspections.xml +++ b/idea/resources/META-INF/inspections.xml @@ -775,10 +775,6 @@ Kotlin - - org.jetbrains.kotlin.idea.parameterInfo.custom.DisableReturnLambdaHintOptionAction - - org.jetbrains.kotlin.idea.intentions.AddUnderscoresToNumericLiteralIntention Kotlin diff --git a/idea/resources/META-INF/plugin-common.xml b/idea/resources/META-INF/plugin-common.xml index 8f7410c2bb9..75c4974c285 100644 --- a/idea/resources/META-INF/plugin-common.xml +++ b/idea/resources/META-INF/plugin-common.xml @@ -375,7 +375,11 @@ - + + + + + diff --git a/idea/src/org/jetbrains/kotlin/idea/parameterInfo/KotlinInlayParameterHintsProvider.kt b/idea/src/org/jetbrains/kotlin/idea/codeInsight/hints/HintType.kt similarity index 57% rename from idea/src/org/jetbrains/kotlin/idea/parameterInfo/KotlinInlayParameterHintsProvider.kt rename to idea/src/org/jetbrains/kotlin/idea/codeInsight/hints/HintType.kt index a61251bcb0b..c9d664301fd 100644 --- a/idea/src/org/jetbrains/kotlin/idea/parameterInfo/KotlinInlayParameterHintsProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/codeInsight/hints/HintType.kt @@ -1,34 +1,26 @@ /* - * Copyright 2000-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ -package org.jetbrains.kotlin.idea.parameterInfo +package org.jetbrains.kotlin.idea.codeInsight.hints -import com.intellij.codeInsight.hints.HintInfo import com.intellij.codeInsight.hints.InlayInfo -import com.intellij.codeInsight.hints.InlayParameterHintsProvider import com.intellij.codeInsight.hints.Option -import com.intellij.lang.Language -import com.intellij.lang.java.JavaLanguage import com.intellij.openapi.application.ApplicationManager import com.intellij.psi.PsiElement -import org.jetbrains.kotlin.descriptors.ConstructorDescriptor -import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.idea.KotlinBundle -import org.jetbrains.kotlin.idea.caches.resolve.resolveToCall +import org.jetbrains.kotlin.idea.parameterInfo.* import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.getReturnTypeReference -import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType -import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameOrNull -import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe -enum class HintType(val showDesc: String, val doNotShowDesc: String, defaultEnabled: Boolean) { +@Suppress("UnstableApiUsage") +enum class HintType(private val showDesc: String, val doNotShowDesc: String, defaultEnabled: Boolean) { PROPERTY_HINT( - KotlinBundle.message("hints.title.property.type.enabled"), + KotlinBundle.message("hints.settings.types.property"), KotlinBundle.message("hints.title.property.type.disabled"), false ) { @@ -40,7 +32,7 @@ enum class HintType(val showDesc: String, val doNotShowDesc: String, defaultEnab }, LOCAL_VARIABLE_HINT( - KotlinBundle.message("hints.title.locals.type.enabled"), + KotlinBundle.message("hints.settings.types.variable"), KotlinBundle.message("hints.title.locals.type.disabled"), false ) { @@ -55,7 +47,7 @@ enum class HintType(val showDesc: String, val doNotShowDesc: String, defaultEnab }, FUNCTION_HINT( - KotlinBundle.message("hints.title.function.type.enabled"), + KotlinBundle.message("hints.settings.types.return"), KotlinBundle.message("hints.title.function.type.disabled"), false ) { @@ -73,7 +65,7 @@ enum class HintType(val showDesc: String, val doNotShowDesc: String, defaultEnab }, PARAMETER_TYPE_HINT( - KotlinBundle.message("hints.title.parameter.type.enabled"), + KotlinBundle.message("hints.settings.types.parameter"), KotlinBundle.message("hints.title.parameter.type.disabled"), false ) { @@ -103,7 +95,7 @@ enum class HintType(val showDesc: String, val doNotShowDesc: String, defaultEnab }, LAMBDA_RETURN_EXPRESSION( - KotlinBundle.message("hints.title.return.expression.enabled"), + KotlinBundle.message("hints.settings.lambda.return"), KotlinBundle.message("hints.title.return.expression.disabled"), true ) { @@ -111,18 +103,13 @@ enum class HintType(val showDesc: String, val doNotShowDesc: String, defaultEnab elem is KtExpression && elem !is KtFunctionLiteral && !elem.isNameReferenceInCall() override fun provideHints(elem: PsiElement): List { - // Will be painted with ReturnHintLinePainter - - // Enable/Disable setting will be present in the list with other hints. - // Enable action will be provided by the platform. - // Disable action need to be reimplemented as hints are not actually added, see DisableReturnLambdaHintOptionAction. - - return emptyList() + if (elem !is KtExpression) return emptyList() + return provideLambdaReturnValueHints(elem) } }, LAMBDA_IMPLICIT_PARAMETER_RECEIVER( - KotlinBundle.message("hints.title.implicit.parameters.enabled"), + KotlinBundle.message("hints.settings.lambda.receivers.parameters"), KotlinBundle.message("hints.title.implicit.parameters.disabled"), true ) { @@ -137,7 +124,7 @@ enum class HintType(val showDesc: String, val doNotShowDesc: String, defaultEnab }, SUSPENDING_CALL( - KotlinBundle.message("hints.title.suspend.calls.enabled"), + KotlinBundle.message("hints.settings.suspending"), KotlinBundle.message("hints.title.suspend.calls.disabled"), false ) { @@ -171,59 +158,4 @@ enum class HintType(val showDesc: String, val doNotShowDesc: String, defaultEnab val option = Option("SHOW_${this.name}", this.showDesc, defaultEnabled) val enabled get() = option.get() -} - -@Suppress("UnstableApiUsage") -class KotlinInlayParameterHintsProvider : InlayParameterHintsProvider { - - override fun getSupportedOptions(): List