Commit c08578a8 authored by Tagir Valeev's avatar Tagir Valeev
Browse files

AnonymousCanBeLambdaInspection: support parenthesized anonymous class

parent 7f984004
Branches unavailable Tags unavailable
No related merge requests found
Showing with 17 additions and 1 deletion
+17 -1
......@@ -199,7 +199,7 @@ public class AnonymousCanBeLambdaInspection extends AbstractBaseJavaLocalInspect
boolean reportNotAnnotatedInterfaces,
@NotNull Set<String> ignoredRuntimeAnnotations) {
PsiElement parent = aClass.getParent();
final PsiElement lambdaContext = parent != null ? parent.getParent() : null;
final PsiElement lambdaContext = parent != null ? PsiUtil.skipParenthesizedExprUp(parent.getParent()) : null;
if (lambdaContext == null || !LambdaUtil.isValidLambdaContext(lambdaContext) && !(lambdaContext instanceof PsiReferenceExpression)) return false;
return isLambdaForm(aClass, acceptParameterizedFunctionTypes, reportNotAnnotatedInterfaces, ignoredRuntimeAnnotations);
}
......
// "Replace with lambda" "true"
class Test {
private void doSomething() {
((Runnable) () -> System.out.println()).run();
}
}
\ No newline at end of file
// "Replace with lambda" "true"
class Test {
private void doSomething() {
(new <caret>Runnable() {
public void run() {
System.out.println();
}
}).run();
}
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment