List<FixableUsageInfo> (List<? extends FixableUsageInfo> fieldUsages) { final List<FixableUsageInfo> result = new ArrayList<>(); if (!myEnumConstants.isEmpty()) { final Set<PsiSwitchStatement> switchStatements = new HashSet<>(); for (UsageInfo usage : fieldUsages) { if (usage instanceof ReplaceStaticVariableAccess) { final PsiElement element = usage.getElement(); final PsiSwitchStatement switchStatement = PsiTreeUtil.getParentOfType(element, PsiSwitchStatement.class); if (switchStatement != null) { switchStatements.add(switchStatement); } } } final PsiConstantEvaluationHelper evaluationHelper = JavaPsiFacade.getInstance(myProject).getConstantEvaluationHelper(); final Set<Object> enumValues = new HashSet<>(); for (PsiField enumConstant : myEnumConstants) { enumValues.add(evaluationHelper.computeConstantExpression(enumConstant.getInitializer())); } final PsiType enumValueType = myEnumConstants.get(0).getType(); for (PsiSwitchStatement switchStatement : switchStatements) { final PsiStatement errStatement = EnumConstantsUtil.isEnumSwitch(switchStatement, enumValueType, enumValues); if (errStatement != null) { String description = null; if (errStatement instanceof PsiSwitchLabelStatement) { final PsiExpression caseValue = ((PsiSwitchLabelStatement)errStatement).getCaseValue(); if (caseValue != null) { description = RefactorJBundle.message("case.value.can.not.be.replaced.with.enum", caseValue.getText()); } } result.add(new ConflictUsageInfo(errStatement, description)); } else { final PsiExpression expression = switchStatement.getExpression(); if (expression instanceof PsiReferenceExpression) { final PsiElement element = ((PsiReferenceExpression)expression).resolve(); if (element != null) { if (!element.getManager().isInProject(element)) { String outOfProjectMessage = RefactorJBundle.message("referenced.element.out.of.project", StringUtil.capitalize(RefactoringUIUtil.getDescription(element, false))); result.add(new ConflictUsageInfo(expression, outOfProjectMessage)); } } } else { result.add(new ConflictUsageInfo(expression, null)); } } } final TypeMigrationRules rules = new TypeMigrationRules(myProject); rules.addConversionDescriptor(new EnumTypeConversionRule(myEnumConstants)); rules.setBoundScope(GlobalSearchScope.projectScope(myProject)); myTypeMigrationProcessor = new TypeMigrationProcessor(myProject, PsiUtilCore.toPsiElementArray(myEnumConstants), Functions.constant(JavaPsiFacade.getElementFactory(myProject).createType(myClass)), rules, true); for (UsageInfo usageInfo : myTypeMigrationProcessor.findUsages()) { if (usageInfo.getElement() instanceof PsiField enumConstantField && enumConstantField.hasModifierProperty(PsiModifier.STATIC) && enumConstantField.hasModifierProperty(PsiModifier.FINAL) && enumConstantField.hasInitializer() && !myEnumConstants.contains(enumConstantField)) { continue; } result.add(new EnumTypeMigrationUsageInfo(usageInfo)); } } return result; }