diff --git a/java/java-impl/src/com/intellij/codeInspection/lambda/RedundantLambdaParameterTypeInspection.java b/java/java-impl/src/com/intellij/codeInspection/lambda/RedundantLambdaParameterTypeInspection.java index 856535a858b8..a443b065431f 100644 --- a/java/java-impl/src/com/intellij/codeInspection/lambda/RedundantLambdaParameterTypeInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/lambda/RedundantLambdaParameterTypeInspection.java @@ -1,11 +1,15 @@ // Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.codeInspection.lambda; -import com.intellij.codeInspection.*; +import com.intellij.codeInspection.AbstractBaseJavaLocalInspectionTool; +import com.intellij.codeInspection.LocalQuickFix; +import com.intellij.codeInspection.ProblemDescriptor; +import com.intellij.codeInspection.ProblemsHolder; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.*; +import com.siyeh.ig.psiutils.CommentTracker; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; @@ -73,7 +77,8 @@ public class RedundantLambdaParameterTypeInspection extends AbstractBaseJavaLoca } final PsiLambdaExpression expression = (PsiLambdaExpression)JavaPsiFacade.getElementFactory(lambdaExpression.getProject()) .createExpressionFromText(text + "->{}", lambdaExpression); - lambdaExpression.getParameterList().replace(expression.getParameterList()); + CommentTracker tracker = new CommentTracker(); + tracker.replaceAndRestoreComments(lambdaExpression.getParameterList(), expression.getParameterList()); } } diff --git a/java/java-tests/testData/codeInspection/redundantLambdaParameterType/InferredFromOtherArgs.java b/java/java-tests/testData/codeInspection/redundantLambdaParameterType/InferredFromOtherArgs.java index abf7228a0904..71da837b4add 100644 --- a/java/java-tests/testData/codeInspection/redundantLambdaParameterType/InferredFromOtherArgs.java +++ b/java/java-tests/testData/codeInspection/redundantLambdaParameterType/InferredFromOtherArgs.java @@ -10,6 +10,6 @@ class ReturnTypeCompatibility { } public static void main(String[] args) { - call("", (String i) -> ""); + call("", (String/*comment*/ i) -> ""); } } \ No newline at end of file diff --git a/java/java-tests/testData/codeInspection/redundantLambdaParameterType/InferredFromOtherArgs_after.java b/java/java-tests/testData/codeInspection/redundantLambdaParameterType/InferredFromOtherArgs_after.java index 4849f5818119..5f24cd9ac936 100644 --- a/java/java-tests/testData/codeInspection/redundantLambdaParameterType/InferredFromOtherArgs_after.java +++ b/java/java-tests/testData/codeInspection/redundantLambdaParameterType/InferredFromOtherArgs_after.java @@ -10,6 +10,6 @@ class ReturnTypeCompatibility { } public static void main(String[] args) { - call("", i -> ""); + call("", i -> /*comment*/ ""); } } \ No newline at end of file