mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 05:21:29 +07:00
Disable conversion when anonymous class is annotated (IDEA-197979)
GitOrigin-RevId: 07e199e8ccf2ff58132f642f6bdf178a34802c37
This commit is contained in:
committed by
intellij-monorepo-bot
parent
37158871a3
commit
c53dea2917
@@ -190,6 +190,7 @@ public class AnonymousCanBeLambdaInspection extends AbstractBaseJavaLocalInspect
|
||||
boolean acceptParameterizedFunctionTypes,
|
||||
boolean reportNotAnnotatedInterfaces,
|
||||
@NotNull Set<String> ignoredRuntimeAnnotations) {
|
||||
if (aClass.getBaseClassType().getAnnotations().length > 0) return false;
|
||||
PsiElement parent = aClass.getParent();
|
||||
final PsiElement lambdaContext = parent != null ? PsiUtil.skipParenthesizedExprUp(parent.getParent()) : null;
|
||||
if (lambdaContext == null || !LambdaUtil.isValidLambdaContext(lambdaContext) && !(lambdaContext instanceof PsiReferenceExpression)) return false;
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// "Replace with lambda" "false"
|
||||
import java.lang.annotation.*;
|
||||
|
||||
class MyTest {
|
||||
final Runnable anonymRunnable = new @A Run<caret>nable() {
|
||||
@Override
|
||||
public void run() {
|
||||
System.out.println();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Target({ElementType.TYPE_USE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface A {}
|
||||
Reference in New Issue
Block a user