Drop everything related to lambda syntax deprecation
This commit is contained in:
@@ -364,9 +364,6 @@ public interface Errors {
|
|||||||
|
|
||||||
DiagnosticFactory0<JetParameter> USELESS_VARARG_ON_PARAMETER = DiagnosticFactory0.create(WARNING);
|
DiagnosticFactory0<JetParameter> USELESS_VARARG_ON_PARAMETER = DiagnosticFactory0.create(WARNING);
|
||||||
|
|
||||||
DiagnosticFactory0<JetFunctionLiteralExpression> DEPRECATED_LAMBDA_SYNTAX =
|
|
||||||
DiagnosticFactory0.create(WARNING, FUNCTION_LITERAL_EXPRESSION_DECLARATION);
|
|
||||||
|
|
||||||
// Named parameters
|
// Named parameters
|
||||||
|
|
||||||
DiagnosticFactory0<JetParameter> DEFAULT_VALUE_NOT_ALLOWED_IN_OVERRIDE = DiagnosticFactory0.create(ERROR, PARAMETER_DEFAULT_VALUE);
|
DiagnosticFactory0<JetParameter> DEFAULT_VALUE_NOT_ALLOWED_IN_OVERRIDE = DiagnosticFactory0.create(ERROR, PARAMETER_DEFAULT_VALUE);
|
||||||
|
|||||||
@@ -178,12 +178,6 @@ public object PositioningStrategies {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public val FUNCTION_LITERAL_EXPRESSION_DECLARATION: PositioningStrategy<JetFunctionLiteralExpression>
|
|
||||||
= object : PositioningStrategy<JetFunctionLiteralExpression>() {
|
|
||||||
override fun mark(element: JetFunctionLiteralExpression) = DECLARATION_SIGNATURE_OR_DEFAULT.mark(element.getFunctionLiteral())
|
|
||||||
override fun isValid(element: JetFunctionLiteralExpression) = DECLARATION_SIGNATURE_OR_DEFAULT.isValid(element.getFunctionLiteral())
|
|
||||||
}
|
|
||||||
|
|
||||||
public val TYPE_PARAMETERS_OR_DECLARATION_SIGNATURE: PositioningStrategy<JetDeclaration> = object : PositioningStrategy<JetDeclaration>() {
|
public val TYPE_PARAMETERS_OR_DECLARATION_SIGNATURE: PositioningStrategy<JetDeclaration> = object : PositioningStrategy<JetDeclaration>() {
|
||||||
override fun mark(element: JetDeclaration): List<TextRange> {
|
override fun mark(element: JetDeclaration): List<TextRange> {
|
||||||
if (element is JetTypeParameterListOwner) {
|
if (element is JetTypeParameterListOwner) {
|
||||||
|
|||||||
-2
@@ -226,8 +226,6 @@ public class DefaultErrorMessages {
|
|||||||
|
|
||||||
MAP.put(FUNCTION_EXPRESSION_PARAMETER_WITH_DEFAULT_VALUE, "A function expression is not allowed to specify default values for its parameters");
|
MAP.put(FUNCTION_EXPRESSION_PARAMETER_WITH_DEFAULT_VALUE, "A function expression is not allowed to specify default values for its parameters");
|
||||||
MAP.put(USELESS_VARARG_ON_PARAMETER, "Vararg on this parameter is useless");
|
MAP.put(USELESS_VARARG_ON_PARAMETER, "Vararg on this parameter is useless");
|
||||||
MAP.put(DEPRECATED_LAMBDA_SYNTAX,
|
|
||||||
"This syntax for lambda is deprecated. Use short lambda notation {a[: Int], b[: String] -> ...} or function expression instead.");
|
|
||||||
|
|
||||||
MAP.put(PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT, "Projections are not allowed on type arguments of functions and properties");
|
MAP.put(PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT, "Projections are not allowed on type arguments of functions and properties");
|
||||||
MAP.put(SUPERTYPE_NOT_INITIALIZED, "This type has a constructor, and thus must be initialized here");
|
MAP.put(SUPERTYPE_NOT_INITIALIZED, "This type has a constructor, and thus must be initialized here");
|
||||||
|
|||||||
@@ -63,14 +63,4 @@ public class JetParameterList extends JetElementImplStub<KotlinPlaceHolderStub<J
|
|||||||
public void removeParameter(@NotNull JetParameter parameter) {
|
public void removeParameter(@NotNull JetParameter parameter) {
|
||||||
EditCommaSeparatedListHelper.INSTANCE$.removeItem(parameter);
|
EditCommaSeparatedListHelper.INSTANCE$.removeItem(parameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// this method needed only for migrate lambda syntax
|
|
||||||
@Deprecated
|
|
||||||
public boolean isParenthesized() {
|
|
||||||
PsiElement firstChild = getFirstChild();
|
|
||||||
if (firstChild != null && firstChild.getNode() != null) {
|
|
||||||
return firstChild.getNode().getElementType() == JetTokens.LPAR;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -884,16 +884,6 @@ public class JetPsiUtil {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isDeprecatedLambdaSyntax(@NotNull JetFunctionLiteralExpression functionLiteralExpression) {
|
|
||||||
JetFunctionLiteral functionLiteral = functionLiteralExpression.getFunctionLiteral();
|
|
||||||
if (functionLiteral.hasDeclaredReturnType() || functionLiteral.getReceiverTypeReference() != null) return true;
|
|
||||||
|
|
||||||
JetParameterList valueParameterList = functionLiteral.getValueParameterList();
|
|
||||||
if (valueParameterList != null && valueParameterList.isParenthesized()) return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static JetExpression getLastElementDeparenthesized(
|
public static JetExpression getLastElementDeparenthesized(
|
||||||
@Nullable JetExpression expression,
|
@Nullable JetExpression expression,
|
||||||
|
|||||||
@@ -136,10 +136,6 @@ public class FunctionsTypingVisitor(facade: ExpressionTypingInternals) : Express
|
|||||||
override fun visitFunctionLiteralExpression(expression: JetFunctionLiteralExpression, context: ExpressionTypingContext): JetTypeInfo? {
|
override fun visitFunctionLiteralExpression(expression: JetFunctionLiteralExpression, context: ExpressionTypingContext): JetTypeInfo? {
|
||||||
if (!expression.getFunctionLiteral().hasBody()) return null
|
if (!expression.getFunctionLiteral().hasBody()) return null
|
||||||
|
|
||||||
if (JetPsiUtil.isDeprecatedLambdaSyntax(expression)) {
|
|
||||||
context.trace.report(DEPRECATED_LAMBDA_SYNTAX.on(expression))
|
|
||||||
}
|
|
||||||
|
|
||||||
val expectedType = context.expectedType
|
val expectedType = context.expectedType
|
||||||
val functionTypeExpected = !noExpectedType(expectedType) && KotlinBuiltIns.isFunctionOrExtensionFunctionType(expectedType)
|
val functionTypeExpected = !noExpectedType(expectedType) && KotlinBuiltIns.isFunctionOrExtensionFunctionType(expectedType)
|
||||||
|
|
||||||
|
|||||||
@@ -82,7 +82,6 @@ public class KotlinCleanupInspection(): LocalInspectionTool(), CleanupLocalInspe
|
|||||||
private fun Diagnostic.isCleanup() = getFactory() in cleanupDiagnosticsFactories || isObsoleteLabel()
|
private fun Diagnostic.isCleanup() = getFactory() in cleanupDiagnosticsFactories || isObsoleteLabel()
|
||||||
|
|
||||||
private val cleanupDiagnosticsFactories = setOf(
|
private val cleanupDiagnosticsFactories = setOf(
|
||||||
Errors.DEPRECATED_LAMBDA_SYNTAX,
|
|
||||||
Errors.MISSING_CONSTRUCTOR_KEYWORD,
|
Errors.MISSING_CONSTRUCTOR_KEYWORD,
|
||||||
Errors.FUNCTION_EXPRESSION_WITH_NAME,
|
Errors.FUNCTION_EXPRESSION_WITH_NAME,
|
||||||
Errors.UNNECESSARY_NOT_NULL_ASSERTION,
|
Errors.UNNECESSARY_NOT_NULL_ASSERTION,
|
||||||
|
|||||||
@@ -1,206 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2015 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.quickfix
|
|
||||||
|
|
||||||
import com.intellij.openapi.editor.Editor
|
|
||||||
import com.intellij.openapi.project.Project
|
|
||||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
|
||||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
|
||||||
import org.jetbrains.kotlin.diagnostics.DiagnosticUtils
|
|
||||||
import org.jetbrains.kotlin.idea.JetBundle
|
|
||||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
|
||||||
import org.jetbrains.kotlin.idea.core.moveInsideParenthesesAndReplaceWith
|
|
||||||
import org.jetbrains.kotlin.idea.quickfix.quickfixUtil.createIntentionFactory
|
|
||||||
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
|
|
||||||
import org.jetbrains.kotlin.idea.util.ShortenReferences
|
|
||||||
import org.jetbrains.kotlin.name.Name
|
|
||||||
import org.jetbrains.kotlin.psi.*
|
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.getFunctionLiteralArgumentName
|
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
|
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.siblings
|
|
||||||
|
|
||||||
public class DeprecatedLambdaSyntaxFix(element: JetFunctionLiteralExpression) : JetIntentionAction<JetFunctionLiteralExpression>(element), CleanupFix {
|
|
||||||
override fun getText() = JetBundle.message("migrate.lambda.syntax")
|
|
||||||
override fun getFamilyName() = JetBundle.message("migrate.lambda.syntax.family")
|
|
||||||
|
|
||||||
override fun invoke(project: Project, editor: Editor?, file: JetFile) {
|
|
||||||
DeprecatedSyntaxFix.createFix(element).runFix()
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object Factory : JetSingleIntentionActionFactory() {
|
|
||||||
override fun createAction(diagnostic: Diagnostic)
|
|
||||||
= (diagnostic.getPsiElement() as? JetFunctionLiteralExpression)?.let { DeprecatedLambdaSyntaxFix(it) }
|
|
||||||
|
|
||||||
public fun createWholeProjectFixFactory(): JetSingleIntentionActionFactory = createIntentionFactory {
|
|
||||||
JetWholeProjectForEachElementOfTypeFix.createByTaskFactory(
|
|
||||||
taskFactory = fun (it: JetFunctionLiteralExpression) = fixTaskFactory(it),
|
|
||||||
taskProcessor = { it.runFix() },
|
|
||||||
name = "Migrate lambda syntax in whole project"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun fixTaskFactory(functionLiteralExpression: JetFunctionLiteralExpression): DeprecatedSyntaxFix? {
|
|
||||||
return if (JetPsiUtil.isDeprecatedLambdaSyntax(functionLiteralExpression)) {
|
|
||||||
DeprecatedSyntaxFix.createFix(functionLiteralExpression)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private interface DeprecatedSyntaxFix {
|
|
||||||
// you must run it under write action
|
|
||||||
fun runFix()
|
|
||||||
|
|
||||||
internal companion object {
|
|
||||||
fun createFix(functionLiteralExpression: JetFunctionLiteralExpression): DeprecatedSyntaxFix {
|
|
||||||
val functionLiteral = functionLiteralExpression.getFunctionLiteral()
|
|
||||||
val hasNoReturnAndReceiverType = !functionLiteral.hasDeclaredReturnType() && functionLiteral.getReceiverTypeReference() == null
|
|
||||||
|
|
||||||
return if (hasNoReturnAndReceiverType) DeparenthesizeParameterList(functionLiteralExpression)
|
|
||||||
else LambdaToFunctionExpression(functionLiteralExpression)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class DeparenthesizeParameterList(
|
|
||||||
val functionLiteralExpression: JetFunctionLiteralExpression
|
|
||||||
): DeprecatedSyntaxFix {
|
|
||||||
|
|
||||||
override fun runFix() {
|
|
||||||
if (!JetPsiUtil.isDeprecatedLambdaSyntax(functionLiteralExpression)) return
|
|
||||||
|
|
||||||
val psiFactory = JetPsiFactory(functionLiteralExpression)
|
|
||||||
val functionLiteral = functionLiteralExpression.getFunctionLiteral()
|
|
||||||
val parameterList = functionLiteral.getValueParameterList()
|
|
||||||
if (parameterList != null && parameterList.isParenthesized()) {
|
|
||||||
val oldParameterList = parameterList.getText()
|
|
||||||
val newParameterList = oldParameterList.substring(1..oldParameterList.length() - 2)
|
|
||||||
parameterList.replace(psiFactory.createFunctionLiteralParameterList(newParameterList))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class LambdaToFunctionExpression(
|
|
||||||
val functionLiteralExpression: JetFunctionLiteralExpression
|
|
||||||
): DeprecatedSyntaxFix {
|
|
||||||
val functionLiteralArgumentName: Name?
|
|
||||||
val receiverType: String?
|
|
||||||
val returnType: String?
|
|
||||||
|
|
||||||
init {
|
|
||||||
val bindingContext = functionLiteralExpression.analyze()
|
|
||||||
val functionLiteralType = bindingContext.getType(functionLiteralExpression)
|
|
||||||
assert(functionLiteralType != null && KotlinBuiltIns.isExactFunctionOrExtensionFunctionType(functionLiteralType)) {
|
|
||||||
"Broken function type for expression: ${functionLiteralExpression.getText()}, at: ${DiagnosticUtils.atLocation(functionLiteralExpression)}"
|
|
||||||
}
|
|
||||||
functionLiteralType!!
|
|
||||||
receiverType = KotlinBuiltIns.getReceiverType(functionLiteralType)?.let { IdeDescriptorRenderers.SOURCE_CODE.renderType(it) }
|
|
||||||
returnType = KotlinBuiltIns.getReturnTypeFromFunctionType(functionLiteralType).let {
|
|
||||||
if (KotlinBuiltIns.isUnit(it))
|
|
||||||
null
|
|
||||||
else
|
|
||||||
IdeDescriptorRenderers.SOURCE_CODE.renderType(it)
|
|
||||||
}
|
|
||||||
functionLiteralArgumentName = getFunctionLiteralArgument()?.getFunctionLiteralArgumentName(bindingContext)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun runFix() {
|
|
||||||
if (!JetPsiUtil.isDeprecatedLambdaSyntax(functionLiteralExpression)) return
|
|
||||||
|
|
||||||
val newFunctionExpression = createFunctionExpression()
|
|
||||||
|
|
||||||
val literalArgument = getFunctionLiteralArgument()
|
|
||||||
val replacedFunctionExpression = if (literalArgument == null) {
|
|
||||||
functionLiteralExpression.replace(newFunctionExpression)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
literalArgument.moveInsideParenthesesAndReplaceWith(newFunctionExpression, functionLiteralArgumentName).
|
|
||||||
getValueArguments().last().getArgumentExpression()
|
|
||||||
}
|
|
||||||
|
|
||||||
val functionExpression = JetPsiUtil.deparenthesize(replacedFunctionExpression as JetExpression) as JetNamedFunction
|
|
||||||
|
|
||||||
ShortenReferences.DEFAULT.process(
|
|
||||||
listOf(functionExpression.getReceiverTypeReference(), functionExpression.getTypeReference()).filterNotNull())
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getFunctionLiteralArgument(): JetFunctionLiteralArgument? {
|
|
||||||
val argument = functionLiteralExpression.getParentOfType<JetFunctionLiteralArgument>(strict = false)
|
|
||||||
|
|
||||||
if (argument != null && argument.getFunctionLiteral() == functionLiteralExpression) {
|
|
||||||
return argument
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun JetExpression.replaceWithReturn(psiFactory: JetPsiFactory) {
|
|
||||||
if (this is JetReturnExpression) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
replace(psiFactory.createExpressionByPattern("return $0", this))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getLambdaLabelName(): String? {
|
|
||||||
val labeledExpression = functionLiteralExpression.getParentOfType<JetLabeledExpression>(strict = false)
|
|
||||||
if (labeledExpression != null && JetPsiUtil.deparenthesize(labeledExpression.getBaseExpression()) == functionLiteralExpression) {
|
|
||||||
return labeledExpression.getLabelName()
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun createFunctionExpression(): JetNamedFunction {
|
|
||||||
val psiFactory = JetPsiFactory(functionLiteralExpression)
|
|
||||||
val functionLiteral = functionLiteralExpression.getFunctionLiteral()
|
|
||||||
val functionName = getLambdaLabelName()
|
|
||||||
val parameterList = functionLiteral.getValueParameterList()?.getText()
|
|
||||||
|
|
||||||
val functionDeclaration = "fun " +
|
|
||||||
(receiverType?.let { "$it." } ?: "") +
|
|
||||||
(functionName ?: "") +
|
|
||||||
(parameterList ?: "()") +
|
|
||||||
(returnType?.let { ": $it" } ?: "")
|
|
||||||
|
|
||||||
val functionWithEmptyBody = psiFactory.createFunction(functionDeclaration + " {}")
|
|
||||||
|
|
||||||
val blockExpression = functionLiteral.getBodyExpression() ?: return functionWithEmptyBody
|
|
||||||
|
|
||||||
val statements = blockExpression.getStatements()
|
|
||||||
if (statements.isEmpty()) return functionWithEmptyBody
|
|
||||||
|
|
||||||
if (statements.size() == 1) {
|
|
||||||
return psiFactory.createFunction(functionDeclaration + " = " + statements.first().getText())
|
|
||||||
}
|
|
||||||
|
|
||||||
// many statements
|
|
||||||
if (returnType != null) statements.filterIsInstance<JetExpression>().lastOrNull()?.replaceWithReturn(psiFactory)
|
|
||||||
|
|
||||||
val fromElement = functionLiteral.getArrow() ?: functionLiteral.getLBrace()
|
|
||||||
val toElement = functionLiteral.getRBrace()
|
|
||||||
// to include comments in the start/end of the body
|
|
||||||
val bodyText = fromElement.siblings(withItself = false)
|
|
||||||
.takeWhile { it != toElement }
|
|
||||||
.map { it.getText() }
|
|
||||||
.joinToString("")
|
|
||||||
return psiFactory.createFunction(functionDeclaration + "{ " + bodyText + "}")
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -222,7 +222,6 @@ public class QuickFixRegistrar : QuickFixContributor {
|
|||||||
NO_VALUE_FOR_PARAMETER.registerFactory(ChangeFunctionSignatureFix.createFactory())
|
NO_VALUE_FOR_PARAMETER.registerFactory(ChangeFunctionSignatureFix.createFactory())
|
||||||
UNUSED_PARAMETER.registerFactory(ChangeFunctionSignatureFix.createFactoryForUnusedParameter())
|
UNUSED_PARAMETER.registerFactory(ChangeFunctionSignatureFix.createFactoryForUnusedParameter())
|
||||||
EXPECTED_PARAMETERS_NUMBER_MISMATCH.registerFactory(ChangeFunctionSignatureFix.createFactoryForParametersNumberMismatch())
|
EXPECTED_PARAMETERS_NUMBER_MISMATCH.registerFactory(ChangeFunctionSignatureFix.createFactoryForParametersNumberMismatch())
|
||||||
DEPRECATED_LAMBDA_SYNTAX.registerFactory(DeprecatedLambdaSyntaxFix, DeprecatedLambdaSyntaxFix.createWholeProjectFixFactory())
|
|
||||||
|
|
||||||
EXPECTED_PARAMETER_TYPE_MISMATCH.registerFactory(ChangeTypeFix.createFactoryForExpectedParameterTypeMismatch())
|
EXPECTED_PARAMETER_TYPE_MISMATCH.registerFactory(ChangeTypeFix.createFactoryForExpectedParameterTypeMismatch())
|
||||||
EXPECTED_RETURN_TYPE_MISMATCH.registerFactory(ChangeTypeFix.createFactoryForExpectedReturnTypeMismatch())
|
EXPECTED_RETURN_TYPE_MISMATCH.registerFactory(ChangeTypeFix.createFactoryForExpectedReturnTypeMismatch())
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ import pack.oldFun1
|
|||||||
import pack.oldFun2 // should not be removed for non-deprecated overload used
|
import pack.oldFun2 // should not be removed for non-deprecated overload used
|
||||||
import pack.oldFun3
|
import pack.oldFun3
|
||||||
|
|
||||||
val f = { (a: Int, b: Int) -> a + b }
|
|
||||||
|
|
||||||
class A private()
|
class A private()
|
||||||
|
|
||||||
val x = fun foo(x: String) { }
|
val x = fun foo(x: String) { }
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import pack.bar
|
import pack.bar
|
||||||
import pack.oldFun2 // should not be removed for non-deprecated overload used
|
import pack.oldFun2 // should not be removed for non-deprecated overload used
|
||||||
|
|
||||||
val f = { a: Int, b: Int -> a + b }
|
|
||||||
|
|
||||||
class A private constructor()
|
class A private constructor()
|
||||||
|
|
||||||
val x = fun(x: String) { }
|
val x = fun(x: String) { }
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
// "Migrate lambda syntax" "true"
|
|
||||||
|
|
||||||
class A
|
|
||||||
|
|
||||||
fun foo(a: Int.(String) -> A) {}
|
|
||||||
|
|
||||||
val a = foo a@ { <caret>Int.(a: String): A ->
|
|
||||||
A()
|
|
||||||
A()
|
|
||||||
}
|
|
||||||
-10
@@ -1,10 +0,0 @@
|
|||||||
// "Migrate lambda syntax" "true"
|
|
||||||
|
|
||||||
class A
|
|
||||||
|
|
||||||
fun foo(a: Int.(String) -> A) {}
|
|
||||||
|
|
||||||
val a = foo(fun Int.a(a: String): A {
|
|
||||||
A()
|
|
||||||
return A()
|
|
||||||
})
|
|
||||||
Vendored
-10
@@ -1,10 +0,0 @@
|
|||||||
// "Migrate lambda syntax" "true"
|
|
||||||
|
|
||||||
class A
|
|
||||||
|
|
||||||
fun foo(a: Int.(String) -> A) {}
|
|
||||||
|
|
||||||
val a = foo a@ { <caret>(a: String): A ->
|
|
||||||
A()
|
|
||||||
A()
|
|
||||||
}
|
|
||||||
Vendored
-10
@@ -1,10 +0,0 @@
|
|||||||
// "Migrate lambda syntax" "true"
|
|
||||||
|
|
||||||
class A
|
|
||||||
|
|
||||||
fun foo(a: Int.(String) -> A) {}
|
|
||||||
|
|
||||||
val a = foo(fun Int.a(a: String): A {
|
|
||||||
A()
|
|
||||||
return A()
|
|
||||||
})
|
|
||||||
-10
@@ -1,10 +0,0 @@
|
|||||||
// "Migrate lambda syntax" "true"
|
|
||||||
|
|
||||||
class A
|
|
||||||
|
|
||||||
fun foo(a: Int.(String) -> A) {}
|
|
||||||
|
|
||||||
val a = foo a@ { <caret>Int.(a: String) ->
|
|
||||||
A()
|
|
||||||
A()
|
|
||||||
}
|
|
||||||
Vendored
-10
@@ -1,10 +0,0 @@
|
|||||||
// "Migrate lambda syntax" "true"
|
|
||||||
|
|
||||||
class A
|
|
||||||
|
|
||||||
fun foo(a: Int.(String) -> A) {}
|
|
||||||
|
|
||||||
val a = foo(fun Int.a(a: String): A {
|
|
||||||
A()
|
|
||||||
return A()
|
|
||||||
})
|
|
||||||
-9
@@ -1,9 +0,0 @@
|
|||||||
// "Migrate lambda syntax" "true"
|
|
||||||
|
|
||||||
class A
|
|
||||||
|
|
||||||
fun foo(a: Any) {}
|
|
||||||
|
|
||||||
val a = foo a@ { <caret>Int.(a: String): A ->
|
|
||||||
A()
|
|
||||||
}
|
|
||||||
-7
@@ -1,7 +0,0 @@
|
|||||||
// "Migrate lambda syntax" "true"
|
|
||||||
|
|
||||||
class A
|
|
||||||
|
|
||||||
fun foo(a: Any) {}
|
|
||||||
|
|
||||||
val a = foo(fun Int.a(a: String): A = A())
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
// "Migrate lambda syntax" "true"
|
|
||||||
|
|
||||||
class A
|
|
||||||
|
|
||||||
fun foo(a: (Int).(String) -> Int) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
val a = foo ({
|
|
||||||
<caret>(Int).(a: String) -> 4
|
|
||||||
})
|
|
||||||
-10
@@ -1,10 +0,0 @@
|
|||||||
// "Migrate lambda syntax" "true"
|
|
||||||
|
|
||||||
class A
|
|
||||||
|
|
||||||
fun foo(a: (Int).(String) -> Int) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
val a = foo (fun Int.(a: String): Int = 4)
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
// "Migrate lambda syntax" "true"
|
|
||||||
|
|
||||||
class A
|
|
||||||
|
|
||||||
fun foo(a: Any) {}
|
|
||||||
|
|
||||||
val a = foo a@ {
|
|
||||||
|
|
||||||
val a = { <caret>(): Int -> 1 }
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
// "Migrate lambda syntax" "true"
|
|
||||||
|
|
||||||
class A
|
|
||||||
|
|
||||||
fun foo(a: Any) {}
|
|
||||||
|
|
||||||
val a = foo a@ {
|
|
||||||
|
|
||||||
val a = fun(): Int = 1
|
|
||||||
}
|
|
||||||
-6
@@ -1,6 +0,0 @@
|
|||||||
val h = { -> }
|
|
||||||
|
|
||||||
val l = bar@ fun Int.bar() {
|
|
||||||
}
|
|
||||||
|
|
||||||
val s = (fun(): Int = 5)()
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
// "Migrate lambda syntax in whole project" "true"
|
|
||||||
|
|
||||||
val a = fun(): Int {
|
|
||||||
|
|
||||||
val b = fun(): Int = 5
|
|
||||||
|
|
||||||
return b()
|
|
||||||
}
|
|
||||||
-5
@@ -1,5 +0,0 @@
|
|||||||
val h = { () -> }
|
|
||||||
|
|
||||||
val l = bar@ { Int.() -> }
|
|
||||||
|
|
||||||
val s = {(): Int -> 5}()
|
|
||||||
-8
@@ -1,8 +0,0 @@
|
|||||||
// "Migrate lambda syntax in whole project" "true"
|
|
||||||
|
|
||||||
val a = { <caret>(): Int ->
|
|
||||||
|
|
||||||
val b = { (): Int -> 5 }
|
|
||||||
|
|
||||||
b()
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
// "Migrate lambda syntax" "true"
|
|
||||||
|
|
||||||
|
|
||||||
val a = { <caret>(p: Int): String ->
|
|
||||||
val v = p + 1
|
|
||||||
v.toString()
|
|
||||||
// returns v.toString()
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
// "Migrate lambda syntax" "true"
|
|
||||||
|
|
||||||
|
|
||||||
val a = fun(p: Int): String {
|
|
||||||
val v = p + 1
|
|
||||||
return v.toString()
|
|
||||||
// returns v.toString()
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
// "Migrate lambda syntax" "true"
|
|
||||||
|
|
||||||
|
|
||||||
val a = { <caret>(a: Int) -> }
|
|
||||||
-4
@@ -1,4 +0,0 @@
|
|||||||
// "Migrate lambda syntax" "true"
|
|
||||||
|
|
||||||
|
|
||||||
val a = { a: Int -> }
|
|
||||||
-4
@@ -1,4 +0,0 @@
|
|||||||
// "Migrate lambda syntax" "true"
|
|
||||||
|
|
||||||
|
|
||||||
val a = { <caret>Int.(a: Int): String -> "" }
|
|
||||||
-4
@@ -1,4 +0,0 @@
|
|||||||
// "Migrate lambda syntax" "true"
|
|
||||||
|
|
||||||
|
|
||||||
val a = fun Int.(a: Int): String = ""
|
|
||||||
@@ -1078,21 +1078,6 @@ public class QuickFixMultiFileTestGenerated extends AbstractQuickFixMultiFileTes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("idea/testData/quickfix/migration/lambdaSyntax")
|
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
|
||||||
public static class LambdaSyntax extends AbstractQuickFixMultiFileTest {
|
|
||||||
public void testAllFilesPresentInLambdaSyntax() throws Exception {
|
|
||||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/migration/lambdaSyntax"), Pattern.compile("^(\\w+)\\.before\\.Main\\.kt$"), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("lambdaSyntaxMultiple.before.Main.kt")
|
|
||||||
public void testLambdaSyntaxMultiple() throws Exception {
|
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/lambdaSyntax/lambdaSyntaxMultiple.before.Main.kt");
|
|
||||||
doTestWithExtraFile(fileName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("idea/testData/quickfix/migration/migrateJavaAnnotationMethodCall")
|
@TestMetadata("idea/testData/quickfix/migration/migrateJavaAnnotationMethodCall")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
@@ -4124,69 +4124,6 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("idea/testData/quickfix/migration/lambdaSyntax")
|
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
|
||||||
public static class LambdaSyntax extends AbstractQuickFixTest {
|
|
||||||
public void testAllFilesPresentInLambdaSyntax() throws Exception {
|
|
||||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/migration/lambdaSyntax"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("labelInLiteralArgument.kt")
|
|
||||||
public void testLabelInLiteralArgument() throws Exception {
|
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/lambdaSyntax/labelInLiteralArgument.kt");
|
|
||||||
doTest(fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("labelInLiteralArgumentImplicitReceiverType.kt")
|
|
||||||
public void testLabelInLiteralArgumentImplicitReceiverType() throws Exception {
|
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/lambdaSyntax/labelInLiteralArgumentImplicitReceiverType.kt");
|
|
||||||
doTest(fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("labelInLiteralArgumentImplicitReturnType.kt")
|
|
||||||
public void testLabelInLiteralArgumentImplicitReturnType() throws Exception {
|
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/lambdaSyntax/labelInLiteralArgumentImplicitReturnType.kt");
|
|
||||||
doTest(fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("labelInLiteralArgumentOneStatement.kt")
|
|
||||||
public void testLabelInLiteralArgumentOneStatement() throws Exception {
|
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/lambdaSyntax/labelInLiteralArgumentOneStatement.kt");
|
|
||||||
doTest(fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("lambdaInFunctionArgument.kt")
|
|
||||||
public void testLambdaInFunctionArgument() throws Exception {
|
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/lambdaSyntax/lambdaInFunctionArgument.kt");
|
|
||||||
doTest(fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("lambdaInsideLambda.kt")
|
|
||||||
public void testLambdaInsideLambda() throws Exception {
|
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/lambdaSyntax/lambdaInsideLambda.kt");
|
|
||||||
doTest(fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("lastStatementIsComment.kt")
|
|
||||||
public void testLastStatementIsComment() throws Exception {
|
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/lambdaSyntax/lastStatementIsComment.kt");
|
|
||||||
doTest(fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("paranthesizedParameters.kt")
|
|
||||||
public void testParanthesizedParameters() throws Exception {
|
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/lambdaSyntax/paranthesizedParameters.kt");
|
|
||||||
doTest(fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("receiverAndReturnInExpression.kt")
|
|
||||||
public void testReceiverAndReturnInExpression() throws Exception {
|
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/lambdaSyntax/receiverAndReturnInExpression.kt");
|
|
||||||
doTest(fileName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("idea/testData/quickfix/migration/missingConstructorKeyword")
|
@TestMetadata("idea/testData/quickfix/migration/missingConstructorKeyword")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
Reference in New Issue
Block a user