Collection<IntentionAction> (@NotNull PsiJavaCodeReferenceElement ref) { Collection<IntentionAction> result = new ArrayList<>(); PsiElement refParent = ref.getParent(); if (refParent != null && refParent.getParent() instanceof PsiDeconstructionPattern) { result.add(new CreateClassFromUsageFix(ref, CreateClassKind.RECORD)); result.add(new CreateInnerClassFromUsageFix(ref, CreateClassKind.RECORD)); } else { PsiElement parent = PsiTreeUtil.getParentOfType(ref, PsiNewExpression.class, PsiMethod.class); PsiExpressionList expressionList = PsiTreeUtil.getParentOfType(ref, PsiExpressionList.class); boolean isNewExpression = parent instanceof PsiNewExpression && !(refParent instanceof PsiTypeElement) && (expressionList == null || !PsiTreeUtil.isAncestor(parent, expressionList, false)); if (isNewExpression) { result.add(new CreateClassFromNewFix((PsiNewExpression)parent)); } else { result.add(new CreateClassFromUsageFix(ref, CreateClassKind.CLASS)); } result.add(new CreateClassFromUsageFix(ref, CreateClassKind.INTERFACE)); if (PsiUtil.isLanguageLevel5OrHigher(ref)) { result.add(new CreateClassFromUsageFix(ref, CreateClassKind.ENUM)); result.add(new CreateClassFromUsageFix(ref, CreateClassKind.ANNOTATION)); } if (HighlightingFeature.RECORDS.isAvailable(ref)) { if (isNewExpression) { result.add(new CreateRecordFromNewFix((PsiNewExpression)parent)); } else { result.add(new CreateClassFromUsageFix(ref, CreateClassKind.RECORD)); } } if (isNewExpression) { result.add(new CreateInnerClassFromNewFix((PsiNewExpression)parent)); if (HighlightingFeature.RECORDS.isAvailable(ref) && ((PsiNewExpression)parent).getQualifier() == null) { result.add(new CreateInnerRecordFromNewFix((PsiNewExpression)parent)); } } else { result.add(new CreateInnerClassFromUsageFix(ref, CreateClassKind.CLASS)); } } return result; }