void (@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater) { PsiMethodCallExpression call = ObjectUtils.tryCast(element, PsiMethodCallExpression.class); if (!FILE_ATTR_CALL_MATCHER.test(call)) return; FileVariableModel fileVariable = FileVariableModel.create(call); if (fileVariable == null) return; PsiElement anchor = fileVariable.findAnchor(); if (anchor == null) return; PsiElement parent = anchor.getParent(); if (parent == null) return; String fileVarName = fileVariable.getName(); if (fileVarName == null) return; AttributesVariableModel attributesVariable = AttributesVariableModel.create(fileVarName, fileVariable.myScope, anchor); if (attributesVariable == null) return; List<String> names = new VariableNameGenerator(anchor, VariableKind.LOCAL_VARIABLE).byType(attributesVariable.myType).byName(attributesVariable.myName) .generateAll(true); String name = names.get(0); final PsiDeclarationStatement declaration; if (!attributesVariable.myNeedsTryCatch) { declaration = addDeclaration(parent, anchor, name, attributesVariable.myType, attributesVariable.myInitializer); } else { declaration = addDeclaration(parent, anchor, name, attributesVariable.myType, null); PsiExpressionStatement assignment = addAssignment(parent, anchor, name, attributesVariable.myInitializer); assignment = surroundWithTryCatch(assignment); if (assignment == null) return; PsiExpression lhs = getLhs(assignment); if (lhs == null) return; PsiReference lhsRef = lhs.getReference(); if (lhsRef == null) return; } List<PsiMethodCallExpression> attrCalls = fileVariable.myAttributeCalls; for (int i = 0; i < attrCalls.size(); i++) { PsiMethodCallExpression attrCall = attrCalls.get(i); String replacement = getBulkCallReplacement(name, attrCall); PsiReplacementUtil.replaceExpressionAndShorten(attrCall, replacement, new CommentTracker()); } PsiVariable attrsVariable = (PsiVariable)declaration.getDeclaredElements()[0]; updater.rename(attrsVariable, names); }